Compare commits
No commits in common. "02f41e57c108a0c7dca71d0b71489c89d7c16384" and "6fdbc88910950e6f98607aa21f1caad8086198a9" have entirely different histories.
02f41e57c1
...
6fdbc88910
@ -12,25 +12,25 @@
|
|||||||
import { Badge } from '$lib/components/ui/badge';
|
import { Badge } from '$lib/components/ui/badge';
|
||||||
import { Separator } from '$lib/components/ui/separator';
|
import { Separator } from '$lib/components/ui/separator';
|
||||||
import { db, createShortform, type List, type Shortform } from '../db/main';
|
import { db, createShortform, type List, type Shortform } from '../db/main';
|
||||||
import { cacheShortform } from '../modules/shortforms';
|
import { cacheShortform } from "../modules/shortforms";
|
||||||
import { liveQuery } from 'dexie';
|
import { liveQuery } from "dexie";
|
||||||
|
|
||||||
import { ScrollArea } from '$lib/components/ui/scroll-area/index.js';
|
import { ScrollArea } from "$lib/components/ui/scroll-area/index.js";
|
||||||
|
|
||||||
$: abbForm = {
|
$: abbForm = {
|
||||||
shortform: '',
|
shortform: "",
|
||||||
phrase: '',
|
phrase: "",
|
||||||
target: '',
|
target: "",
|
||||||
errors: []
|
errors: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
let importing = false;
|
let importing = false;
|
||||||
let progress = 0;
|
let progress = 0;
|
||||||
const handleCreate = async (e) => {
|
const handleCreate = async (e) => {
|
||||||
// abbForm.errors = []
|
// abbForm.errors = []
|
||||||
e.preventDefault();
|
e.preventDefault()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
id?: number;
|
id?: number;
|
||||||
listid: number;
|
listid: number;
|
||||||
shortform: string;
|
shortform: string;
|
||||||
@ -42,59 +42,55 @@
|
|||||||
*/
|
*/
|
||||||
const sf = {
|
const sf = {
|
||||||
listid: abbForm.target.value,
|
listid: abbForm.target.value,
|
||||||
shortform: abbForm.shortform.replace(/\s/g, '').toLowerCase(),
|
shortform: abbForm.shortform.replace(/\s/g,"").toLowerCase(),
|
||||||
phrase: abbForm.phrase.trim(),
|
phrase: abbForm.phrase.trim(),
|
||||||
last_used: new Date(0),
|
last_used: new Date(0),
|
||||||
uses: 0,
|
uses: 0,
|
||||||
remind: 0,
|
remind: 0,
|
||||||
updated: Date.now()
|
updated: Date.now(),
|
||||||
};
|
}
|
||||||
//appState.open = ""
|
//appState.open = ""
|
||||||
db.shortforms
|
db.shortforms.where("[listid+shortform]").equals([sf.listid, sf.shortform]).first()
|
||||||
.where('[listid+shortform]')
|
.then(existing => {
|
||||||
.equals([sf.listid, sf.shortform])
|
sf.id = existing.id
|
||||||
.first()
|
db.shortforms.put(sf).then(result => {
|
||||||
.then((existing) => {
|
cacheShortform(sf);
|
||||||
sf.id = existing.id;
|
appState.open = ""
|
||||||
db.shortforms.put(sf).then((result) => {
|
|
||||||
cacheShortform(sf);
|
|
||||||
appState.open = '';
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
})
|
||||||
db.shortforms.put(sf).then((result) => {
|
.catch(() => {
|
||||||
cacheShortform(sf);
|
db.shortforms.put(sf).then(result => {
|
||||||
appState.open = '';
|
cacheShortform(sf);
|
||||||
});
|
appState.open = ""
|
||||||
});
|
})
|
||||||
|
})
|
||||||
};
|
};
|
||||||
const cancelCreate = () => {
|
const cancelCreate = () => {
|
||||||
abbForm.shortform = '';
|
abbForm.shortform = ""
|
||||||
abbForm.phrase = '';
|
abbForm.phrase = ""
|
||||||
abbForm.target = {};
|
abbForm.target = {}
|
||||||
abbForm.errors = [];
|
abbForm.errors = []
|
||||||
appState.open = '';
|
appState.open = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelectedChange = (v) => {
|
const onSelectedChange = (v) => {
|
||||||
console.log(v);
|
console.log(v)
|
||||||
abbForm.target = v;
|
abbForm.target = v
|
||||||
};
|
}
|
||||||
let selectedLists = [];
|
let selectedLists = []
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
db.lists.get(shortforms.standardList).then((l) => {
|
db.lists.get(shortforms.standardList).then(l => {
|
||||||
selectedLists.push({ value: l.id, label: l.name });
|
selectedLists.push({ value: l.id, label: l.name })
|
||||||
abbForm.target = { value: l.id, label: l.name };
|
abbForm.target = { value: l.id, label: l.name }
|
||||||
});
|
})
|
||||||
console.log('fokusera på input och mata med medhavd data');
|
console.log("fokusera på input och mata med medhavd data")
|
||||||
const el = document.getElementById('shortformEl');
|
const el = document.getElementById("shortformEl")
|
||||||
if (el) {
|
el.focus()
|
||||||
setTimeout(() => {
|
|
||||||
el.focus();
|
|
||||||
}, 15);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card.Root class="mx-auto w-[490px]">
|
<Card.Root class="mx-auto w-[490px]">
|
||||||
@ -103,22 +99,10 @@
|
|||||||
<Card.Description></Card.Description>
|
<Card.Description></Card.Description>
|
||||||
</Card.Header>
|
</Card.Header>
|
||||||
<Card.Content class="mx-auto">
|
<Card.Content class="mx-auto">
|
||||||
<form
|
<form class="grid gap-4 py-4" method="post" enctype="multipart/form-data" on:submit={handleCreate} autocomplete="off">
|
||||||
class="grid gap-4 py-4"
|
|
||||||
method="post"
|
|
||||||
enctype="multipart/form-data"
|
|
||||||
on:submit={handleCreate}
|
|
||||||
autocomplete="off"
|
|
||||||
>
|
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label>Förkortning</Label>
|
<Label>Förkortning</Label>
|
||||||
<Input
|
<Input id="shortformEl" bind:value={abbForm.shortform} focus placeholder="" class="w-[290px]" />
|
||||||
id="shortformEl"
|
|
||||||
bind:value={abbForm.shortform}
|
|
||||||
focus
|
|
||||||
placeholder=""
|
|
||||||
class="w-[290px]"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label>Text</Label>
|
<Label>Text</Label>
|
||||||
@ -126,29 +110,32 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label>Mål</Label>
|
<Label>Mål</Label>
|
||||||
<Select.Root selected={abbForm.target} {onSelectedChange}>
|
<Select.Root selected={abbForm.target} onSelectedChange={onSelectedChange}>
|
||||||
<Select.Trigger class="w-[290px]">
|
<Select.Trigger class="w-[290px]">
|
||||||
<Select.Value placeholder="Ingen lista vald" />
|
<Select.Value placeholder="Ingen lista vald" />
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
|
|
||||||
<Select.Content>
|
<Select.Content>
|
||||||
{#each selectedLists as list}
|
{#each selectedLists as list}
|
||||||
<Select.Item value={list.id} label={list.name}>{list.name}</Select.Item>
|
<Select.Item
|
||||||
{/each}
|
value={list.id}
|
||||||
|
label={list.name}
|
||||||
|
>{list.name}</Select.Item>
|
||||||
|
{/each}
|
||||||
</Select.Content>
|
</Select.Content>
|
||||||
</Select.Root>
|
</Select.Root>
|
||||||
</div>
|
</div>
|
||||||
{#if abbForm.errors.length > 0}
|
{#if abbForm.errors.length > 0}
|
||||||
<ScrollArea class="max-h-48 rounded-md">
|
<ScrollArea class="max-h-48 rounded-md">
|
||||||
<div class="border-l-4 border-orange-500 bg-orange-100 p-4 text-orange-700" role="alert">
|
<div class="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4" role="alert">
|
||||||
<p class="font-bold">Fel vid import</p>
|
<p class="font-bold">Fel vid import</p>
|
||||||
<ul class="p-6">
|
<ul class="p-6">
|
||||||
{#each abbForms.errors as error}
|
{#each abbForms.errors as error}
|
||||||
<li class="list-disc">{error}</li>
|
<li class="list-disc">{error}</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
{/if}
|
{/if}
|
||||||
<button type="submit" class="hidden" />
|
<button type="submit" class="hidden" />
|
||||||
</form>
|
</form>
|
||||||
@ -160,3 +147,4 @@
|
|||||||
</Card.Footer>
|
</Card.Footer>
|
||||||
-->
|
-->
|
||||||
</Card.Root>
|
</Card.Root>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
$: form = {
|
$: form = {
|
||||||
textarea: '',
|
textarea: '',
|
||||||
name: '',
|
name: '',
|
||||||
type: true
|
type: false
|
||||||
};
|
};
|
||||||
let importing = false;
|
let importing = false;
|
||||||
let progress = 0;
|
let progress = 0;
|
||||||
@ -92,7 +92,7 @@ förkn=förkortningen
|
|||||||
<Input bind:value={form.name} placeholder="Döp förkortningslistan" class="w-[290px]" />
|
<Input bind:value={form.name} placeholder="Döp förkortningslistan" class="w-[290px]" />
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label>Skapa ämneslista</Label>
|
<Label>Prioritera lista</Label>
|
||||||
<Switch bind:checked={form.type} />
|
<Switch bind:checked={form.type} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
|
|
||||||
import * as Card from '$lib/components/ui/card/index';
|
|
||||||
import * as Select from '$lib/components/ui/select';
|
|
||||||
import { Label } from '$lib/components/ui/label';
|
|
||||||
import { db } from '../db/main';
|
|
||||||
import { liveQuery } from 'dexie';
|
|
||||||
import { shortforms } from '$lib/stores.svelte';
|
|
||||||
import { cacheShortforms } from '../modules/shortforms';
|
|
||||||
|
|
||||||
const onSelectedStandardListChange = (e) => {
|
|
||||||
console.log('onSelectedStandardListChange', e);
|
|
||||||
shortforms.standardList = e.value;
|
|
||||||
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSelectedSubjectListChange = (e) => {
|
|
||||||
if (e.value == 0) {
|
|
||||||
listSelectorForm.subject = { value: '', label: '' };
|
|
||||||
shortforms.subjectList = '';
|
|
||||||
cacheShortforms([Number(shortforms.standardList)]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log('onSelectedSubjectListChange', e);
|
|
||||||
shortforms.subjectList = e.value;
|
|
||||||
cacheShortforms([Number(shortforms.standardList), Number(shortforms.subjectList)]);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSubmit = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
console.log('submit', listSelectorForm);
|
|
||||||
};
|
|
||||||
|
|
||||||
$: listSelectorForm = {
|
|
||||||
standard: { value: '', label: '' },
|
|
||||||
subject: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getListFromId = (lists, id) => {
|
|
||||||
return lists.filter((l) => l.id == id)[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
let standardLists = [];
|
|
||||||
let subjectLists = [];
|
|
||||||
onMount(() => {
|
|
||||||
//console.log($state.snapshot(shortforms));
|
|
||||||
db.lists.toArray().then((lists) => {
|
|
||||||
standardLists = lists.filter((l) => l.type == 0);
|
|
||||||
subjectLists = lists.filter((l) => l.type == 1);
|
|
||||||
const standard = getListFromId(standardLists, shortforms.standardList);
|
|
||||||
listSelectorForm.standard = { value: standard.id, label: standard.name };
|
|
||||||
const subject = getListFromId(subjectLists, shortforms.subjectList);
|
|
||||||
listSelectorForm.subject = { value: subject.id, label: subject.name };
|
|
||||||
console.log(listSelectorForm);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Card.Root class="mx-auto w-[490px]">
|
|
||||||
<Card.Header>
|
|
||||||
<Card.Title>Välj förkortningslistor</Card.Title>
|
|
||||||
<Card.Description></Card.Description>
|
|
||||||
</Card.Header>
|
|
||||||
<Card.Content class="mx-auto">
|
|
||||||
<form
|
|
||||||
class="grid gap-4 py-4"
|
|
||||||
method="post"
|
|
||||||
enctype="multipart/form-data"
|
|
||||||
onsubmit={onSubmit}
|
|
||||||
autocomplete="off"
|
|
||||||
>
|
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
|
||||||
<Label>Standardlista</Label>
|
|
||||||
<Select.Root
|
|
||||||
selected={listSelectorForm.standard}
|
|
||||||
onSelectedChange={onSelectedStandardListChange}
|
|
||||||
>
|
|
||||||
<Select.Trigger class="w-[290px]">
|
|
||||||
<Select.Value placeholder="Ingen lista vald" />
|
|
||||||
</Select.Trigger>
|
|
||||||
|
|
||||||
<Select.Content>
|
|
||||||
{#each standardLists as list}
|
|
||||||
<Select.Item value={list.id} label={list.name}>{list.name}</Select.Item>
|
|
||||||
{/each}
|
|
||||||
</Select.Content>
|
|
||||||
</Select.Root>
|
|
||||||
</div>
|
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
|
||||||
<Label>Ämneslista</Label>
|
|
||||||
<Select.Root
|
|
||||||
selected={listSelectorForm.subject}
|
|
||||||
onSelectedChange={onSelectedSubjectListChange}
|
|
||||||
disabled={subjectLists.length < 1}
|
|
||||||
>
|
|
||||||
<Select.Trigger class="w-[290px]">
|
|
||||||
<Select.Value placeholder="Ingen lista vald" />
|
|
||||||
</Select.Trigger>
|
|
||||||
|
|
||||||
<Select.Content>
|
|
||||||
<Select.Item value={0} label="Ingen lista vald">Ingen lista vald</Select.Item>
|
|
||||||
{#each subjectLists as list}
|
|
||||||
<Select.Item value={list.id} label={list.name}>{list.name}</Select.Item>
|
|
||||||
{/each}
|
|
||||||
</Select.Content>
|
|
||||||
</Select.Root>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="hidden" />
|
|
||||||
</form>
|
|
||||||
</Card.Content>
|
|
||||||
<!--
|
|
||||||
<Card.Footer class="flex justify-between">
|
|
||||||
<Button on:click={cancelCreate} variant="outline">Avbryt</Button>
|
|
||||||
<Button on:click={handleCreate}>Importera</Button>
|
|
||||||
</Card.Footer>
|
|
||||||
-->
|
|
||||||
</Card.Root>
|
|
@ -1,101 +1,79 @@
|
|||||||
<script>
|
<script>
|
||||||
import { appState } from '$lib/stores.svelte';
|
import { appState } from "$lib/stores.svelte"
|
||||||
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index';
|
import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index";
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import Gear from 'svelte-radix/Gear.svelte';
|
import Gear from "svelte-radix/Gear.svelte";
|
||||||
|
|
||||||
let closeFocus = 'textarea#doc.textarea';
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DropdownMenu.Root
|
<DropdownMenu.Root open={appState.menuOpen} onOpenChange={(v) => {appState.menuOpen = v}} closeFocus="textarea#doc.textarea">
|
||||||
open={appState.menuOpen}
|
<DropdownMenu.Trigger asChild let:builder>
|
||||||
onOpenChange={(v) => {
|
<Button builders={[builder]} variant="ghost" class="absolute top-2 right-2" size="icon">
|
||||||
appState.menuOpen = v;
|
<Gear class="h-4 w-4" />
|
||||||
}}
|
</Button>
|
||||||
{closeFocus}
|
</DropdownMenu.Trigger>
|
||||||
>
|
<DropdownMenu.Content class="w-56">
|
||||||
<DropdownMenu.Trigger asChild let:builder>
|
<DropdownMenu.Label>Inställningar</DropdownMenu.Label>
|
||||||
<Button builders={[builder]} variant="ghost" class="absolute right-2 top-2" size="icon">
|
<DropdownMenu.Separator />
|
||||||
<Gear class="h-4 w-4" />
|
<DropdownMenu.Group>
|
||||||
</Button>
|
<DropdownMenu.Item on:click={() => {appState.open="create"}}>
|
||||||
</DropdownMenu.Trigger>
|
Lägg till förkortning
|
||||||
<DropdownMenu.Content class="w-56">
|
<DropdownMenu.Shortcut>F2</DropdownMenu.Shortcut>
|
||||||
<DropdownMenu.Label>Inställningar</DropdownMenu.Label>
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.Separator />
|
<DropdownMenu.Item>
|
||||||
<DropdownMenu.Group>
|
Statistik
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
on:click={() => {
|
</DropdownMenu.Item>
|
||||||
appState.open = 'create';
|
</DropdownMenu.Group>
|
||||||
}}
|
<DropdownMenu.Separator />
|
||||||
>
|
<DropdownMenu.Group>
|
||||||
Lägg till förkortning
|
<DropdownMenu.Item>
|
||||||
<DropdownMenu.Shortcut>F2</DropdownMenu.Shortcut>
|
Förkortningar
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
<DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
Statistik
|
<DropdownMenu.Item>
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
Förinskriven text
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
</DropdownMenu.Group>
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.Separator />
|
<DropdownMenu.Item>
|
||||||
<DropdownMenu.Group>
|
Textinställningar
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
on:click={() => {
|
</DropdownMenu.Item>
|
||||||
appState.open = 'selectLists';
|
<DropdownMenu.Item>
|
||||||
}}
|
Tangentbord
|
||||||
>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
Välj listor
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
</DropdownMenu.Group>
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.Separator />
|
||||||
<DropdownMenu.Item>
|
<DropdownMenu.Group>
|
||||||
Förkortningar
|
<DropdownMenu.Sub>
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
<DropdownMenu.SubTrigger>Anslut</DropdownMenu.SubTrigger>
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.SubContent>
|
||||||
<DropdownMenu.Item>
|
<DropdownMenu.Item>
|
||||||
Förinskriven text
|
Distanstolkning
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.Item>
|
<DropdownMenu.Item>
|
||||||
Textinställningar
|
Lokalt nätverk
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.Item>
|
</DropdownMenu.SubContent>
|
||||||
Tangentbord
|
</DropdownMenu.Sub>
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
</DropdownMenu.Group>
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.Separator />
|
||||||
</DropdownMenu.Group>
|
<DropdownMenu.Item>
|
||||||
<DropdownMenu.Separator />
|
Hjälp
|
||||||
<DropdownMenu.Group>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
<DropdownMenu.Sub>
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.SubTrigger>Anslut</DropdownMenu.SubTrigger>
|
<DropdownMenu.Item>Feedback
|
||||||
<DropdownMenu.SubContent>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
<DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
Distanstolkning
|
<DropdownMenu.Item>Användarkonto
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
<DropdownMenu.Item>
|
<DropdownMenu.Separator />
|
||||||
Lokalt nätverk
|
<DropdownMenu.Item>
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
Logga ut
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.Shortcut>⇧⌘Q</DropdownMenu.Shortcut>
|
||||||
</DropdownMenu.SubContent>
|
</DropdownMenu.Item>
|
||||||
</DropdownMenu.Sub>
|
</DropdownMenu.Content>
|
||||||
</DropdownMenu.Group>
|
|
||||||
<DropdownMenu.Separator />
|
|
||||||
<DropdownMenu.Item>
|
|
||||||
Hjälp
|
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
<DropdownMenu.Item
|
|
||||||
>Feedback
|
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
<DropdownMenu.Item
|
|
||||||
>Användarkonto
|
|
||||||
<DropdownMenu.Shortcut>F12</DropdownMenu.Shortcut>
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
<DropdownMenu.Separator />
|
|
||||||
<DropdownMenu.Item>
|
|
||||||
Logga ut
|
|
||||||
<DropdownMenu.Shortcut>⇧⌘Q</DropdownMenu.Shortcut>
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
</DropdownMenu.Content>
|
|
||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
|
@ -5,34 +5,34 @@ const colorSetting = {
|
|||||||
|
|
||||||
const colorThemes = [
|
const colorThemes = [
|
||||||
{
|
{
|
||||||
bg: "white",
|
bg: "white",
|
||||||
fg: "black",
|
fg: "black",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bg: "black",
|
bg: "black",
|
||||||
fg: "white",
|
fg: "white",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bg: "black",
|
bg: "black",
|
||||||
fg: "yellow",
|
fg: "yellow",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bg: "yellow",
|
bg: "yellow",
|
||||||
fg: "black",
|
fg: "black",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bg: "blue",
|
bg: "blue",
|
||||||
fg: "yellow",
|
fg: "yellow",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bg: "yellow",
|
bg: "yellow",
|
||||||
fg: "blue",
|
fg: "blue",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
let selectedColor = 0;
|
let selectedColor = 0;
|
||||||
|
|
||||||
export const shortforms = $state({ standardList: "", subjectList: "", cache: new Map() })
|
export const shortforms = $state({ standardList: "", subjectLists: [], cache: new Map() })
|
||||||
export const importState = $state({ data: "", errors: [] })
|
export const importState = $state({ data: "", errors: [] })
|
||||||
export const textSettings = $state({ font: "Arial", size: 30, colors: colorSetting, padding: 0, lineheight: 1 })
|
export const textSettings = $state({ font: "Arial", size: 30, colors: colorSetting, padding: 0, lineheight: 1 })
|
||||||
export const appState = $state({ text: "", menuOpen: false, open: "" })
|
export const appState = $state({ text: "", menuOpen: false, open: "" })
|
||||||
@ -58,15 +58,10 @@ export const selectNextColor = () => {
|
|||||||
textSettings.colors = colorThemes[(selectedColor % 6)]
|
textSettings.colors = colorThemes[(selectedColor % 6)]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const toggleMenuOpen = (force = undefined) => {
|
export const toggleMenuOpen = () => {
|
||||||
if (force == undefined) {
|
appState.menuOpen = !appState.menuOpen
|
||||||
appState.menuOpen = !appState.menuOpen
|
|
||||||
} else {
|
|
||||||
appState.menuOpen = force
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const incTextSize = () => {
|
export const incTextSize = () => {
|
||||||
console.log(textSettings.size)
|
console.log(textSettings.size)
|
||||||
if (textSettings.size < 200) {
|
if (textSettings.size < 200) {
|
||||||
|
@ -9,7 +9,7 @@ export const defaultExpanders: Map<string, ExpanderType> = new Map();
|
|||||||
export const hotkeys: Map<string, any> = new Map();
|
export const hotkeys: Map<string, any> = new Map();
|
||||||
|
|
||||||
defaultExpanders.set("\n", {
|
defaultExpanders.set("\n", {
|
||||||
key: { keyCode: 188, shiftKey: false },
|
key: { keyCode: 13, shiftKey: false },
|
||||||
symbol: "\n",
|
symbol: "\n",
|
||||||
fullstop: true,
|
fullstop: true,
|
||||||
});
|
});
|
||||||
@ -136,7 +136,6 @@ hotkeys.set("F8", {
|
|||||||
hotkeys.set("F2", {
|
hotkeys.set("F2", {
|
||||||
action: (e) => {
|
action: (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
toggleMenuOpen(false)
|
|
||||||
appState.open = "create"
|
appState.open = "create"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -49,8 +49,6 @@ export function cacheShortforms(lists: Array<number> = []) {
|
|||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
shortforms.cache = cache
|
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
export function expandShortform(
|
export function expandShortform(
|
||||||
|
@ -2,59 +2,50 @@
|
|||||||
import Textarea from '../components/textarea.svelte';
|
import Textarea from '../components/textarea.svelte';
|
||||||
import Import from '../components/import/import.svelte';
|
import Import from '../components/import/import.svelte';
|
||||||
import Create from '../components/create.svelte';
|
import Create from '../components/create.svelte';
|
||||||
import ListSelector from '../components/listselector.svelte';
|
|
||||||
import Dashboard from '../components/dashboard.svelte';
|
import Dashboard from '../components/dashboard.svelte';
|
||||||
import { db, deleteShortformList, type Shortform } from '../db/main';
|
import { db, deleteShortformList, type Shortform } from '../db/main';
|
||||||
import Menu from '../components/menu.svelte';
|
import Menu from "../components/menu.svelte";
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { appState } from '$lib/stores.svelte';
|
import { appState } from '$lib/stores.svelte'
|
||||||
let loaded = false;
|
let loaded = false
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
appState.open;
|
appState.open
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
if (appState.open == '') {
|
if (appState.open == "") {
|
||||||
textarea.focus();
|
textarea.focus()
|
||||||
}
|
}
|
||||||
if (appState.open == 'dashboard') {
|
if (appState.open == "dashboard") {
|
||||||
console.log('should open dashboard');
|
console.log("should open dashboard")
|
||||||
showDashboard = true;
|
showDashboard = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loaded = true;
|
loaded = true
|
||||||
});
|
|
||||||
|
})
|
||||||
import { hotkeys } from '../modules/keyboard';
|
import { hotkeys } from '../modules/keyboard';
|
||||||
let showDashboard: boolean = true;
|
let showDashboard: boolean = true;
|
||||||
import { Toaster } from '$lib/components/ui/sonner';
|
import { Toaster } from "$lib/components/ui/sonner";
|
||||||
const handleHotkeys = (e: KeyboardEvent) => {
|
const handleHotkeys = (e: KeyboardEvent) => {
|
||||||
hotkeys.get(e.key)?.action(e);
|
hotkeys.get(e.key)?.action(e);
|
||||||
};
|
};
|
||||||
let textarea = null;
|
let textarea = null
|
||||||
</script>
|
|
||||||
|
|
||||||
|
</script>
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>SKRIVERT</title>
|
<title>SKRIVERT</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
<svelte:window on:keydown={handleHotkeys} />
|
<svelte:window on:keydown={handleHotkeys} />
|
||||||
|
|
||||||
<div class="h-dvh w-full overflow-hidden" role="application">
|
<div class="h-dvh w-full overflow-hidden" role="application">
|
||||||
{#if appState.open == 'create'}
|
{#if appState.open == "create"}
|
||||||
<div
|
<div class="fixed flex top-0 right-0 left-0 z-50 justify-center items-center align-middle w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||||
class="fixed left-0 right-0 top-0 z-50 flex h-[calc(100%-1rem)] max-h-full w-full items-center justify-center align-middle md:inset-0"
|
|
||||||
>
|
|
||||||
<Create />
|
<Create />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if appState.open == 'selectLists'}
|
|
||||||
<div
|
|
||||||
class="fixed left-0 right-0 top-0 z-50 flex h-[calc(100%-1rem)] max-h-full w-full items-center justify-center align-middle md:inset-0"
|
|
||||||
>
|
|
||||||
<ListSelector />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
<div class="h-full">
|
<div class="h-full">
|
||||||
<Menu />
|
<Menu />
|
||||||
<Textarea bind:ref={textarea} />
|
<Textarea bind:ref={textarea} />
|
||||||
<!-- <Button variant="destructive" on:click={deleteDefaultShortforms}>Ta bort standardlista</Button>-->
|
<!-- <Button variant="destructive" on:click={deleteDefaultShortforms}>Ta bort standardlista</Button>-->
|
||||||
<!-- <Dashboard open={showDashboard} />-->
|
<!-- <Dashboard open={showDashboard} />-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user