Skip to main content

Objects

This is the API reference for all canvas object types in Kritzel. Every object consists of properties, computed properties, and methods.

Base Object​

Abstract base class for every object that can be placed on the canvas. All other object types listed below extend this class and inherit its properties, computed properties, and methods — only properties/methods specific to a given type are listed in its own section.

Properties​

PropertyTypeDefaultDescription
idstringauto-generated UUIDUnique identifier
workspaceIdstring—ID of the workspace this object belongs to
xnumber—X position in world coordinates
ynumber—Y position in world coordinates
translateXnumber—World-space X translation
translateYnumber—World-space Y translation
widthnumber—Width in world units
heightnumber—Height in world units
rotationnumber0Rotation in radians
opacitynumber1Opacity (0–1)
zIndexnumber0Z-order layer
scalenumber—Object scale
backgroundColorThemeAwareColor—Background color
borderColorThemeAwareColor—Border color
borderWidthnumber0Border width
paddingnumber0Padding
resizingbooleanfalseWhether the object is currently being resized
markedForRemovalbooleanfalseWhether the object is pending removal
userIdstring—ID of the user who created the object
isVisiblebooleantrueVisibility flag
isSelectedbooleanfalseWhether the object is selected
isHoveredbooleanfalseWhether the object is hovered
isMountedbooleanfalseWhether the object is mounted to the DOM
isEditablebooleanfalseWhether the object is in edit mode
isInteractivebooleanfalseWhether the object responds to interaction
isResizablebooleantrueWhether the object can be resized
isRotatablebooleantrueWhether the object can be rotated

Computed Properties​

PropertyTypeDescription
centerXnumberCenter X coordinate
centerYnumberCenter Y coordinate
totalWidthnumberWidth including padding and borders
totalHeightnumberHeight including padding and borders
boundingBoxKritzelBoundingBoxAxis-aligned bounding box
rotatedBoundingBoxKritzelBoundingBoxBounding box accounting for rotation
rotatedPolygonKritzelPolygonFour corners of the rotated rectangle
transformationMatrixDOMMatrixFull transformation matrix
rotationDegreesnumberRotation converted to degrees

Methods​

MethodDescription
mount(element)Mounts the object to a DOM element
generateId()Generates a new unique identifier
isInViewport()Tests if the object is visible in the current viewport
centerInViewport()Moves the object to the center of the current viewport
update()Notifies the store that the object was updated
move(startX, startY, endX, endY)Moves the object by the delta between two points
resize(x, y, width, height)Resizes and repositions the object
rotate(value)Sets the rotation angle in radians
updatePosition(x, y)Updates the object's translateX/translateY
clone()Creates a shallow copy of the object with the same id
copy()Creates an independent copy of the object with a new id
serialize()Converts the object to a plain serializable representation
deserialize(data)Restores the object from serialized data
isClass(className)Type guard that checks the object's __class__
edit(event)Handles edit actions; overridden by editable object types
hitTest(x, y)Tests if a world-coordinate point intersects this object
hitTestPolygon(polygon)Tests if a polygon intersects this object

Path​

Freehand brush strokes. Rendered as SVG paths using the perfect-freehand library.

  • Created by: KritzelBrushTool
  • Removed by: KritzelEraserTool

Properties​

PropertyTypeDefaultDescription
pointsnumber[][][]Array of [x, y] coordinate pairs defining the path
dstring—Generated SVG path data string
strokeThemeAwareColornoneStroke color
strokeWidthnumber8Width of the stroke in pixels
lineSlacknumber0.5Additional padding for bounding box calculations
fillThemeAwareColor—Fill color
isDebugInfoVisiblebooleantrueWhether debug info is rendered for the path
isCompletedbooleanfalseWhether the stroke has finished being drawn

Computed Properties​

PropertyTypeDescription
viewBoxstringSVG viewBox attribute for local (object-relative) rendering

Line​

Straight lines and arrows with configurable start/end arrowheads.

  • Created by: KritzelLineTool
  • Supports anchor snapping to other objects (connecting lines to shapes)
  • Arrowhead styles: triangle, open, diamond, circle

Properties​

PropertyTypeDefaultDescription
startXnumber0X coordinate of the start point
startYnumber0Y coordinate of the start point
endXnumber0X coordinate of the end point
endYnumber0Y coordinate of the end point
controlXnumber—X coordinate of the curve control point
controlYnumber—Y coordinate of the curve control point
strokeThemeAwareColor—Stroke color
strokeWidthnumber4Width of the stroke in pixels
opacitynumber1Line opacity (0–1)
startAnchorLineAnchor—Anchor connection for the start point
endAnchorLineAnchor—Anchor connection for the end point
arrowsLineArrowConfig—Arrow head configuration for start and end of line
isDebugInfoVisiblebooleantrueWhether debug info is rendered for the line
isCompletedbooleanfalseWhether the line has finished being drawn

Computed Properties​

PropertyTypeDescription
dstringGenerated SVG path data string (straight line or quadratic Bezier curve)
viewBoxstringSVG viewBox attribute string

Shape​

Geometric shapes: rectangle, ellipse, or triangle.

  • Created by: KritzelShapeTool
  • Can contain editable text
  • Shape type is determined by the ShapeType enum
enum ShapeType {
Rectangle = 'rectangle',
Ellipse = 'ellipse',
Triangle = 'triangle',
}

Properties​

PropertyTypeDefaultDescription
shapeTypeShapeTypeRectangleRectangle, Ellipse, or Triangle
fillColorThemeAwareColortransparentFill color
strokeColorThemeAwareColor#000000Stroke color
strokeWidthnumber4Width of the shape's stroke in pixels
fontFamilystringArialFont family for the shape's text content
fontSizenumber16Font size for text content in points
fontColorThemeAwareColor#000000Font color for text content
scaleFactornumber1Horizontal scale factor for transformations
isEditingbooleanfalseWhether the shape's text is currently being edited
editorEditorView—ProseMirror editor instance for the shape's text
contentany—Serialized ProseMirror document content
uneditedObjectKritzelShape—Snapshot of the shape before editing started

Computed Properties​

PropertyTypeDescription
viewBoxstringSVG viewBox using screen-space coordinates

Methods​

MethodDescription
updateDimensions()Recomputes world-space translateX/translateY from screen-space x/y
mountTextEditor(element)Mounts the ProseMirror text editor to a DOM element
setContent(content)Sets the text content from a serialized ProseMirror document
focus(coords)Focuses the text editor, optionally positioning the cursor at given coordinates

Text​

Rich text object powered by ProseMirror.

  • Created by: KritzelTextTool
  • Supports font family, size, and color configuration

Properties​

PropertyTypeDefaultDescription
fontFamilystringArialFont family name
fontSizenumber8Font size in points
fontColorThemeAwareColor#000000Font color
initialWidthnumber1Initial width before scaling
initialHeightnumber1Initial height before scaling
scaleFactornumber1Horizontal scale factor for transformations
isDebugInfoVisiblebooleantrueWhether debug info is rendered for the text object
isEditingbooleanfalseWhether the text is currently being edited
isNewlyCreatedbooleanfalseWhether the text object was just created and not yet edited
editorEditorView—ProseMirror editor instance
contentany—Serialized ProseMirror document content
uneditedObjectKritzelText—Snapshot of the text object before editing started
rowsnumber1Number of text rows

Computed Properties​

PropertyTypeDescription
isEmptybooleanWhether the editor is empty or contains only whitespace

Methods​

MethodDescription
setContent(content)Sets the text content from a serialized ProseMirror document
createEditor()Creates and configures a new ProseMirror editor instance
adjustSizeOnInput()Recalculates width/height based on the current content
focus(coords)Focuses the text editor, optionally positioning the cursor at given coordinates

Image​

Raster image object.

  • Created by: KritzelImageTool
  • Supports resizing while maintaining aspect ratio

Properties​

PropertyTypeDefaultDescription
assetIdstring''Stable asset identifier used to resolve the image bytes
mimeTypestring''MIME type of the referenced asset
srcstring''Legacy inline data URL (deprecated, use assetId)
maxWidthnumber300Maximum width in pixels
maxHeightnumber300Maximum height in pixels
maxCompressionSizenumber1200Maximum size used when compressing the image
resolvedSrcstring—URL resolved from the asset storage layer (not persisted)
loadStateKritzelAssetLoadStateidleCurrent load state of the referenced asset (not persisted)
maxLoadAttemptsnumber3Maximum number of definitive resolution failures before giving up
loadAttemptsnumber0Number of definitive resolution failures so far (not persisted)
maxTransientRetryDurationMsnumber30000Maximum time to keep retrying transient failures
transientRetryStartedAtnumber—Timestamp of the first transient failure in the current retry chain

Methods​

MethodDescription
ensureResolved()Triggers (idempotent) resolution of the referenced asset

Group​

Permanent grouping of multiple objects. Unlike a temporary multi-selection, a group is persisted and saved with the workspace.

  • Supports nested groups (groups can contain other groups)
  • Clicking any child selects the entire group
  • Children move, resize, and rotate as a unit

Properties​

PropertyTypeDefaultDescription
childIdsstring[][]IDs of the child objects within this group

Computed Properties​

PropertyTypeDescription
childrenKritzelBaseObject[]The actual child objects resolved from the store
lengthnumberNumber of children in this group

Methods​

MethodDescription
addChild(object)Adds a child object to this group
removeChild(objectId)Removes a child object from this group by id
ungroup()Returns all children as top-level objects
finalize()Refreshes the bounding box and snapshots after children are positioned
refreshBoundingBox()Recalculates the group's bounding box based on its children

Static Methods​

MethodDescription
createFromObjects(core, objects)Creates a group from an array of existing objects
findParentGroup(core, objectId)Finds the parent group that contains the given object as a direct child
collectDescendantIds(group)Recursively collects the ids of all descendants of a group

Dynamic Object​

User-defined custom HTML element on the canvas.

  • Allows embedding arbitrary HTML content as a canvas object
  • Participates in selection, movement, and z-ordering like any other object

Properties​

PropertyTypeDefaultDescription
elementHTMLElement—The HTML element rendered on the canvas
rendererKeystring—Identifier for a registered renderer (for example, 'react-card')
rendererDataunknown—Custom data payload passed to the renderer

Methods​

MethodDescription
setIsInteractive(isInteractive)Updates interactivity state for the embedded HTML content
hasFocusedInputElement()Returns true when a text-input-like element inside this object currently has focus