Installation#
Install the following dependencies:
Copy and paste the following code into your project.
Add the --shiki-* CSS variables to your global CSS (same as Code Snippet).
Update the import paths to match your project setup.
Usage#
Numscript Language#
The code editor ships with a custom TextMate grammar for Numscript — Formance's DSL for describing financial transactions. Set language="numscript" to enable syntax highlighting for keywords (send, source, destination), monetary literals ([USD/2 100]), account addresses (@world), variables ($amount), and more.
The grammar file is bundled with the code-themes dependency and registered automatically when the editor initializes.
Numscript Validator#
The numscript-validator companion package validates Numscript code against the Numscript playground API and surfaces errors as inline diagnostics in the editor.
The createNumscriptValidator accepts an optional context with balances, variables, and metadata to validate against — the same inputs the Numscript playground uses.
Validator Demo#
The example below starts with a syntax error (sendd instead of send). The error marker appears inline after a 500ms debounce. Fix the typo to see it clear.
Navigator#
The withNavigator prop adds a breadcrumb toolbar above the editor that parses JSON or YAML content into a navigation tree. Users can drill into nested sections and jump to the corresponding line in the editor.