Read-only preview
11/19/26Less than 1 minute
Read-only preview
There is no separate preview component anymore: AnnotationPreview and the @ghentcdh/annotation-preview package were removed. Use AnnotationEditor (or SmartAnnotationEditor) with readonly instead. Annotations are rendered and can be selected, but not created, edited or deleted.
See the Preview demo for a live example.
Usage
Vue
<template>
<AnnotationEditor
:readonly="true"
:sources="sources"
:annotations="annotations"
:annotation-definitions="definitions"
:layout="layout"
@select:annotation="onSelect"
/>
</template>
<script setup lang="ts">
import {
AnnotationEditor,
parseAnnotations,
w3cAnnotationTransformer,
type SourceModel,
} from '@ghentcdh/annotation-vue';
import { type W3CAnnotation } from '@ghentcdh/w3c-utils';
// sources, definitions, layout and w3cAnnotations: see the AnnotationEditor usage example
const annotations = parseAnnotations(w3cAnnotationTransformer, w3cAnnotations);
const onSelect = (annotation: W3CAnnotation | null, action: string | null) => {
console.log('selected', annotation?.id, action);
};
</script>Migrating from AnnotationPreview
AnnotationPreview | AnnotationEditor |
|---|---|
import … from '@ghentcdh/annotation-preview' | import { AnnotationEditor } from '@ghentcdh/annotation-vue' |
| — | add :readonly="true" |
configuration | drop it — not a prop of AnnotationEditor |
annotations: W3CAnnotation[] | annotations: EditorAnnotation[] — convert with your annotationTransformer |
annotationAdapter | annotationTransformer |
PreviewLayout | GridLayout |
sources, annotationDefinitions, cols, layout, selectedAnnotationId, textAdapter and the select:annotation event work the same. See AnnotationEditor for the full prop list.