Skip to content

API reference / Common / Engine types / PortableSelection

Type Alias: PortableSelection ​

ts
type PortableSelection = 
  | "none"
  | {
  objects: {
     page: PageId;
     ids: GraphicsObjectId[];
  };
}
  | {
  annotations: {
     page: PageId;
     ids: AnnotationId[];
  };
}
  | {
  annotationShape: {
     page: PageId;
     id: AnnotationId;
     selection: ShapeSelection;
  };
}
  | {
  objectText: {
     page: PageId;
     anchor: TextPosition;
     focus: TextPosition;
  };
}
  | {
  documentText: {
     anchor: PortableTextEndpoint;
     focus: PortableTextEndpoint;
  };
};

The selection of a portable document's editor — presence state beside the CRDT, never in it (see [Selection]).

Confined to one page: a selection is graphics objects or annotations on a single page, named together with that page's id — never both kinds at once. Editing is page-at-a-time, so an object edit always knows its page from the selection — no per-object page lookup, and a gesture commits as one page-scoped command. Picking on a different page starts a fresh selection there (see combined_with).

Entities are named by id, not index: ids are minted once and shared by every replica, so a selection survives a concurrent page reorder untouched, and a concurrently deleted object simply stops resolving (consumers skip it) instead of silently pointing at a neighbor. Mirrors PresentationSelection.