Skip to main content
Version: 11.14.0

Preview

The PreviewService manages document previews: fetching preview data, communicating with the preview iframe, and controlling highlight visibility.

Methods

preview()

Fetches preview data for a document.

preview(id: string, q: Partial<Query>, customHighlights?: CustomHighlights[], audit?: AuditEvents): Observable<PreviewData>
NameTypeRequiredDescription
idstringThe document ID to preview.
qPartial<Query>Query parameters for the preview.
customHighlightsCustomHighlights[]Additional custom highlights.
auditAuditEventsAudit events to log.

Returns Observable<PreviewData> — emits the preview data.

Example

example.component.ts
import { inject } from '@angular/core';
import { PreviewService } from '@sinequa/atomic-angular';

inject(PreviewService).preview('documentId', { text: 'query' }).subscribe(data => {
console.log(data);
});

close()

Closes a preview and updates the audit log.

close(id: string, query: Partial<Query>): void
NameTypeRequiredDescription
idstringThe document ID of the preview to close.
queryPartial<Query>The query used when the preview was opened.

openExternal()

Opens an article in a new browser tab.

openExternal(article: Article): void
NameTypeRequiredDescription
articleArticleThe article to open externally.

setIframe()

Sets the preview iframe window reference.

setIframe(iframe: Window | null): void
NameTypeRequiredDescription
iframeWindow | nullThe iframe window, or null to unset.

setPreviewData()

Sets the preview data and updates the active highlight category.

setPreviewData(data: PreviewData): void
NameTypeRequiredDescription
dataPreviewDataThe preview data to set.

sendMessage()

Sends a message to the preview iframe.

sendMessage(message: unknown): void
NameTypeRequiredDescription
messageunknownThe message payload.

retrieveHtmlContent()

Sends a message to the iframe to retrieve HTML content for a specific highlight category.

retrieveHtmlContent(id: string, highlightCategory: string, previewData: PreviewData): void
NameTypeRequiredDescription
idstringUnique identifier for the request.
highlightCategorystringThe highlight category to retrieve.
previewDataPreviewDataPreview data with highlight locations.

zoomIn()

Sends a zoom-in message to the preview iframe.

zoomIn(): void

zoomOut()

Sends a zoom-out message to the preview iframe.

zoomOut(): void

toggleAIDescription()

Enables or disables the AI description in the preview.

toggleAIDescription(enabled: boolean): void
NameTypeRequiredDescription
enabledbooleantrue to enable the AI description.

toggle()

Toggles extract and entity highlights in the preview.

toggle(extracts: boolean, entities: boolean): void
NameTypeRequiredDescription
extractsbooleanWhether to show extract highlights.
entitiesbooleanWhether to show entity highlights.