kripke: add math keys
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Katex from "$lib/components/katex.svelte";
|
||||||
import { type Formula, prettyPrint, tryParse } from "@cannorin/kripke";
|
import { type Formula, prettyPrint, tryParse } from "@cannorin/kripke";
|
||||||
import { formulaHistory } from "../lib/store";
|
import { formulaHistory } from "../lib/store";
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ let history = $derived(
|
|||||||
.slice(0, 10)
|
.slice(0, 10)
|
||||||
.map(([a, _ac]) => a),
|
.map(([a, _ac]) => a),
|
||||||
);
|
);
|
||||||
|
let inputElement: HTMLInputElement;
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const fml = tryParse(input);
|
const fml = tryParse(input);
|
||||||
@@ -39,11 +41,36 @@ $effect(() => {
|
|||||||
</datalist>
|
</datalist>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<input
|
{#snippet mathKey(latexCommand: string, actualText?: string)}
|
||||||
|
<button onclick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
input += actualText ?? latexCommand;
|
||||||
|
inputElement.focus();
|
||||||
|
}}>
|
||||||
|
<Katex math={latexCommand} />
|
||||||
|
</button>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
<div class="rounded border border-foreground w-full">
|
||||||
|
<div class="border-0 border-b border-muted px-2 py-1 flex justify-between">
|
||||||
|
{@render mathKey("\\top", "⊤")}
|
||||||
|
{@render mathKey("\\bot", "⊥")}
|
||||||
|
{@render mathKey("\\neg", "¬")}
|
||||||
|
{@render mathKey("\\Box", "□")}
|
||||||
|
{@render mathKey("\\Diamond", "◇")}
|
||||||
|
{@render mathKey("\\land", "∧")}
|
||||||
|
{@render mathKey("\\lor", "∨")}
|
||||||
|
{@render mathKey("\\to", "→")}
|
||||||
|
{@render mathKey("\\leftrightarrow", "↔")}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input
|
||||||
id="formula"
|
id="formula"
|
||||||
list="formula-history"
|
list="formula-history"
|
||||||
class={["rounded border border-foreground ring-0 focus:outline-none focus:ring-0 p-2 w-full", error && "border-primary"]}
|
class={["ring-0 rounded focus:outline-none p-2 focus:ring-0 w-full", error && "border-primary"]}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Enter modal formula"
|
placeholder="Enter modal formula"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
bind:value={input} />
|
bind:value={input}
|
||||||
|
bind:this={inputElement} />
|
||||||
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user