global state: textdata, font och storlek
This commit is contained in:
parent
c59afe3893
commit
54329592fa
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { shortforms } from '$lib/stores.svelte';
|
import { appState, shortforms, textSettings } from '$lib/stores.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
import * as Select from "$lib/components/ui/select/index.js";
|
import * as Select from "$lib/components/ui/select/index.js";
|
||||||
|
|
||||||
let styles = {
|
$: styles = {
|
||||||
"text-bg": "#333333",
|
"text-bg": "#333333",
|
||||||
"text-fg": "#baff00",
|
"text-fg": "#baff00",
|
||||||
|
"text-font": textSettings.font,
|
||||||
|
"text-size": textSettings.size + "px",
|
||||||
}
|
}
|
||||||
|
|
||||||
$: cssVarStyles = Object.entries(styles)
|
$: cssVarStyles = Object.entries(styles)
|
||||||
@ -34,7 +36,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
let textarea: HTMLTextAreaElement;
|
let textarea: HTMLTextAreaElement;
|
||||||
let text = '';
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
shortforms.cache = cacheShortforms([890324]);
|
shortforms.cache = cacheShortforms([890324]);
|
||||||
@ -97,8 +98,17 @@
|
|||||||
*/
|
*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="docContainer h-full flex flex-col" role="application" id="docContainer">
|
<div class="docContainer h-95 flex flex-col" role="application" id="docContainer">
|
||||||
<textarea style={cssVarStyles} class="textarea flex-grow" id="doc" on:keyup={change} on:beforeinput={input} bind:value={text}></textarea>
|
<textarea style="
|
||||||
|
font-size:{textSettings.size}px;
|
||||||
|
font-family:{textSettings.font};
|
||||||
|
"
|
||||||
|
class="textarea flex-grow"
|
||||||
|
id="doc"
|
||||||
|
on:keyup={change}
|
||||||
|
on:beforeinput={input}
|
||||||
|
bind:value={appState.text}
|
||||||
|
></textarea>
|
||||||
<Select.Root
|
<Select.Root
|
||||||
selected={selectedStandardList}
|
selected={selectedStandardList}
|
||||||
onSelectedChange={selectedStandardListChanged}
|
onSelectedChange={selectedStandardListChanged}
|
||||||
@ -121,14 +131,17 @@
|
|||||||
.docContainer {
|
.docContainer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.docContainer textarea {
|
.docContainer textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.3em;
|
padding: 0.3em;
|
||||||
resize: none;
|
resize: none;
|
||||||
font-size: 2em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.textarea {
|
.textarea {
|
||||||
color: var(--text-fg, black);
|
color: var(--text-fg, black);
|
||||||
background-color: var(--text-bg, white);
|
background-color: var(--text-bg, white);
|
||||||
|
font-family: var(--text-font, "Arial");
|
||||||
|
font-size: var(--text-size, "20px");
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,2 +1,27 @@
|
|||||||
export const shortforms = $state({ standardList: "", subjectLists: [], 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, padding: 0, lineheight: 1 })
|
||||||
|
export const appState = $state({ text: "" })
|
||||||
|
|
||||||
|
export const incTextSize = () => {
|
||||||
|
console.log(textSettings.size)
|
||||||
|
if (textSettings.size < 200) {
|
||||||
|
textSettings.size += 5
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (textSettings.size > 200) {
|
||||||
|
textSettings.size = 200
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const decTextSize = () => {
|
||||||
|
if (textSettings.size > 15) {
|
||||||
|
textSettings.size -= 5
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (textSettings.size <= 15) {
|
||||||
|
textSettings.size = 15
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import type { ExpanderType } from "./index.d.ts";
|
import type { ExpanderType } from "./index.d.ts";
|
||||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
import { incTextSize, decTextSize, appState } from "$lib/stores.svelte"
|
||||||
|
|
||||||
let fullscreen = true;
|
let fullscreen = true;
|
||||||
export const defaultExpanders: Map<string, ExpanderType> = new Map();
|
export const defaultExpanders: Map<string, ExpanderType> = new Map();
|
||||||
@ -85,6 +86,29 @@ hotkeys.set("F1", {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
hotkeys.set("F4", {
|
||||||
|
action: (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
console.log("Clear text", appState.text)
|
||||||
|
appState.text = ""
|
||||||
|
}
|
||||||
|
})
|
||||||
|
hotkeys.set("F6", {
|
||||||
|
action: (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
console.log("Decrease text size")
|
||||||
|
decTextSize()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
hotkeys.set("F7", {
|
||||||
|
action: (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
console.log("Increase text size")
|
||||||
|
incTextSize()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
hotkeys.set("F11", {
|
hotkeys.set("F11", {
|
||||||
action: (e) => {
|
action: (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user