PageProxy

One page in the current Lucid document

Extends


Constructors

new PageProxy()

new PageProxy(id, client): PageProxy

Parameters

ParameterTypeDescription
idstringThe ID of this page
clientEditorClient

Returns

PageProxy

Overrides

ElementProxy.constructor


Properties

allBlocks

readonly allBlocks: MapProxy<string, BlockProxy>;

The blocks contained on this page, including ones inside groups


allGroups

readonly allGroups: MapProxy<string, GroupProxy>;

The groups contained on this page, including ones inside groups


allItems

readonly allItems: MapProxy<string, BlockProxy | LineProxy | GroupProxy>;

All blocks, lines, and groups on the page, including ones inside groups


allLines

readonly allLines: MapProxy<string, LineProxy>;

The lines contained on this page, including ones inside groups


allShapeData

readonly allShapeData: MapProxy<string, SerializedFieldType | DataError>;

All shape data accessible on this element, including shape data inherited from the page or a containing group.
This collection is read-only.

Inherited from

ElementProxy.allShapeData


blocks

readonly blocks: MapProxy<string, BlockProxy>;

The blocks contained directly on this page, not including ones inside groups


client

protected readonly client: EditorClient;

Inherited from

ElementProxy.client


groups

readonly groups: MapProxy<string, GroupProxy>;

The groups contained directly on this page, not including ones inside groups


id

readonly id: string;

The ID of this page

Inherited from

ElementProxy.id


lines

readonly lines: MapProxy<string, LineProxy>;

The lines contained directly on this page, not including ones inside groups


properties

readonly properties: WriteableMapProxy<string, JsonSerializable, void, JsonSerializable>;

All properties available on this element, organized by name.
Not all properties are writeable (e.g. "ClassName" on a block).
To move or resize elements, use setLocation() or setBoundingBox() or offset() instead.

Inherited from

ElementProxy.properties


referenceKeys

readonly referenceKeys: MapProxy<string | number, ReferenceKeyProxy>;

The set of reference keys, organized by their ID, which can be either a string or number.

For more information, see the Developer Guide.

Inherited from

ElementProxy.referenceKeys


shapeData

readonly shapeData: ShapeDataProxy;

The shape data set directly on this element (not including any shape data inherited from the page or a containing group).

Inherited from

ElementProxy.shapeData


Methods

addBlock()

addBlock(def): BlockProxy

Add a new block to this page.

IMPORTANT: Because code for block classes are loaded incrementally, you MUST call
EditorClient.loadBlockClasses with the given block class name (and wait for it to
resolve) before attempting to create a block. If you don't, an error will be thrown.

Parameters

ParameterTypeDescription
defBlockDefinitionThe definition of the new block to add

Returns

BlockProxy

The added block


addDiagramFromMermaid()

addDiagramFromMermaid(
   diagramType, 
   mermaid, 
   origin?, 
exactPlacement?): Promise<(BlockProxy | LineProxy | GroupProxy)[]>

Add a diagram described by Mermaid markup to this page.

See https://mermaid.js.org/intro/syntax-reference.html for information on Mermaid markup syntax.

Parameters

ParameterTypeDescription
diagramTypeMermaidDiagramType

The type of the diagram. Note that this is redundant because the Mermaid markup also contains

the diagram type.

mermaidstringMermaid markup text describing the diagram to add.
origin?Point

Where to place the diagram on the page. If absent some free

space within or near the current viewport is automatically chosen.

exactPlacement?boolean

If true and if origin is specified, places the diagram exactly at the specified origin

instead of trying to find free space.

Returns

Promise<(BlockProxy | LineProxy | GroupProxy)[]>

An array of the proxies for all the objects in the added diagram.


addImage()

addImage(def): Promise<BlockProxy>

Add a new image to this page.

Parameters

ParameterTypeDescription
defImageDefinitionThe definition of the new image to add

Returns

Promise<BlockProxy>

The added image


addLine()

addLine(def): LineProxy

Add a new line to this page.

Parameters

ParameterTypeDescription
defLineDefinitionThe definition of the new line to add

Returns

LineProxy

The added line


applyRuleToAllItems()

applyRuleToAllItems(rule): void

Parameters

ParameterTypeDescription
ruleRuleProxyRule to apply to all items on this page

Returns

void


delete()

delete(): void

Delete this page from the document if possible

Returns

void


duplicate()

duplicate(): Promise<void>

Duplicates the page represented by the page proxy

Returns

Promise<void>


executeFormula()

executeFormula(formula): SerializedFieldType | DataError

Execute a formula in the context of this element

Parameters

ParameterTypeDescription
formulastringThe formula text, e.g. "@a + @b" to add together the shape data values a and b.

Returns

SerializedFieldType | DataError

The result of the formula, or an error.

Inherited from

ElementProxy.executeFormula


exists()

exists(): boolean

Returns

boolean

true if this element still exists on the document, or false otherwise

Inherited from

ElementProxy.exists


findAvailableSpace()

findAvailableSpace(
   searchX, 
   searchY, 
   width, 
   height): object

Find available space on this page for adding new content.

Parameters

ParameterTypeDescription
searchXnumberPlace to start the search
searchYnumberPlace to start the search
widthnumber
heightnumber

Returns

object

a reference to the page and origin (upper-left point) of the space you can add new
content of the given size to.

page
page: PageProxy;
x
x: number;
y
y: number;

findItems()

findItems(boundingBox, searchType): (BlockProxy | LineProxy | GroupProxy)[]

Parameters

ParameterTypeDescription
boundingBoxBoxAn area of this page to search for blocks, lines, and groups
searchTypeGetItemsAtSearchType

Returns

(BlockProxy | LineProxy | GroupProxy)[]

Items in the given bounding box, based on the search type


getLLMContextForItems()

getLLMContextForItems(items, contextType): object

Parameters

ParameterTypeDefault valueDescription
itemsItemProxy[]undefined
contextTypeGetLLMContextTypeGetLLMContextType.Relational-

Returns

object

A string representing the content of the items provided, including immediate surrounding context if
necessary, in a format that is easily understandable by LLMs like ChatGPT. Also a map of IDs, from the shortened
IDs provided for the items in the context to the actual Lucid item IDs.

idToLucidId
idToLucidId: Map<string, string>;
prompt
prompt: string;

getPageNumber()

getPageNumber(): number

Returns

number

the page number of this page


getRulesAppliedToAllItems()

getRulesAppliedToAllItems(): RuleProxy[]

Returns

RuleProxy[]

All conditional formatting rules that are applied to every item on this page


getSvg()

getSvg(
   items?, 
   includeBackground?, 
   viewBox?): GetSvgResult

Parameters

ParameterTypeDefault valueDescription
items?ItemProxy[]undefinedIf specified, only include these items in the resulting SVG
includeBackground?booleanfalseIf true, include the background of the page in the SVG. Otherwise the background is transparent.
viewBox?BoxundefinedIf specified, crop the resulting SVG to the specified bounding box in page coordinates

Returns

GetSvgResult

A promise resolving to an SVG string


getTitle()

getTitle(): string

Returns

string

the title of this page


groupBlocks()

groupBlocks(blocks): GroupProxy

Creates a new group from a list of items.

Parameters

ParameterTypeDescription
blocksBlockProxy[]A non-empty array of items to group

Returns

GroupProxy

The added group


importLinks()

importLinks(links): Promise<void>

Import links onto this page as link unfurl blocks

NOTE: links will be unfurled by Lucid based on extensions installed by user

Parameters

ParameterTypeDescription
linksstring[]links to be imported onto the canvas as link unfurl blocks

Returns

Promise<void>


removeReferenceKey()

removeReferenceKey(key): void

Remove the specified reference key from this element.

Parameters

ParameterTypeDescription
keystring | number

Returns

void

Inherited from

ElementProxy.removeReferenceKey


setReferenceKey()

setReferenceKey(key, settings): void

Set a reference key on this element, replacing any existing reference at the specified key.

Parameters

ParameterTypeDescription
keystring | number
settingsReferenceKeyDefinition

Returns

void

Inherited from

ElementProxy.setReferenceKey


setTitle()

setTitle(title): void

Updates the page of this page

Parameters

ParameterTypeDescription
titlestringThe new title for this page

Returns

void


unapplyRuleToAllItems()

unapplyRuleToAllItems(rule): void

Parameters

ParameterTypeDescription
ruleRuleProxyRule to remove from the list applied to all items on this page

Returns

void