|
|
@@ -0,0 +1,116 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { Block } from "@enesis/editor"
|
|
|
+import { ref } from "vue"
|
|
|
+
|
|
|
+const inlineMath = ref(`This has inline math: $x^2 + y^2 = z^2$ inside a paragraph.
|
|
|
+
|
|
|
+You can also do $\\sum_{i=1}^n i = \\frac{n(n+1)}{2}$ for summations.
|
|
|
+
|
|
|
+And $\\alpha\\beta\\gamma$ for Greek letters.
|
|
|
+
|
|
|
+A bare $5 should not render as math. Neither should $ this$.`)
|
|
|
+
|
|
|
+const blockMath = ref(`Here is some block math:
|
|
|
+
|
|
|
+$$
|
|
|
+\\int_{-\\infty}^{\\infty} e^{-x^2} \\, dx = \\sqrt{\\pi}
|
|
|
+$$
|
|
|
+
|
|
|
+And another one:
|
|
|
+
|
|
|
+$$
|
|
|
+\\begin{bmatrix}
|
|
|
+a & b \\\\
|
|
|
+c & d
|
|
|
+\\end{bmatrix}
|
|
|
+$$`)
|
|
|
+
|
|
|
+const mixed = ref(`# Math Test Document
|
|
|
+
|
|
|
+You can mix **bold** and $x$ math inline.
|
|
|
+
|
|
|
+> [!NOTE] Math in callouts works: $E = mc^2$
|
|
|
+
|
|
|
+[[Page Ref]] with $\\theta$ math.
|
|
|
+
|
|
|
+TODO Test task with math: $\\Delta$ [#A]
|
|
|
+
|
|
|
+$$
|
|
|
+f(x) = \\begin{cases}
|
|
|
+x^2 & \\text{if } x > 0 \\\\
|
|
|
+0 & \\text{otherwise}
|
|
|
+\\end{cases}
|
|
|
+$$
|
|
|
+
|
|
|
+property:: math expression $\\lambda$ test`)
|
|
|
+
|
|
|
+function log(event: string, payload?: unknown) {
|
|
|
+ console.log(`[Block] ${event}`, payload)
|
|
|
+
|
|
|
+ if (event === "blur") {
|
|
|
+ console.log("Content:", inlineMath.value, blockMath.value, mixed.value)
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="p-8 max-w-2xl mx-auto space-y-6">
|
|
|
+ <h1 class="text-2xl font-bold">Math Feature Tests</h1>
|
|
|
+
|
|
|
+ <section class="rounded-lg border border-(--ui-border) p-4 space-y-2">
|
|
|
+ <h2 class="text-lg font-semibold">Inline Math</h2>
|
|
|
+ <p class="text-sm text-(--ui-text-muted)">
|
|
|
+ Type <code class="text-xs">$...$</code> for inline math. Use
|
|
|
+ <kbd class="px-1.5 py-0.5 rounded bg-(--ui-bg-elevated) border border-(--ui-border) text-xs">Mod+M</kbd>
|
|
|
+ to toggle inline math on selection.
|
|
|
+ </p>
|
|
|
+ <Block
|
|
|
+ v-model:content="inlineMath"
|
|
|
+ :focused="true"
|
|
|
+ cursor-position="end"
|
|
|
+ marker-mode="always-visible"
|
|
|
+ @change="log('change', $event)"
|
|
|
+ @focus="log('focus', $event)"
|
|
|
+ @blur="log('blur')"
|
|
|
+ @selection-change="log('selection-change', $event)"
|
|
|
+ />
|
|
|
+ </section>
|
|
|
+
|
|
|
+ <section class="rounded-lg border border-(--ui-border) p-4 space-y-2">
|
|
|
+ <h2 class="text-lg font-semibold">Block Math</h2>
|
|
|
+ <p class="text-sm text-(--ui-text-muted)">
|
|
|
+ Type <code class="text-xs">$$</code> at the start of an empty paragraph for a
|
|
|
+ display math block. Use
|
|
|
+ <kbd class="px-1.5 py-0.5 rounded bg-(--ui-bg-elevated) border border-(--ui-border) text-xs">Mod+Shift+M</kbd>
|
|
|
+ to insert one.
|
|
|
+ </p>
|
|
|
+ <Block
|
|
|
+ v-model:content="blockMath"
|
|
|
+ :focused="true"
|
|
|
+ cursor-position="end"
|
|
|
+ marker-mode="always-visible"
|
|
|
+ @change="log('change', $event)"
|
|
|
+ @focus="log('focus', $event)"
|
|
|
+ @blur="log('blur')"
|
|
|
+ @selection-change="log('selection-change', $event)"
|
|
|
+ />
|
|
|
+ </section>
|
|
|
+
|
|
|
+ <section class="rounded-lg border border-(--ui-border) p-4 space-y-2">
|
|
|
+ <h2 class="text-lg font-semibold">Mixed Syntax</h2>
|
|
|
+ <p class="text-sm text-(--ui-text-muted)">
|
|
|
+ Math combined with headings, bold, callouts, page refs, tasks, and properties.
|
|
|
+ </p>
|
|
|
+ <Block
|
|
|
+ v-model:content="mixed"
|
|
|
+ :focused="true"
|
|
|
+ cursor-position="end"
|
|
|
+ marker-mode="always-visible"
|
|
|
+ @change="log('change', $event)"
|
|
|
+ @focus="log('focus', $event)"
|
|
|
+ @blur="log('blur')"
|
|
|
+ @selection-change="log('selection-change', $event)"
|
|
|
+ />
|
|
|
+ </section>
|
|
|
+ </div>
|
|
|
+</template>
|