Appearance
Note Store
Pinia store that implements the externalization capabilities, storing layers all configuration options (e.g. brush size, colors, etc.)
State
Name | Description | Type | Values | Default |
---|---|---|---|---|
enabled | whether VEXT is enabled | boolean | - | true |
canvas | fabric.js canvas object | object | - | null |
mode | which mode is currently active | string | ["layer", "brush", "shape", "edit", "connect", "settings", "whiteboard"] | "layer" |
currentState | current state as stored in the state store | object | - | null |
layers | list of all layers (AnntotationLayer) | array | - | [] |
activeLayer | currently active layer id | string | - | null |
layerMode | how layers are added | string | ["on annotation", "on state change", "manual"] | on annotation |
LAYER_ID_IDX | number for the next layer id | number | - | 0 |
activeObjectUUID | UUID of the selected fabric.js object | string | - | null |
activeObject | the selected fabric.js object | object | - | null |
connectLocation | start location of a connection | array | - | [0, 0] |
connectObject | connection data | any | - | null |
Getters
currentLayer
Return the currently active layer object if it exists, null otherwise.
previewLayer
Returns the preview layer object if it exists, null otherwise.
color
Currently active color.
layerColors
Array of layer colors.
nextColor
Next available color from the default colors. Will cycle if the number of layers exceeds the number of default colors.
nextID
An ID for a next layer.
Methods
enable
Enable the VEXT annotation functionalities.
disable
Disable the VEXT annotation functionalities.
enablePointerEvents
Enable or disable pointer events for the canvas node.
@param {Boolean}
value
emit
Emit an event from the note event handler.
@param {String}
name - event name@param {*}
data - event payload
on
Register an event handler.
@param {String}
name - event name@param {Function}
hadler - event callback handler@returns
handle id
off
Remove an event handler for the given event.
@param {String}
name - event name@param {Number}
handler - event handle@returns
true if the event was removed
isUniqueID
Whether the given id already exists for another layer.
@param {String}
id@returns
true if the id already exists, else false
getLayerIndex
Get the index in the layers array for a given layer id
@param {String}
id@returns
index if exists, else -1
getLayer
Get the AnnotationLayer object for a given layer id
@param {String}
id@returns
AnnotationLayer object if exists, else null
overwriteState
Set the current application state as the associated state of the currently active layer.
@param {Object}
state - current application state
renameLayer
Rename the given layer. If
id
is null, active layer will be renamed.@param {String}
oldId - layer id@param {String}
newId - new layer name/id@returns
true if the layer was renamed, otherwise false
addLayerComment
Add a comment to the given layer. If
id
is null, the comment is added to the active layer.@param {String}
comment - comment@param {String}
id - layer id (defaultnull
)@returns
true if the comment was added, otherwise false
updateLayerComment
Update the comment of the given layer. If
id
is null, the active layer is assumed.@param {String}
comment - comment@param {String}
id - layer id (defaultnull
)@param {Number}
index - comment index (default0
)@returns
true if the comment was updated, otherwise false
removeLayerComment
Remove the comment of the given layer. If
id
is null, the active layer is assumed.@param {String}
id - layer id (defaultnull
)@param {Number}
index - comment index (default0
)@returns
true if the comment was removed, otherwise false
removeLayerComments
Remove all comments of the given layer. If
id
is null, the active layer is assumed.@param {String}
id - layer id (defaultnull
)@returns
true if the comments were removed, otherwise false
mergeLayers
Merge annotations from one layer into another. The state of the merged layer is lost in the process. If
idInto
is null, the active layer is assumed.@param {String}
idFrom - layer to merge@param {String}
idInto - layer to merge into (defaultnull
)
addLayer
Create a new layer with the given state and set it as the active layer.
@param {Object}
state - application state@param {Boolean}
record - whether to record this action in history (defaulttrue
)@param {String}
id - layer id (defaultnull
)@param {String}
color - layer color (defaultnull
)@param {Number}
width - canvas width (defaultnull
)@param {Number}
height - canvas height (defaultnull
)@param {Array}
items - annotation items (default[]
)@param {Array}
comments - comments (default[]
)@param {Array}
connections - connections (default[]
)
removeLayer
Remove the layer with the given id, if it exists.
@param {String}
id - layer id@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeEmptyLayers
Remove all layers that contain no annotations.
@param {Boolean}
record - whether to record this action in history (defaulttrue
)
setActiveLayer
Set the active layer to the layer with id.
@param {String}
id@param {Boolean}
record - whether to record this action in history (defaulttrue
)
setLayerVisibility
Set the visibility for the layer with id.
@param {Boolean}
visible@param {String}
id - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history@param {Boolean}
render - whether to request a re-render of the canvas
setLayerOpacity
Set the opacity for the layer with id.
@param {Number}
value@param {String}
id - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)@param {Boolean}
render - whether to request a re-render of the canvas (defaulttrue
)
setMode
Set the active mode.
@param {String}
mode@param {Boolean}
record - whether to record this action in history (defaulttrue
)
setPreviousMode
Go to the previous mode.
@param {Boolean}
record - whether to record this action in history (defaulttrue
)
addObject
Add an object to the active layer.
@param {Object}
obj - fabric.js object@param {String}
layer - layer id (defaultnull
)@param {Boolean}
addToCanvas - whether to add them to the canvas (defaulttrue
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
addObjects
Add a list of objects to the active layer
@param {Array}
objs - list of fabric.js objects@param {String}
layer - layer id (defaultnull
)@param {Boolean}
addToCanvas - whether to add them to the canvas@param {Boolean}
record - whether to record this action in history
addObjectFromJSON
Add an object to the active layer
@param {String}
json - JSON representation of a fabric.js object@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
addObjectsFromJSON
Add a list of object to the active layer
@param {Array}
json - a list of JSON representations of frabic.js objects@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeObject
Remove the object with uuid from a layer
@param {String}
uuid@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeObjects
Remove all objects with a UUID included in uuids from a layer
@param {Array}
uuids@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeLastObject
Remove the last object that was added.
@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeLastObject
Remove the most recently added annotation object.
@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
modifyObject
Modify an annotation object.
@param {String}
uuid - object UUID@param {Object}
transform - object transform@param {String}
layer - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
setActiveObject
Set a specific annotation object to be active.
@param {String}
uuid - object UUID@param {String}
layer - layer id (defaultnull
)
getActiveObject
Returns the currently active fabric.js object.
@returns
active object or null
discardActiveObject
Discards the currently active fabric.js object.
deleteActiveObject
Deletes the object currently selected in fabric.js, if it exists.
@param {Boolean}
record - whether to record this action in history (defaulttrue
)
layerFromItem
Get the layer object for a given fabric.js item.
@param {Object}
item@returns
layer object if exists, else undefined
resizeCanvas
Resize the fabric.js canvas to [width, height].
@param {Number}
width@param {Number}
height
setCanvasZIndex
Sets the z-index for the canvas and wrapper elements.
@param {number}
value - z-index value to set
setContentNode
Set the visualization HTML node to include when rendering a layer into a PDF.
@param {HTMLElement}
node
setCanvas
Set the fabric.js canvas object - since it cannot be instantiated in a store. This adds several event listeners to the canvas.
@param {Object}
canvas
hasStateHash
Whether a layer with the given state exists.
@param {String}
hash@returns
true if exists, else false
layerFromStateHash
Returns the corresponding layer for a given state hash.
@param {String}
hash@returns
layer object if exists, else undefined
setState
Set the current application state.
@param {object}
state
selectPreviewLayer
Select the preview layer as active layer.
addConnection
Add a connection to a specific annotation in a layer.
@param {String}
uuid - annotation UUID@param {String}
id - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
addConnectionFromJSON
Add a connection from a JSON object to a specific annotation in a layer.
@param {String}
uuid - annotation UUID@param {Object}
json - connection@param {String}
id - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeLastConnection
Remove the most recently added connection of an annotation from a layer.
@param {String}
uuid - annotation UUID@param {String}
id - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
removeConnectionAtIndex
Remove the a connection of an annotation from a layer.
@param {String}
uuid - annotation UUID@param {Number}
index - connection index@param {String}
id - layer id (defaultnull
)@param {Boolean}
record - whether to record this action in history (defaulttrue
)
startConnect
Start a connection action.
@param {Object}
element - data to connect to@param {Number}
x - x position in window coordinates@param {Number}
y - y position in window coordinates
moveConnect
Move a started connection action.
@param {Number}
x - new x position in window coordinates@param {Number}
y - new y position in window coordinates
endConnect
End a started connection action.
@param {Number}
x - final x position in window coordinates@param {Number}
y - final y position in window coordinates
async importLayer
Reads the json file and creates a layer from it.
@param {File}
file - JSON file@returns
promise that is resolved when the layer is added
exportLayer
Return the currently active layer as a JSON object.
@returns
layer object if exists, else throws an exception
async exportZIP
Creates a .zip archive containing a report PDF, the layer as JSON, and state as JSON that is then automatically downloaded.
@param {String}
name - name to use for the zip file (default available)@param {Boolean}
canvasOnly - one include the canvas, not the whole content in the report PDF