Put the canvas in your own page.

SlateboxJS draws an editable SVG diagram inside an element of your page. Your code adds notes and arrows, people move and rename them, and one call gives you the whole slate as a string to store wherever you like.

The button opens the same two notes in the hosted app, drawn from one typed line. The library itself needs no account. Run the quickstart in the docs ↗

import { Slate } from 'slateboxjs'
import 'slateboxjs/style.css'

const slate = new Slate('#board',
  { name: 'Listening bench' })

const evidence = slate.addNode({
  ...note, ...sand, id: 'evidence',
  x: 0, y: 0,
  text: 'Visitors stop\nto listen',
})

const decision = slate.addNode({
  ...note, ...mint, id: 'decision',
  x: 250, y: 110,
  text: 'Set a bench\nby the speaker',
})
await Promise.all(
  [evidence.ready, decision.ready])

evidence.relationships.addAssociation(
  decision,
  { ...arrow, id: 'evidence-decision' })

const saved = slate.exportJSON()
const { nodes } = JSON.parse(saved)
print(nodes.length + ' notes saved')

await slate.loadJSON(saved)
const drawn = slate.getAllNodes()
print(drawn.length + ' notes drawn again')

How it works

An element, some notes, a string.

  1. Give it an element

    new Slate('#board', { name }) turns an element with a visible height into a canvas. The quickstart in the docs is one HTML file that imports the browser module and its stylesheet.

  2. Add notes and arrows

    slate.addNode(options) returns the note. note.relationships.addAssociation(other) draws the arrow. Give a note a stable id and slate.getNode(id) finds it again.

  3. Let people edit

    Dragging, renaming and connecting come with the canvas. Your code can do the same with position, setText and setColors.

  4. Save and load

    slate.exportJSON() returns a string. await slate.loadJSON(saved) draws it again. Call slate.destroy() when the view goes away.

Native workshops

A workshop is notes on the same slate.

Give attachWorkshop the slate you already have and a workshop model. Lanes and cards are drawn as real notes beside your own, with the slate’s pan and zoom. The model stays the one saved source of truth.

In version 3.1.3 of the library
import { attachWorkshop }
  from 'slateboxjs/workshops/model'

const board = attachWorkshop(slate, model, {
  origin: { x: 260, y: 0 },
  onChange(next) { save(next) },
  onRefuse({ reason }) { toast(reason) },
})
A move
A card dropped in a lane that has room commits, and onChange gets the new model.
A refusal
A drop the rules close glides back. The lane shows the reason for about a second and a half, and onRefuse gets the sentence.
Your export
slate.exportJSON() never contains the workshop’s notes. They are a drawing of the model.

The library draws. Your application keeps the data.

SlateboxJS creates objects in the page. Where a slate is stored, who may open it and who is on a call belong to the application around it.

A string
exportJSON() gives the slate as text. Put it in your own database, a file or the browser’s storage.
An image
slate.svg() returns SVG markup of the board, and await slate.png() renders a raster export.
A frame
slate.fitToContent() frames everything on the board after your code has drawn it.
A hosted slate
To change a slate that lives in the Slatebox app, use the HTTP API instead.

The plan this needs.

Free
None. The library is MIT licensed and runs in your page without an account or a key.
Nothing more is needed for this. Plans are for the hosted app.
Compare plans

Next

Two notes and an arrow, in one file.

The quickstart is a single HTML file. Move the notes, rename one, then save and reload to see the same map.