Skip to main content
Version: Next 🚧

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
idstring✓The 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
idstring✓The 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
articleArticle✓The article to open externally.

setIframe()​

Sets the preview iframe window reference.

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

setPreviewData()​

Sets the preview data and updates the active highlight category.

setPreviewData(data: PreviewData): void
NameTypeRequiredDescription
dataPreviewData✓The preview data to set.

sendMessage()​

Sends a message to the preview iframe.

sendMessage(message: unknown): void
NameTypeRequiredDescription
messageunknown✓The 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
idstring✓Unique identifier for the request.
highlightCategorystring✓The highlight category to retrieve.
previewDataPreviewData✓Preview 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
enabledboolean✓true to enable the AI description.

toggle()​

Toggles extract and entity highlights in the preview.

toggle(extracts: boolean, entities: boolean): void
NameTypeRequiredDescription
extractsboolean✓Whether to show extract highlights.
entitiesboolean✓Whether to show entity highlights.