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>
| Name | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | The document ID to preview. |
q | Partial<Query> | ✓ | Query parameters for the preview. |
customHighlights | CustomHighlights[] | Additional custom highlights. | |
audit | AuditEvents | Audit events to log. |
Returns Observable<PreviewData> — emits the preview data.
Example
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
| Name | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | The document ID of the preview to close. |
query | Partial<Query> | ✓ | The query used when the preview was opened. |
openExternal()
Opens an article in a new browser tab.
openExternal(article: Article): void
| Name | Type | Required | Description |
|---|---|---|---|
article | Article | ✓ | The article to open externally. |
setIframe()
Sets the preview iframe window reference.
setIframe(iframe: Window | null): void
| Name | Type | Required | Description |
|---|---|---|---|
iframe | Window | null | ✓ | The iframe window, or null to unset. |
setPreviewData()
Sets the preview data and updates the active highlight category.
setPreviewData(data: PreviewData): void
| Name | Type | Required | Description |
|---|---|---|---|
data | PreviewData | ✓ | The preview data to set. |
sendMessage()
Sends a message to the preview iframe.
sendMessage(message: unknown): void
| Name | Type | Required | Description |
|---|---|---|---|
message | unknown | ✓ | 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
| Name | Type | Required | Description |
|---|---|---|---|
id | string | ✓ | Unique identifier for the request. |
highlightCategory | string | ✓ | The highlight category to retrieve. |
previewData | PreviewData | ✓ | 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
| Name | Type | Required | Description |
|---|---|---|---|
enabled | boolean | ✓ | true to enable the AI description. |
toggle()
Toggles extract and entity highlights in the preview.
toggle(extracts: boolean, entities: boolean): void
| Name | Type | Required | Description |
|---|---|---|---|
extracts | boolean | ✓ | Whether to show extract highlights. |
entities | boolean | ✓ | Whether to show entity highlights. |