Skip to content

Import and Export (User)

@lyfie/luthor-headless now uses a JSON/JSONB-first import/export model.

Store canonical editor state as JSON (or JSONB in PostgreSQL):

  • Canonical: Lexical JSON for exact fidelity
  • Persistence: JSONB payloads for reversible edits and reliable restores

The editor runtime context exposes:

  • export.toJSON()
  • import.fromJSON(value)

These APIs are lossless for supported nodes and extension state.

  • Treat JSON/JSONB as the only source of truth.
  • Validate untrusted JSON before calling fromJSON.
  • Keep schema version metadata in your persistence envelope if your app evolves custom nodes over time.
{
"schemaVersion": 1,
"preset": "extensive",
"savedAt": "2026-02-20T00:00:00.000Z",
"content": {
"jsonb": "{ ...lexical state... }"
}
}