A modern, Vue 3-based whiteboard and diagramming library for building interactive canvas applications.
npm install whiteboard-v2
# or
yarn add whiteboard-v2This library requires the following peer dependencies:
npm install vue@^3.5 pinia@^3.0import 'whiteboard-v2/style.css'import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
const app = createApp(App)
app.use(createPinia())
app.mount('#app')<script setup lang="ts">
import { EditPage } from 'whiteboard-v2'
</script>
<template>
<EditPage />
</template>| Component | Description |
|---|---|
EditPage |
Full-featured editor with sidebars, toolbars, and canvas |
| Store | Description |
|---|---|
useElementsStore |
Manages canvas elements, selection, clipboard, and history |
useZoomStore |
Controls zoom level |
useDragStore |
Manages drag state and ghost elements |
All TypeScript types are exported for type-safe integration:
Element- Base element interfaceGroupElement- Grouped elementsShapeType- Available shape typesSnapLine- Snapping guide typesElementWrapperEvents- Event interfacesResizeEvents- Resize event interfaces
- Rectangle, Triangle, Trapezoid, Chevron
- Hexagon, Ellipse, Diamond, Parallelogram
- Pentagon, Arrow, Line, Horizontal Line
- Custom shapes
- Drag and drop positioning
- 8-direction resize handles
- 90-degree rotation
- Multi-element selection
- Shape grouping and ungrouping
- Copy, paste, and duplicate
- Undo/redo history (up to 50 states)
- Smart snap alignment guides
- Grid-based canvas
- Zoom controls (in, out, fit to view)
- Dark mode support
- Save/load JSON files
- Template support
| Shortcut | Action |
|---|---|
Arrow keys |
Move selected elements (5px) |
Shift + Arrow keys |
Move selected elements (20px) |
Ctrl/Cmd + C |
Copy |
Ctrl/Cmd + V |
Paste |
Ctrl/Cmd + D |
Duplicate |
Ctrl/Cmd + G |
Group elements |
Ctrl/Cmd + Shift + G |
Ungroup |
Ctrl/Cmd + S |
Save |
Delete / Backspace |
Delete selected |
<script setup lang="ts">
import { useElementsStore, useZoomStore } from 'whiteboard-v2'
const elementsStore = useElementsStore()
const zoomStore = useZoomStore()
// Add an element programmatically
elementsStore.addElement({
type: 'shape',
shapeType: 'rectangle',
x: 100,
y: 100,
width: 200,
height: 100,
fillColor: '#3b82f6',
outlineColor: '#1e40af',
})
// Control zoom
zoomStore.setZoom(1.5)
</script>import { useElementsStore } from 'whiteboard-v2'
const store = useElementsStore()
// Export canvas state
const canvasData = JSON.stringify(store.elements)
// Import canvas state
store.elements = JSON.parse(canvasData)The swt-export-ready branch contains improvements for better TypeScript declaration bundling when using the library in other applications. These changes will be merged soon.
- Node.js v24
- Yarn v1
yarn install
yarn devNavigate to:
http://localhost:5173/edit- Full editorhttp://localhost:5173/view- Read-only viewer
| Script | Description |
|---|---|
yarn dev |
Start development server |
yarn build |
Build library for production |
yarn test |
Run tests in watch mode |
yarn test:run |
Run tests once |
yarn lint |
Lint and fix code |
yarn format |
Format code with Prettier |
MIT License - Modell Aachen GmbH