DocumentProxy

The currently-open Lucid document

Extends


Constructors

new DocumentProxy()

new DocumentProxy(client): DocumentProxy

Parameters

ParameterType
clientEditorClient

Returns

DocumentProxy

Overrides

ElementProxy.constructor


Properties

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


cardIntegrationConfigs

readonly cardIntegrationConfigs: MapProxy<string, CardConfigProxy>;

client

protected readonly client: EditorClient;

Inherited from

ElementProxy.client


id

readonly id: string;

ID of this element

Inherited from

ElementProxy.id


pages

readonly pages: MapProxy<string, PageProxy>;

The set of pages on this document, organized by ID


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


rules

readonly rules: MapProxy<string, RuleProxy>;

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

addPage()

addPage(def): PageProxy

Add a new page to the current document

Parameters

ParameterTypeDescription
defPageDefinitionDefinition of the page to add

Returns

PageProxy

The created page


addRule()

addRule(definition): undefined | RuleProxy

Parameters

ParameterType
definitionRuleDefinition

Returns

undefined | RuleProxy


allBlocks()

allBlocks(): Generator<BlockProxy, void, unknown>

An iterator over all blocks on all pages of the document

Returns

Generator<BlockProxy, void, unknown>


allLines()

allLines(): Generator<LineProxy, void, unknown>

An iterator over all lines on all pages of the document

Returns

Generator<LineProxy, void, unknown>


duplicateItems()

duplicateItems(ids): DuplicateItemsResult

Parameters

ParameterType
idsstring[]

Returns

DuplicateItemsResult


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


getTitle()

getTitle(): string

Returns

string

The title of this document


hookAllChanges()

hookAllChanges(callback): string

Infrequently, you may need to watch for any changes to the document. These changes may be
the local user adding content, or a data integration sending updated records to a data collection,
or a remote user hitting undo, or any user entering or exiting an intra-document mutex.

Because these changes may happen rapidly, the callback you provide here will only be called on
a heavily-debounced schedule. The callback will happen between 1-10 seconds after changes are
made to the document, depending on the frequency with which changes are happening.

Parameters

ParameterTypeDescription
callback() => void

Returns

string

A handle that can be passed into unhookAllChanges


hookCreateItems()

hookCreateItems(callback): string

Watch for new blocks, lines, or groups added to this document. The callback will
be called with new items created by the current user, but will not be called with items
created

  • As part of a generated diagram, e.g. org chart
  • By another user on the same document

Parameters

ParameterTypeDescription
callback(items) => void

Returns

string

A handle that can be passed to unhookCreateItems


hookDeleteItems()

hookDeleteItems(callback): string

Watch for new blocks, lines, or groups deleted from this document. The callback will
be called with items deleted by the current user, but will not be called with items
deleted

  • As part of a generated diagram, e.g. org chart
  • By another user on the same document

Parameters

ParameterTypeDescription
callback(itemIds) => void

Returns

string

A handle that can be passed to unhookDeleteItems


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 title of this document

Parameters

ParameterTypeDescription
titlestringThe new title for this document

Returns

void


unhookAllChanges()

unhookAllChanges(handle): void

Parameters

ParameterTypeDescription
handlestringReturn value from hookAllChanges

Returns

void


unhookCreateItems()

unhookCreateItems(handle): void

Parameters

ParameterTypeDescription
handlestringReturn value from hookCreateItems

Returns

void


unhookDeleteItems()

unhookDeleteItems(handle): void

Parameters

ParameterTypeDescription
handlestringReturn value from hookDeleteItems

Returns

void