Using Typst.ts in the browser #511
-
Hello! I have a use case and I want to confirm whether this library can achieve the functionality required since I wasn't able to determine that from the docs. I want to embed a typst editor inside a web app that I'm building and I want it to be able to compile typst text and render it entirely client side in the browser. From my current understanding of the docs, you can compile and render typst text in the browser but you need to supply the compiler with a Note: Im also happy to contribute to the library and docs if changes are required. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Making an editor with preview is not easy, as you have to load and maintain fonts, files, and state of the compiler and renderers. And I will tell you three different ways to have and improve one with typst.ts, with each increasing difficulty to implement. You need to bind a input element and then keep rendering a SVG element with snippets API. The sample loads fonts from GitHub and start serving preview with input:
Minimal: Online Demo and Source Code There is an incremental rendering API (
Typst Preview: Extension and Repository There is also an incremental compiling API which further improves better performance, but I admit it is not ready for use. If you would like to go deeper, we can discuss a nice and stable incremental compiling API.
Underleaf: Online Demo and Source Code |
Beta Was this translation helpful? Give feedback.
Making an editor with preview is not easy, as you have to load and maintain fonts, files, and state of the compiler and renderers. And I will tell you three different ways to have and improve one with typst.ts, with each increasing difficulty to implement.
You need to bind a input element and then keep rendering a SVG element with snippets API. The sample loads fonts from GitHub and start serving preview with input:
RenderSession
for ease of use.Minimal: Online Demo and Source Code
There is an incremental rendering API (
RenderSession
) but the documents are in source code so you may not find and learn tha…