Skip to main content
Mount the editor with client.mountEditor(el, options). el is an Element or a CSS selector string. It returns an EditorInstance for imperative control.
const editor = qirtaas.mountEditor("#editor", {
  documentId: "b1f2…",
  locale: "ar",
  theme: "light",
  onReady: () => console.log("ready"),
  onChange: (json) => save(json),
  onSaveStateChange: (state) => setBadge(state),
  onDocumentCreated: (id) => (currentDocId = id),
  onError: (code, detail) => report(code, detail),
  onTokenExpired: () => refreshSession(),
});

EditorMountOptions

documentId
string
Existing document id to load. Omit to lazy-create a document on the first content change — the new id arrives via onDocumentCreated.
initialContent
Json | null
Initial content (TipTap JSON) when not loading from a documentId — in-memory editing.
locale
"en" | "ar"
Editor UI and content language/direction.
theme
"light" | "dark"
Color theme. Can be changed live via setTheme.
readOnly
boolean
default:"false"
Start read-only. Editing can be toggled later via setEditable().
autofocus
boolean
autosave
AutosaveOptions
Autosave behavior. See Types. Set { enabled: false } to drive persistence yourself via save().

Callbacks

onReady
() => void
Fired once the editor is mounted and (if loading) the document is in.
onChange
(json: Json) => void
Fired on every content change with the current TipTap JSON.
onSaveStateChange
(state: SaveState) => void
Fired when autosave transitions between idle | saving | saved | error.
onDocumentCreated
(id: string) => void
Fired with the new id when a document is lazy-created.
onError
(code: ErrorCode, detail?: unknown) => void
Fired on recoverable/unrecoverable errors with a stable error code.
onTokenExpired
() => void
Fired when a forced token refresh fails; autosave pauses until recovery.
onEvent
(name: string, props?) => void
Analytics passthrough for editor interaction events.

EditorInstance

The object returned by mountEditor:
getJSON()
Json | null
Current editor content (TipTap JSON).
save()
Promise<void>
Force an immediate save of any pending changes.
setEditable(editable)
void
Toggle read-only / editable live.
setTheme(theme)
void
Switch theme ("light" | "dark") live.
destroy()
void
Tear down the editor and release the shared overlay root. Call this on unmount.

Manual save (autosave off)

const editor = qirtaas.mountEditor("#editor", {
  autosave: { enabled: false },
  onChange: (json) => setDirty(true),
});

// later, e.g. on your own "Save" button:
await editor.save();