canvist_desktop
The canvist rich-text editor for macOS, Windows, and Linux: a native component for any winit app, painted with vello and laid out by the same engine as canvist’s server-side renderer, so a document wraps identically in the window, in a PNG, and in HTML.
- Typing like a text view: key bindings with Cmd on macOS and Ctrl elsewhere, input rules (
##makes a heading), undo grouped by typing bursts, and paging. - Input methods: preedit text is underlined in place, and the candidate window sits under it.
- Clipboard: copy and cut write HTML and plain text; paste prefers HTML, so formatting survives other apps.
- Mouse and trackpad: click, double-click for a word, triple-click for a block, Shift-click and drag to extend, and autoscroll past the edges.
- Scrolling and high-DPI, with only the visible blocks laid out and painted.
- Accessibility: an AccessKit tree of text runs with character positions, so screen readers read, navigate, and select text.
- Fonts: the system’s own, plus any loaded from bytes with
register_font. - Typed commands: handles from the engine’s extensions, so an unregistered extension’s commands don’t compile.
- Collaboration (
collabfeature): join a y-websocket or Hocuspocus room and edit live.
use canvist_desktop::DesktopEditor;
use canvist_desktop::EditorOptions;
use canvist_desktop::winit::winit::window::Window;
use canvist_headless::Engine;
use canvist_headless::Format;
let mut editor = DesktopEditor::new(Engine::starter_kit(), EditorOptions::new().max_width(720.0))?;
editor.load(Format::Markdown, "# Hello\n\nStart typing.")?;
canvist_desktop::winit::run(editor, Window::default_attributes().with_title("Notes"))?;
# Ok::<(), canvist_desktop::DesktopError>(())To put the editor in your own app beside a toolbar, use winit::EditorWindow: see the quick start. Without the default winit feature, the crate is the headless editor core: it takes input as InputEvents, lays out, renders PNGs, and builds the accessibility tree, which is how its tests drive it.
A keystroke’s whole frame (the edit, layout, display list, and GPU scene encoding) takes about 0.14 ms in a 10,000-paragraph document on an Apple silicon Mac. The performance budgets hold it under 4 ms.