Skip to main content

Home > @jsplumbtoolkit/core > JsPlumbToolkitOptions

JsPlumbToolkitOptions interface#

Constructor options for a Toolkit instance.

Signature:

export interface JsPlumbToolkitOptions 

Properties#

PropertyTypeDescription
autoSave?boolean(Optional) Whether or not to automatically save the data when an update to a model object occurs. If you set this then you need to provide saveUrl or autoSaveHandler.
autoSaveDebounceTimeout?number(Optional) A debounce timeout to use when the autoSave functionality is turned on. You can use this to reduce the number of calls to your auto save endpoint.
autoSaveHandler?(instance: JsPlumbToolkit) => any(Optional) A handler for the auto save operation. You need to provide this or saveUrl if you set autoSave:true.
data?any(Optional) Data to load directly after Toolkit has been created.
defaultCost?number(Optional) The default cost for an edge. Default value is 1.
defaultDirected?boolean(Optional) Whether edges are directed by default. The default value for this is true - edges are directed by default.
doNotUpdateOriginalData?boolean(Optional) Sets whether or not the Toolkit manipulates the original dataset when updates are made. Defaults to true.
edgeFactory?ObjectFactory(Optional)
edgeIdFunction?IdFunction(Optional) A function to use to determine the ID of some edge from its data. By default the Toolkit uses the value of the object's id property.
edgeTypeFunction?TypeFunction(Optional) A function to use to determine the type of some edge from its data object. By default the Toolkit uses the value of the object's type property.
edgeTypeProperty?string(Optional) The name of the property that identifies a given edge's type. By default this is the type property. If you do not set this but you do set typeProperty, that value will be used.
groupFactory?ObjectFactory(Optional)
idFunction?IdFunction(Optional) A function to use to determine the ID of some data object. By default the Toolkit uses the value of the object's id property.
maxSelectedEdges?number(Optional) The maximum number of edges that can be selected at any one time. Defaults to Infinity.
maxSelectedGroups?number(Optional) The maximum number of groups that can be selected at any one time. Defaults to Infinity.
maxSelectedNodes?number(Optional) The maximum number of nodes that can be selected at any one time. Defaults to Infinity.
model?DataModelDefinition(Optional)
nodeFactory?ObjectFactory(Optional)
onAfterAutoSave?() => any(Optional) A function to run after the auto save has run.
onAutoSaveError?() => any(Optional) A function to call when an auto save operation experienced an error.
onAutoSaveSuccess?() => any(Optional) A function to call when an auto save operation was successful.
onBeforeAutoSave?() => any(Optional) A function to run before auto save runs.
portDataProperty?string(Optional) The name of a property that will exist inside the backing data for nodes/group, and which represents a list of ports pertaining to that node/group. When a node/group is rendered, if this property is set, the Toolkit will consider the value of this property to be a list of port data object. So this property's value should be of type Array<ObjectData>
portExtractor?(o: ObjectData) => Array<ObjectData>(Optional) A function to use to extract an array of ports from the data representing some node/group. Whenever a node/group is rendered, the Toolkit will use this method, if provided, to determine a list of ports for that node/group. If you use this you probably also want to define a portUpdater. Note that if you provide the portDataProperty then you do not need to set this.
portFactory?ObjectFactory(Optional)
portIdFunction?IdFunction(Optional) A function to use to determine the ID of some port from its data. By default the Toolkit uses the value of the object's id property.
portOrderProperty?string(Optional) The name of a property inside of each port's data that can be used to order the ports. For instance, you might have ports that have a rank property, which is a number. The Toolkit will sort the ports according to the natural ordering of this property.
portSeparator?string(Optional) The character to use in port identifiers. Defaults to ., eg. someVertex.somePort.
portTypeFunction?TypeFunction(Optional) A function to use to determine the type of some port from its data object. By default the Toolkit uses the value of the object's type property.
portTypeProperty?string(Optional) The name of the property that identifies a given port's type. By default this is the type property. If you do not set this but you do set typeProperty, that value will be used.
portUpdater?Function(Optional) A function to use to update a given node/group's list of ports. Note that if you provide the portDataProperty then you do not need to set this.
saveHeaders?any(Optional) A map of HTTP headers to send along with an auto save request.
saveUrl?string(Optional) URL for auto save endpoint.
selectionCapacityPolicy?string(Optional) Defines the action taken when appending an object that would take the selection above its limit for the given object type. This can be either Selection.DISCARD_EXISTING (the default) or Selection.DISCARD_NEW.
typeFunction?TypeFunction(Optional) A function to use to determine the type of some data object. By default the Toolkit uses the value of the object's type property.
typeProperty?string(Optional) The name of the property that identifies a given object's type. By default this is the type property.
undoRedo?{ enabled?: boolean; maximumSize?: number; }(Optional) Configuration for undo/redo

Methods#

MethodDescription
beforeConnect(source, target, data)?(Optional) A function to run before an edge with the given data can be established between the given source and target. Returning false from this method aborts the connection.
beforeDetach(source, target, edge, isDiscard)?(Optional) A function to run before the given edge is detached from the given source vertex. If this method returns false, the detach will be aborted.
beforeMoveConnection(source, target, edge)?(Optional) A function to run before an edge of the given type is relocated from its current source or target to a new source or target. Returning false from this method will abort the move
beforeStartConnect(source, type)?(Optional) A function to run before an edge of the given type is dragged from the given source. Returning false from this method will abort the connection.
beforeStartDetach(source, edge)?(Optional) A function to run before the given edge is detached from the given source vertex. If this method returns false, the detach will be aborted. The difference between this and beforeDetach is that this method is fired as soon as a user tries to detach an edge from an endpoint in the UI, whereas beforeDetach allows a user to detach the edge in the UI.