diaryx.org / projects /

leaf

Rust · Swift MIT / Apache-2.0

A caret-based rich-text editor that edits the document's AST.

leaf gives you an ordinary text caret — mouse, selection, a formatting toolbar — and turns every keystroke into an offset-addressed edit on twig's tree. The document stays a live, round-trippable AST the whole time you type into it, so a Markdown file and a Djot file are edited through exactly the same operations.

  • Two views, one rendering path. Source (caret in raw bytes) and WYSIWYG (**bold** painted bold, delimiters hidden) — every rendered glyph maps back to its source byte, so carets and clicks ride the visible text in either.
  • One core, many frontends. A frontend-neutral core; embeddable widgets for ratatui, gpui, AppKit/UIKit (via UniFFI), and the browser (via wasm).
  • Thin hosts everywhere. A terminal editor, a GUI app, an iOS host, and a web demo are all thin wrappers around the same widget.

Where it fits

leaf is the editor underneath Diaryx's writing surface — the same core that renders an entry on Mac renders it on iPhone. It edits documents through twig's tree. Standalone, it's embeddable anywhere a rich-text view over plain files belongs.

Status

Work in progress, and open about it: caret editing, mouse, selection, and both views work today; soft-wrap edge cases, inline images, and undo/redo are the known next steps.