Svelte Components
Svelte components for building annotation UIs.
Core Components
Section titled “Core Components”AnnotaProvider
Section titled “AnnotaProvider”Provides annotation context to all child components.
Usage:
<AnnotaProvider slideId="my-slide"> <!-- Other components --></AnnotaProvider>Props:
slideId?: string- Identifier for this slide’s annotations
Viewer
Section titled “Viewer”OpenSeadragon viewer wrapper.
Usage:
<Viewer options={viewerOptions} onViewerReady={(viewer) => { // Store viewer instance }}/>Props:
options: OpenSeadragon.Options- OpenSeadragon configurationonViewerReady: (viewer: OpenSeadragon.Viewer) => void- Callback when viewer initializes
Annotator
Section titled “Annotator”Annotation overlay layer that renders annotations on top of the viewer.
Usage:
{#if viewer} <Annotator {viewer} style={(annotation) => ({ fill: "#FF0000", fillOpacity: 0.3, })} />{/if}Props:
viewer: OpenSeadragon.Viewer- The viewer instancestyle?: (annotation: Annotation) => AnnotationStyle- Custom style function
UI Components
Section titled “UI Components”Display information about an annotation.
Usage:
<Popup {viewer} annotation={annotation}> <div> <h3>{annotation.properties?.label}</h3> <p>Type: {annotation.shape.type}</p> </div></Popup>Props:
viewer: OpenSeadragon.Viewer- The viewer instanceannotation: Annotation- The annotation to displayoffset?: [number, number]- Offset from annotation position
ContextMenu
Section titled “ContextMenu”Context menu for annotation actions.
Usage:
<ContextMenu position={menuState.position} onClose={hideMenu}> <ContextMenuItem label="Delete" onclick={handleDelete} /> <ContextMenuDivider /> <ContextMenuItem label="Edit" onclick={handleEdit} /></ContextMenu>Props:
position: { x: number; y: number } | null- Menu positiononClose?: () => void- Callback when menu closeschildren: Snippet- Menu items
Editor Components
Section titled “Editor Components”AnnotationEditor
Section titled “AnnotationEditor”Provides vertex editing controls for selected annotations.
Usage:
<AnnotationEditor {viewer} />Props:
viewer: OpenSeadragon.Viewer- The viewer instance
Component Comparison
Section titled “Component Comparison”| Feature | React | Svelte |
|---|---|---|
| Provider | AnnotaProvider | AnnotaProvider |
| Viewer | AnnotaViewer | Viewer |
| Annotator | Annotator | Annotator |
| Popup | AnnotationPopup | Popup |
| Context Menu | ContextMenu | ContextMenu |
| Editor | AnnotationEditor | AnnotationEditor |
See Also
Section titled “See Also”- React Components - For comparison with React
- Component Patterns - Integration examples