Recipes

Recipe: Annotation Workflow

End-to-end annotation flow with selection helpers and CRUD APIs.

instance.setAnnotationMode('HIGHLIGHT');

const created = await instance.create({
  id: crypto.randomUUID(),
  type: 'note',
  pageIndex: 0,
  text: 'Review this section',
});

const selection = instance.getSelection();
if (selection) {
  instance.createHighlightFromSelection();
}

await instance.update({
  id: created.get(0).id,
  text: 'Updated review note',
});

Notes

  • Use setAnnotationCreatorName so audit trails are consistent.
  • Persist/export state with exportInstantJSON for collaborative workflows.