Search documentation

Search documentation

Core SDK@pillar-ai/sdk

Features

Toggle text selection helper and DOM scanning.

typescript
import Pillar from '@pillar-ai/sdk'

Methods

Pillar.setTextSelectionEnabled()

Enable or disable the text selection "Ask AI" popover at runtime.

typescript
setTextSelectionEnabled(enabled: boolean): void

Parameters

enabled
requiredboolean
- Whether to show the popover when text is selected

Example

tsx
// Disable text selection popover
pillar.setTextSelectionEnabled(false);
// Re-enable it
pillar.setTextSelectionEnabled(true);

Pillar.setDOMScanningEnabled()

Enable or disable DOM scanning at runtime.

typescript
setDOMScanningEnabled(enabled: boolean): void

Parameters

enabled
requiredboolean
- Whether to enable DOM scanning

Example

tsx
// Enable DOM scanning
pillar.setDOMScanningEnabled(true);
// Disable DOM scanning
pillar.setDOMScanningEnabled(false);

Types

TextSelectionConfig

interface
typescript
interface TextSelectionConfig {
/** Whether to show "Ask AI" popover on text selection (default: true) */
enabled?: boolean;
/** Label for the popover button (default: 'Ask AI') */
label?: string;
}

Properties

enabled
boolean
Whether to show "Ask AI" popover on text selection (default: true)
label
string
Label for the popover button (default: 'Ask AI')

DOMScanningConfig

interface
typescript
interface DOMScanningConfig {
/**
* Whether DOM scanning is enabled.
* When enabled, page structure is captured and sent with messages.
* @default false
*/
enabled?: boolean;
/**
* Whether to include text content in the scan.
* @default true
*/
includeText?: boolean;
/**
* Maximum depth to traverse the DOM tree.
* @default 20
*/
maxDepth?: number;
/**
* Whether to only include visible elements.
* @default true
*/
visibleOnly?: boolean;
/**
* CSS selector for elements to exclude from scanning.
* @example '.sidebar, .footer, [data-no-scan]'
*/
excludeSelector?: string;
/**
* Maximum text length before truncation.
* @default 500
*/
maxTextLength?: number;
/**
* Configuration for highlighting elements during AI interactions.
*/
interactionHighlight?: InteractionHighlightConfig;
}

Properties

enabled
boolean
Whether DOM scanning is enabled. When enabled, page structure is captured and sent with messages.Defaults to false.
includeText
boolean
Whether to include text content in the scan.Defaults to true.
maxDepth
number
Maximum depth to traverse the DOM tree.Defaults to 20.
visibleOnly
boolean
Whether to only include visible elements.Defaults to true.
excludeSelector
string
CSS selector for elements to exclude from scanning.
maxTextLength
number
Maximum text length before truncation.Defaults to 500.
interactionHighlight
InteractionHighlightConfig
Configuration for highlighting elements during AI interactions.