drawink: A Framework-Agnostic Canvas Library for Layering Annotations and Whiteboards onto Web Pages
Web apps that need annotation or whiteboard features can adopt a maintained, MIT-licensed Canvas library with a shared core and Vue/React wrappers instead of reinventing coordinate mapping, undo stacks, and export. The trade-offs it documents, like object-level erasing and full-array rendering, give an honest baseline for deciding whether the approach fits your performance budget.
drawink turns a plain container into a drawing surface that sits over existing DOM content. A document mode overlays strokes on fixed pages for annotation and teaching, while an infinite mode provides a pannable, zoomable canvas that keeps world coordinates separate from screen transforms. Both modes share the same object-driven data model: brush strokes, rectangles, circles, 3D primitives like cylinders, and custom registered shapes, all backed by undo/redo with branching history.
Integration is minimal. Install @drawink/core, @drawink/vue, or @drawink/react, mount a Drawboard with a mode option, and receive serialized drawing data through onChange. Persistence uses versioned JSON for editing and PNG export for sharing; exported images contain only the annotation layer, not the underlying page content. The library handles coordinates, component lifecycle, and StrictMode cleanup, but leaves authentication, cloud storage, and collaboration to the host application.
The design splits model, renderer, and framework adapters, and the article warns that rendering iterates over all shapes and history is stored as serialized snapshots, so large workloads need real-browser testing. Custom shapes, toolbar placement, and API-driven export cover most business integration needs.
Maintaining separate world and screen coordinates makes infinite zoom stable, but the enforced 1.5px minimum stroke width hints at a compromise to keep thin lines visible at high zoom-out.
The article's own caveat that rendering iterates all shapes and history uses serialized snapshots signals a practical ceiling: drawink suits annotation and teaching boards, not huge canvas apps with thousands of objects.
drawink's 'object eraser' trades pixel-level precision for semantic simplicity, which matches its target use of annotating lessons and documents rather than free-form image editing.
Registration of custom shapes by ID and the requirement to re-register before load indicates a deliberate design to keep serialized data small and framework-agnostic, at the cost of extra setup for host apps.