GeneratorProxy

A generator on a page — an item that derives its shapes from some backing definition (e.g. a Mermaid diagram laid
out from markup). A single GeneratorProxy represents any generator type; its properties are read and written
generically via GeneratorProperty, and each generator type decides which properties it supports.

Extends


Constructors

new GeneratorProxy()

new GeneratorProxy(id, client): GeneratorProxy

Parameters

ParameterTypeDescription
idstringID of this element
clientEditorClient

Returns

GeneratorProxy

Inherited from

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


client

protected readonly client: EditorClient;

Inherited from

ElementProxy.client


id

readonly id: string;

ID of this element

Inherited from

ElementProxy.id


properties

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

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.

For text area properties, properties.get('Text') returns plain text. To get or set
rich text with inline formatting (bold, italic, links, line spacing), use the Rich:
prefix: properties.get('Rich:Text') returns {t: string, m: Array} with text and
markup, and properties.set('Rich:Text', {t: 'hello', m: [{s: 0, e: 5, n: 'b', v: true}]})
sets bold text. This works with any text area name (e.g. 'Rich:Title',
'Rich:Cell_0,1').

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

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


getProperty()

getProperty(property): UnsafeJsonSerializableOrUndefined

Reads a GeneratorProperty from this generator.

Parameters

ParameterTypeDescription
property"markup"The property to read (e.g. GeneratorProperty.Markup).

Returns

UnsafeJsonSerializableOrUndefined

The property value, or undefined if this generator does not have it.


listProperties()

listProperties(): "markup"[]

Returns

"markup"[]

The GeneratorPropertys that this generator supports.


removeReferenceKey()

removeReferenceKey(key): void

Remove the specified reference key from this element.

Parameters

ParameterTypeDescription
keystring | number

Returns

void

Inherited from

ElementProxy.removeReferenceKey


setProperty()

setProperty(property, value): Promise<void>

Sets a GeneratorProperty on this generator. Depending on the property and generator type this may
re-render the generator (e.g. setting Markup re-parses and re-lays-out a native Mermaid generator). Throws if
the generator does not support setting the property.

The returned promise resolves once the property has been applied. You may ignore it if you don't need to wait
for (or surface errors from) any re-render.

Parameters

ParameterTypeDescription
property"markup"The property to set (e.g. GeneratorProperty.Markup).
valueUnsafeJsonSerializableOrUndefinedThe new value for the property.

Returns

Promise<void>


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