Skip to main content

Canvas Addons

Addons extend ChamevoCanvas with optional features via the canvas.use() plugin pattern.

Using Addons

import { ChamevoCanvas, snapGuides, ruler, multiSelection, highlightEditable } from '@chamevo/core';

const canvas = new ChamevoCanvas(canvasEl, { width: 800, height: 600 });

// Enable smart alignment guides
canvas.use(snapGuides);

// Enable rulers
canvas.use(ruler, { unit: 'mm' });

// Enable Shift+click multi-selection
canvas.use(multiSelection);

// Highlight editable objects with dashed border
canvas.use(highlightEditable, { color: '#2185d0' });

Built-in Addons

AddonDescriptionOptions
snapGuidesSmart alignment guides when moving/resizing elements.
rulerX/Y axis rulers with unit display.{ unit: 'mm' | 'cm' | 'inch' | 'px' }
multiSelectionSelect multiple elements with Shift+click.
highlightEditableShow dashed border on editable objects.{ color: string }

Canvas Overlay Components

Some visual overlays are implemented as StencilJS components rather than canvas addons. These are automatically rendered by cv-customizer and controlled via options:

ComponentOptionDescription
<cv-size-tooltip>sizeTooltip: trueShows W × H dimensions above the selected image element in the configured unitOfMeasurement.

Creating Custom Addons

Addons implement the ChamevoAddon interface:

import type { ChamevoAddon } from '@chamevo/core';

const myAddon: ChamevoAddon = {
name: 'my-addon',

install(canvas, options) {
// Called once when canvas.use(myAddon) is invoked
// Set up event listeners, modify canvas behavior, etc.

canvas.on('object:added', (e) => {
console.log('Element added:', e.target);
});
},

uninstall(canvas) {
// Clean up when addon is removed
},
};

// Usage
canvas.use(myAddon, { /* custom options */ });

Next Steps