Search page titles, headings and text across the docs.

Rust crates

canvist_ffi

The canvist editor for iOS and Android. It exports an Editor through UniFFI to the Canvist Swift package and the canvist-android Kotlin library. It isn’t published on its own.

An Editor is the whole engine without a UI:

  • a canvist_headless document with the StarterKit’s commands, input rules, history, and key bindings;
  • its canvist_layout layout, with text measured by the platform (CoreTextMeasurer on iOS, PaintMeasurer on Android);
  • frames that hand the platform a display list to paint, and only what changed;
  • the text model UITextInput and InputConnection expect: the document as one UTF-16 string, with marked text for IME composition, geometry for carets, selection handles, and candidate windows, and lines and blocks for screen readers;
  • Yjs collaboration, through updates or the y-sync protocol.

Commands are typed: crates/canvist_ffi/tests/handles.rs generates Swift and Kotlin handles (kit.heading.toggleHeading(level: 2)) from the same metadata the Rust commands check their arguments against.

use std::sync::Arc;

use canvist_ffi::DocFormat;
use canvist_ffi::Editor;
use canvist_ffi::EditorOptions;
use canvist_ffi::testing::FixedPlatformMeasurer;

let editor = Editor::new(EditorOptions::starter_kit(), Arc::new(FixedPlatformMeasurer::default()))?;
editor.load(DocFormat::Markdown, "Hello")?;
editor.select(5, 5)?;
editor.insert_text(" world")?;
assert_eq!(editor.export(DocFormat::Markdown), "Hello world");
# Ok::<(), canvist_ffi::CanvistError>(())

Flutter and Dart don’t use this crate: they bind canvist_headless through flutter_rust_bridge. See the native toolchain guide for building and testing on iOS and Android.

Docs