feat: add bold/italic shortcuts and toolbar buttons for Typst editor
Build and Deploy Verso / deploy (push) Successful in 14m39s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
claude
2026-06-11 08:28:47 +00:00
co-authored by Claude Sonnet 4.6
parent 4899afd45f
commit 31db7b2b4e
5 changed files with 72 additions and 1 deletions
@@ -10,6 +10,7 @@ import { styleTags, tags as t } from '@lezer/highlight'
import { parser } from '../../lezer-typst/typst.mjs'
import { typstCompletions } from './complete'
import { typstDocumentOutline } from './document-outline'
import { shortcuts } from './shortcuts'
// Note on tree structure: rules starting with a lowercase letter in the grammar
// are inline (no tree node), so their children are promoted to the parent.
@@ -111,5 +112,6 @@ export const typst = () => {
TypstLanguage.data.of({ autocomplete: typstCompletions }),
typstDocumentOutline,
syntaxHighlighting(typstHighlightStyle),
shortcuts(),
])
}
@@ -0,0 +1,22 @@
import { Prec } from '@codemirror/state'
import { keymap } from '@codemirror/view'
import { wrapRanges } from '../../commands/ranges'
export const shortcuts = () => {
return Prec.high(
keymap.of([
{
key: 'Ctrl-b',
mac: 'Mod-b',
preventDefault: true,
run: wrapRanges('*', '*'),
},
{
key: 'Ctrl-i',
mac: 'Mod-i',
preventDefault: true,
run: wrapRanges('_', '_'),
},
])
)
}