Skip to main content

DiagramActionMediator

Defines an object that can decide at runtime whether a given shape should offer various actions in its shape editing tools. Each method in this interface is optional, and does not override any diagram-wide settings for the specific operation. Also, the mediator will not be invoked if a diagram is not editable.

Properties

canClone()?

optional canClone: (v, shape, el) => boolean

Returns whether or not the given vertex should be clonable in the UI. Defaults to true, meaning the clone icon will be present in the diagram tools.

Parameters

v

Node | Group

shape

ShapeType

el

BrowserElement

Returns

boolean


canCollapse()?

optional canCollapse: (group, currentSize) => boolean | ObjectData

Returns whether or not the given group can be collapsed

Parameters

group

Group

Group in question

currentSize

Size

The group's current size.

Returns

boolean | ObjectData

Either a boolean value indicating the operation may or may not proceed, or a set of values. In the case that a set of values are returned, the operation is approved, and the data returned is updated onto the group's dataset. This is useful when your UI wants to stored specific information related to the collapsed group.


canDelete()?

optional canDelete: (v, shape, el) => boolean

Returns whether or not the given vertex should be deletable in the UI. Defaults to true, meaning the delete icon will be present in the diagram tools when the vertex is selected.

Parameters

v

Node | Group

shape

ShapeType

el

BrowserElement

Returns

boolean


canDrag()?

optional canDrag: (v, shape, el) => boolean

Returns whether or not the given vertex should be draggable in the UI. Defaults to true.

Parameters

v

Node | Group

shape

ShapeType

el

BrowserElement

Returns

boolean


canDrop()?

optional canDrop: (vertex, targetVertex?, isOnCanvas?) => boolean

Returns whether or not the given vertex should be droppable on the given target, which may either be another vertex (if targetVertex is set), or the diagram canvas (if isOnCanvas is set). This method will never be called with both targetVertex set an isOnCanvas true - it's one or the other.

Parameters

vertex

Node | Group

targetVertex?

Node | Group

isOnCanvas?

boolean

Returns

boolean


canExpand()?

optional canExpand: (group, currentSize) => boolean | ObjectData

Returns whether or not the given group can be expanded

Parameters

group

Group

Group in question

currentSize

Size

The group's current (collapsed) size.

Returns

boolean | ObjectData

Either a boolean value indicating the operation may or may not proceed, or a set of values. In the case that a set of values are returned, the operation is approved, and the data returned is updated onto the group's dataset. This is useful when your UI wants to stored specific information related to the expanded group.


optional canLink: (v, shape, el) => boolean

Returns whether or not the given vertex should be linkable via edge drag in the UI. Defaults to true, meaning the link icon will be present in the diagram tools when the vertex is selected.

Parameters

v

Node | Group

shape

ShapeType

el

BrowserElement

Returns

boolean


canResize()?

optional canResize: (v, shape, el) => boolean

Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the resize handles will be present in the diagram tools when the vertex is selected.

Parameters

v

Node | Group

shape

ShapeType

el

BrowserElement

Returns

boolean


canRotate()?

optional canRotate: (v, shape, el) => boolean

Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the rotate handle and leader will be present in the diagram tools when the vertex is selected.

Parameters

v

Node | Group

shape

ShapeType

el

BrowserElement

Returns

boolean