Skip to content
On this page

Vext Whiteboard Store

Pinia store that manages the whiteboard functionality.

State

NameDescriptionTypeValuesDefault
canvasfabric.js canvas instanceobject-null
modeactive modestring["edit", "brush"]"edit"
enabledwhether the whiteboard is enabledboolean-false
modifiedtimestamps for tracked layer modificationsobject-{}
layerswhiteboard-layer instancesobject-{}
selectedLayerlayer to select all canvas objects forstring-""
pathsarray of paths drawn on the whiteboardarray-[]
borderborder style for layer canvas objectsobject-{ color: "lightgrey", size: 1, }

Methods

setCanvas

Set the fabric.js canvas instance to use for the whiteboard.
@param {Object} canvas - the fabric.js canvas

setMode

Set the mode for the whiteboard.
@param {String} mode
@param {Boolean} record - whether to record this action (default true)

addPath

Adds a path to the whiteboard canvas.
@param {Object} path - fabric.js path object
@param {Boolean} addToCanvas - whether to add the path to the canvas (default true)
@param {Boolean} record - whether to record this action (default true)

addPathFromJSON

Adds a path to the whiteboard canvas.
@param {Object} path - JSON representation of a fabric.js path object
@param {Boolean} record - whether to record this action (default true)

removePath

Removes a path from the whiteboard canvas.
@param {Number} index - path index, null removes the most recently added path (default null)
@param {Boolean} record - whether to record this action (default true)

modifyObject

Modifies an objects transform (i.e. scale, translation, rotation).
@param {String} uuid - object UUID
@param {Object} transform - the transform to apply
@param {Boolean} record - whether to record this action (default true)

itemFromUUID

Returns the matching canvas object for a given UUID.
@param {String} uuid - object uuid
@returns {Object}

setBrushColor

Sets the brush color for the whiteboard canvas.
@param {String} color - brush color

setBrushSize

Sets the brush size for the whiteboard canvas.
@param {Number} size - brush size in pixels

setCanvasZIndex

Sets the z-index for the canvas element.
@param {Number} value - z-index value

resizeCanvas

Resize the canvas to the passed width and height.
@param {Number} width - new canvas width
@param {Number} height - new canvas height

async enable

Enables the whiteboard and reloads any layer data if they were modified since the last time the whiteboard was enabled.

disable

Disables the whiteboard.

selectLayer

Select a specific layer's canvas objects.
@param {String} id - layer id

deleteActiveObject

Deletes the currently active canvas object.

async addLayerImage

Adds the data from a layer as a new WhiteBoardLayer.
@param {AnnotationLayer} layer - layer object

async updateLayerImage

Updates the data from a layer.
@param {AnnotationLayer} layer - layer object