Appearance
Vext Whiteboard Store
Pinia store that manages the whiteboard functionality.
State
Name | Description | Type | Values | Default |
---|---|---|---|---|
canvas | fabric.js canvas instance | object | - | null |
mode | active mode | string | ["edit", "brush"] | "edit" |
enabled | whether the whiteboard is enabled | boolean | - | false |
modified | timestamps for tracked layer modifications | object | - | {} |
layers | whiteboard-layer instances | object | - | {} |
selectedLayer | layer to select all canvas objects for | string | - | "" |
paths | array of paths drawn on the whiteboard | array | - | [] |
border | border style for layer canvas objects | object | - | { 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 (defaulttrue
)
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 (defaulttrue
)@param {Boolean}
record - whether to record this action (defaulttrue
)
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 (defaulttrue
)
removePath
Removes a path from the whiteboard canvas.
@param {Number}
index - path index, null removes the most recently added path (defaultnull
)@param {Boolean}
record - whether to record this action (defaulttrue
)
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 (defaulttrue
)
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