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
enabledrequiredboolean
- Whether to show the popover when text is selected
Example
tsx
// Disable text selection popoverpillar.setTextSelectionEnabled(false);// Re-enable itpillar.setTextSelectionEnabled(true);
Pillar.setDOMScanningEnabled()
Enable or disable DOM scanning at runtime.
typescript
setDOMScanningEnabled(enabled: boolean): void
Parameters
enabledrequiredboolean
- Whether to enable DOM scanning
Example
tsx
// Enable DOM scanningpillar.setDOMScanningEnabled(true);// Disable DOM scanningpillar.setDOMScanningEnabled(false);
Types
TextSelectionConfig
interfacetypescript
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
enabledboolean
Whether to show "Ask AI" popover on text selection (default: true)
labelstring
Label for the popover button (default: 'Ask AI')
DOMScanningConfig
interfacetypescript
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
enabledboolean
Whether DOM scanning is enabled.
When enabled, page structure is captured and sent with messages.Defaults to
false.includeTextboolean
Whether to include text content in the scan.Defaults to
true.maxDepthnumber
Maximum depth to traverse the DOM tree.Defaults to
20.visibleOnlyboolean
Whether to only include visible elements.Defaults to
true.excludeSelectorstring
CSS selector for elements to exclude from scanning.
maxTextLengthnumber
Maximum text length before truncation.Defaults to
500.interactionHighlightInteractionHighlightConfig
Configuration for highlighting elements during AI interactions.