Getting StartedInstallation & Setup

Installation & Setup

Prerequisites

  • Node.js 18+ (LTS recommended)
  • npm 9+ or any compatible package manager

Install from npm

The Canvus SDK is published to npm as @canvus/core.

npm install @canvus/core

Basic Usage

Import the SDK in your project:

import { Workspace } from '@canvus/core'
 
const container = document.getElementById('editor-container')!
const ws = new Workspace(container, {
  onHTMLCommit(id, html) {
    console.log('Clean HTML:', html)
  },
})

Canvus is a zero-dependency SDK. It ships as pure ESM TypeScript with no runtime framework dependencies. You can integrate it into React, Vue, Svelte, or vanilla JavaScript projects.


Development Setup (Contributing)

If you want to contribute to the SDK or run the demos locally, clone the repository and build from source:

git clone https://github.com/balfaro01/canvus.git
cd canvus
npm install
npm run build

This compiles the TypeScript source in src/ to the ESM distribution in dist/:

  • dist/index.js β€” ESM entrypoint module
  • dist/index.d.ts β€” TypeScript type declarations
  • dist/*.js β€” Compiled utility modules

See the Development Setup guide for the full contributor workflow.

Launch the Dev Workbench

The demo workspace is an interactive playground for testing the SDK:

npm run demo

Open http://localhost:3000 to interact with:

  • Multi-direction panning and cursor-anchored zooming
  • Node resizing with flow reflow and alignment snapping
  • Display style hot-swapping (Flexbox, CSS Grid, block layouts)
  • Spacing adjusters for margins and paddings
  • The Flat String Bridge output logs

Project Structure

canvus/
β”œβ”€β”€ demo/         # Dev Workbench (Interactive local testing site)
β”œβ”€β”€ dist/         # Compiled SDK ESM build and type declarations
β”œβ”€β”€ docs/         # Raw developer documentation & ADRs
β”œβ”€β”€ docs-site/    # This documentation site (Next.js + Nextra)
β”œβ”€β”€ src/          # SDK Core source code (TypeScript)
β”‚   β”œβ”€β”€ index.ts        # Public API barrel exports
β”‚   β”œβ”€β”€ types.ts        # Canonical data types & models
β”‚   β”œβ”€β”€ matrix.ts       # Coordinate transform math
β”‚   β”œβ”€β”€ shadow-mount.ts # Shadow DOM projection layer
β”‚   β”œβ”€β”€ tree.ts         # In-memory node hierarchy
β”‚   β”œβ”€β”€ layout.ts       # CSS introspection & flow detection
β”‚   β”œβ”€β”€ renderer.ts     # Canvas overlay painter
β”‚   β”œβ”€β”€ drop-zone.ts    # Drag-and-drop slot calculations
β”‚   β”œβ”€β”€ importer.ts     # HTML/CSS document importer
β”‚   └── workspace.ts    # Central interaction orchestrator
β”œβ”€β”€ skills/       # Custom AI/Agent skills
└── package.json  # Scripts, build rules, and dependencies