Skip to main content

PalettePluginOptions

Options for the palette plugin

Extends

Properties

allowClickToAdd?

optional allowClickToAdd: boolean

When in draw mode, allow addition of new vertices simply by clicking, instead of requiring a shape be drawn. (When this is true, the drag to draw functionality also still works)

Inherited from

PaletteOptions.allowClickToAdd


allowDropOnCanvas?

optional allowDropOnCanvas: boolean

Defaults to true. Allows items to be dropped onto whitespace.

Inherited from

PaletteOptions.allowDropOnCanvas


allowDropOnEdge?

optional allowDropOnEdge: boolean | CanDropOnEdgeFilter

Defaults to false. Allows items to be dropped onto edges in the canvas. A drop on an edge causes that edge to be split, with one edge having the new vertex as a target, and another edge with the new vertex as source.

Inherited from

PaletteOptions.allowDropOnEdge


allowDropOnGroup?

optional allowDropOnGroup: boolean

Defaults to true. Allows items to be dropped onto groups in the canvas.

Inherited from

PaletteOptions.allowDropOnGroup


allowDropOnNode?

optional allowDropOnNode: boolean

Defaults to false. Allows items to be dropped onto nodes in the canvas. If this is true and an element is dropped onto a node, the result is the same as if the element has been dropped onto whitespace. Note that when this is false and the user has dragged something over a node, the drag item is still not considered to be over the canvas, and releasing the mouse button at that time will not cause a new node to be added. Use ignoreDropOnNode if that's the behaviour you want.

Inherited from

PaletteOptions.allowDropOnNode


allowRotation?

optional allowRotation: boolean

Whether or not to allow rotation of elements being dragged. Defaults to true.

Inherited from

PaletteOptions.allowRotation


autoEdgeConnect?

optional autoEdgeConnect: boolean | AutoEdgeConnectOptions

Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.

Inherited from

PaletteOptions.autoEdgeConnect


canDrop()?

optional canDrop: (candidate, target?, onCanvas?) => boolean

Optional function that is invoked at the start of a drag, and which identifies allowed drop targets. Each target - the canvas, nodes and groups - is passed in turn to this method; returning false indicates that the given target is not valid for that drag.

Parameters

candidate

Node | Group

target?

Node | Group

onCanvas?

boolean

Returns

boolean

Inherited from

PaletteOptions.canDrop


canvasDropFilter?

optional canvasDropFilter: CanvasDropFilter

Optional function that you can use to inform the Palette that drop should be aborted. This method is invoked at the start of a drag (in drag mode) or when an item is tapped (in tap/draw mode) and is passed the candidate drag object's data.

Inherited from

PaletteOptions.canvasDropFilter


clickToAddOnly?

optional clickToAddOnly: boolean

This flag relates to "draw" mode, and defaults to false. When true, the palette only supports click to draw new vertices, not drag. This flag is forced to true if the associated UI does not have useModelForSizes set, since there is no point in allowing a user to drag a vertex to some size if its not going to be honoured. When you set this flag and associated UI does have useModelForSizes set, the palette will use default sizes for new nodes/groups.

Inherited from

PaletteOptions.clickToAddOnly


contentTemplate?

optional contentTemplate: string

Optional template that will be used in conjunction with data to generate the HTML content of the palette. The template can return any number of elements (ie. you're not limited to just a single root node)

Inherited from

PaletteOptions.contentTemplate


data?

optional data: ObjectData

Optional data that will be used in conjunction with contentTemplate to generate the HTML content of the palette.

Inherited from

PaletteOptions.data


dataGenerator?

optional dataGenerator: DataGeneratorFunction

Optional function to generate an initial payload from an element that has started to be dragged/has been tapped.

Inherited from

PaletteOptions.dataGenerator


dragActiveClass?

optional dragActiveClass: string

Class to set on the UI canvas and any other drop targets when a new element is being dragged

Inherited from

PaletteOptions.dragActiveClass


dragElementClass?

optional dragElementClass: string

Class to set on an element being dragged.

Inherited from

PaletteOptions.dragElementClass


dragHoverCannotDropClass?

optional dragHoverCannotDropClass: string

Class to set on the UI canvas and any other drop targets when a drag element is hovering over it but drop is not allowed.s

Inherited from

PaletteOptions.dragHoverCannotDropClass


dragHoverClass?

optional dragHoverClass: string

Class to set on the UI canvas and any other drop targets when a drag element is hovering over it.

Inherited from

PaletteOptions.dragHoverClass


dragSize?

optional dragSize: Size

Optional size to use for elements dragged from the palette; used in drag mode only.

Inherited from

PaletteOptions.dragSize


dragSizeGenerator()?

optional dragSizeGenerator: (payload, el) => Size

Optional function to generate the size to use for some object that is being dragged.

Parameters

payload

ObjectData

el

BrowserElement

Returns

Size

Inherited from

PaletteOptions.dragSizeGenerator


edgeDropHandler()?

optional edgeDropHandler: (newVertex, originalEdge) => EdgeDropInfo

If allowDropOnEdge is true, this function can be provided, to customise the behaviour of the drop. By default, the new vertex is used as the target of the original edge and the source of the new edge. But you might want to connect to ports on the new vertex, and this method allows you to do that: you can return the ID of a port to use for the existing edge's target, a port ID to use for the new edge's source, a source anchor or a target anchor.

Parameters

newVertex

Vertex

The newly dropped vertex

originalEdge

Edge

The edge that the vertex was dropped on.

Returns

EdgeDropInfo

Advanced

Inherited from

PaletteOptions.edgeDropHandler


elementGenerator()?

optional elementGenerator: (el, e) => BrowserElement

Optional function you can provide which will be used to generate an element to use for dragging. The default behaviour is to use a clone of the element the user began dragging, but if you provide this method you can customise that.

Parameters

el

BrowserElement

e

MouseEvent

Returns

BrowserElement

Inherited from

PaletteOptions.elementGenerator


enabled?

optional enabled: boolean

Defaults to true. Set to false if you wish to instantiate the Palette in a disabled state

Inherited from

PaletteOptions.enabled


groupIdentifier?

optional groupIdentifier: GroupIdentifierFunction

Optional function to use to determine if the element being dragged/has been tapped represents a group. If you do not provide this, the default behaviour is to check for the presence of a data-vjs-is-group attribute on the element, with a value of true.

Inherited from

PaletteOptions.groupIdentifier


ignoreDropOnNode?

optional ignoreDropOnNode: boolean

Defaults to false. When true, the palette treats nodes as if they are part of the canvas - a user can drag new items on top of existing nodes and the new item will be added to the canvas. If you want to force your users to drop on canvas whitespace, don't set this. Note that this flag will force allowDropOnNode to false.

Inherited from

PaletteOptions.ignoreDropOnNode


ignoreGrid?

optional ignoreGrid: boolean

Defaults to false. By default this class will conform to any grid in place in the surface to which it is attached when dragging items around.

Inherited from

PaletteOptions.ignoreGrid


ignoreZoom?

optional ignoreZoom: boolean

By default, the Palette will apply a scale transform to elements that are being dragged so that they appear at the same size as the UI they're being dragged to. Setting this flag to true will switch off that behaviour.

Inherited from

PaletteOptions.ignoreZoom


lassoClass?

optional lassoClass: string

When in 'draw' mode, you can optionally provide a class to set on the lasso used by the vertex drawing plugin.

Inherited from

PaletteOptions.lassoClass


mode?

optional mode: PaletteMode

Mode to operate in - 'drag', 'tap' or 'draw'. Defaults to 'drag'.

Inherited from

PaletteOptions.mode


onDrag?

optional onDrag: DragFunction

Optional function to invoke as the user is dragging a new element, or has tapped an element and is moving the mouse over the canvas.

Inherited from

PaletteOptions.onDrag


onVertexAdded?

optional onVertexAdded: OnVertexAddedCallback

Optional callback that will be invoked after a new vertex has been dropped and added to the dataset.

Param

Inherited from

PaletteOptions.onVertexAdded


rotationSpeed?

optional rotationSpeed: number

The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.

Inherited from

PaletteOptions.rotationSpeed


selectAfterAdd?

optional selectAfterAdd: boolean

Defaults to false. When true, a newly added vertex is set as the model's current selection.

Inherited from

PaletteOptions.selectAfterAdd


selector?

optional selector: string

A CSS selector identifying children of source that are draggable/can be tapped. If not provided, the Palette will use [data-vjs-type].

Inherited from

PaletteOptions.selector


source

source: BrowserElement

The element containing things that will be dragged/tapped.

Inherited from

PaletteOptions.source


typeGenerator?

optional typeGenerator: TypeGeneratorFunction

Optional function to determine the type of the data object from an element that is being dragged (in drag mode) or has been tapped (in draw/tap mode)

Inherited from

PaletteOptions.typeGenerator


vertexPreviewGenerator()?

optional vertexPreviewGenerator: (objectType, type, data, p, e) => BrowserElement

When in draw mode, this function can be used to provide the element shown to the user as a new vertex is being drawn.

Parameters

objectType

string

Group or Node

type

string

The type will map to an item in your view

data

ObjectData

The return value from the dataGenerator

p

PointXY

Location on the canvas where the mousedown event occurred.

e

MouseEvent

Mouse down event

Returns

BrowserElement

Inherited from

PaletteOptions.vertexPreviewGenerator


vertexPreviewUpdater()?

optional vertexPreviewUpdater: (el, origin, size, data) => any

When in draw mode this function is repeatedly called as the mouse is dragging a new shape. It provides a hook for you to update the element's appearance. This is only called if you provided a vertexPreviewGenerator and it has returned a valid DOM element at the start of a drag.

Parameters

el

BrowserElement

The element you returned from vertexPreviewGenerator.

origin

PointXY

The canvas location of the new vertex's top/left corner.

size

Size

The current size of the new vertex.

data

ObjectData

The return value from the dataGenerator

Returns

any

Inherited from

PaletteOptions.vertexPreviewUpdater