One page in the current Lucid document
Extends
Constructors
new PageProxy()
new PageProxy(id, client): PageProxy
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The ID of this page |
client | EditorClient |
Returns
Overrides
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
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
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
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
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
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
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
Parameter | Type | Description |
---|---|---|
def | BlockDefinition | The definition of the new block to add |
Returns
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
Parameter | Type | Description |
---|---|---|
diagramType | MermaidDiagramType | The type of the diagram. Note that this is redundant because the Mermaid markup also contains the diagram type. |
mermaid | string | Mermaid 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
Parameter | Type | Description |
---|---|---|
def | ImageDefinition | The 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
Parameter | Type | Description |
---|---|---|
def | LineDefinition | The definition of the new line to add |
Returns
The added line
applyRuleToAllItems()
applyRuleToAllItems(rule): void
Parameters
Parameter | Type | Description |
---|---|---|
rule | RuleProxy | Rule 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
Parameter | Type | Description |
---|---|---|
formula | string | The 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
exists()
exists(): boolean
Returns
boolean
true
if this element still exists on the document, or false
otherwise
Inherited from
findAvailableSpace()
findAvailableSpace(
searchX,
searchY,
width,
height): object
Find available space on this page for adding new content.
Parameters
Parameter | Type | Description |
---|---|---|
searchX | number | Place to start the search |
searchY | number | Place to start the search |
width | number | |
height | number |
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
Parameter | Type | Description |
---|---|---|
boundingBox | Box | An area of this page to search for blocks, lines, and groups |
searchType | GetItemsAtSearchType |
Returns
(BlockProxy
| LineProxy
| GroupProxy
)[]
Items in the given bounding box, based on the search type
getLLMContextForItems()
getLLMContextForItems(items, contextType): object
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
items | ItemProxy [] | undefined | |
contextType | GetLLMContextType | GetLLMContextType.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
Parameter | Type | Default value | Description |
---|---|---|---|
items ? | ItemProxy [] | undefined | If specified, only include these items in the resulting SVG |
includeBackground ? | boolean | false | If true, include the background of the page in the SVG. Otherwise the background is transparent. |
viewBox ? | Box | undefined | If specified, crop the resulting SVG to the specified bounding box in page coordinates |
Returns
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
Parameter | Type | Description |
---|---|---|
blocks | BlockProxy [] | A non-empty array of items to group |
Returns
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
Parameter | Type | Description |
---|---|---|
links | string [] | 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
Parameter | Type | Description |
---|---|---|
key | string | 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
Parameter | Type | Description |
---|---|---|
key | string | number | |
settings | ReferenceKeyDefinition |
Returns
void
Inherited from
setTitle()
setTitle(title): void
Updates the page of this page
Parameters
Parameter | Type | Description |
---|---|---|
title | string | The new title for this page |
Returns
void
unapplyRuleToAllItems()
unapplyRuleToAllItems(rule): void
Parameters
Parameter | Type | Description |
---|---|---|
rule | RuleProxy | Rule to remove from the list applied to all items on this page |
Returns
void