Workspaces
Overview
A workspace is the container of the current canvas and stores its objects, viewport, and configuration. Only the active workspace is displayed and changed as the user interacts with the editor. This lets a single editor manage multiple independent canvases, similar to pages or documents.
Workspaces can either be created programmatically or managed through the built-in workspace manager.
Creating Workspaces
Workspaces can be created by instantiating a KritzelWorkspace object and passing it to editor.createWorkspace(). You can specify custom properties such as the workspace name, initial canvas viewport settings, or a custom id.
Reading Workspaces
Use getWorkspaces() to retrieve the complete workspace collection and getActiveWorkspace() when you only need the workspace currently shown in the editor. Both methods return workspace metadata such as the ID, name, visibility, and timestamps.
Updating Workspaces
Pass a workspace to updateWorkspace() describing how you want it to look. Name, visibility and viewport are applied, and if you set objects it becomes the workspace's complete object set — objects are matched by ID, so new entries are added, existing ones are updated, and anything you leave out is removed. Leave objects undefined (the default) to change metadata only, or pass [] to clear the canvas.
Deleting Workspaces
Call deleteWorkspace() with the workspace to remove. Keep at least one workspace available for the user and choose another active workspace before deleting the current one. The (workspacesChange) event lets custom navigation refresh whenever the collection changes.
Switching Workspaces
By default, Kritzel provides a built-in UI for managing multiple workspaces. However, if you hide this UI (hideWorkspaceManager), you can programmatically build your own workspace navigation. The <kritzel-editor> exposes an [activeWorkspaceId] input and an (activeWorkspaceChange) output binding that make switching between canvases seamless.
API Details
For the full list of related APIs, see the following reference sections.