Changelog
Recent ScribbleSVG package versions
Package versions in this monorepo (see each package’s package.json for the source of truth):
| Package | Version |
|---|---|
@scribblesvg/core | 0.2.3 |
@scribblesvg/react-utils | 0.2.6 |
| docs site | 0.2.1 |
Unreleased
Freehand pencil:
- New pencil tool in the editor toolbar. Each press-drag draws one stroke, and the tool stays active between strokes. Like dragging out a shape, the stroke is in the document from the press and
onChangefires as it grows; it is one undo step. - While the pencil is active, a toggle beside it turns smoothing on or off. It starts on each time the editor mounts. Smoothing evens out hand wobble and keeps deliberate corners sharp.
- New
freedrawelement type in@scribblesvg/core:points: [number, number][]in canvas coordinates, drawn as one smooth path without Rough.js. Strokes can be selected, moved, resized, group-scaled, copied and pasted. They have no label, and connectors don't bind to them. - New core type export:
FreedrawElement. Stroke smoothing and path building stay internal. - Escape while drawing drops the stroke in progress and leaves nothing to undo.
PLACE_ELEMENTtakes an optionalselect(default true). Withselect: falseit clears the selection and keeps the current tool, which is how each pencil stroke is placed.- Behaviour change for embedders:
DiagramElementandToolTypeeach gain a member (freedraw,pencil), so an exhaustiveswitchover either needs a new case.isBindablenow returns false for strokes.CanvasStategainspencilSmoothing.
Element groups:
- Elements can be grouped: new optional
groupIdon every element, validated by core. Documents without it load as before - Ctrl/⌘ + G groups the selection (merging any groups in it) and Ctrl/⌘ + Shift + G ungroups it, each one undo step
- Clicking, Shift-clicking or box-selecting a member selects its whole group; double-clicking a member of the selected group selects just that member, and the next click edits its text
- Pasting a group gives the copy its own new group
- A selected group is drawn as one box instead of a box per member, so grouping and ungrouping show on screen. A selection of several groups outlines each group once
Keyboard shortcuts are scoped to the focused editor:
- Behaviour change for embedders: shortcuts no longer work without focus. They used to listen on
window, so keys typed anywhere on the page (a form field, a second editor) could edit the diagram. Now they only apply while focus is inside the editor; pressing the canvas or a toolbar button gives it focus. - New
autoFocusprop onDiagramCanvasfocuses the canvas on mount, so shortcuts work before the first click - The canvas shows a focus ring for keyboard focus (
:focus-visibleineditor.css) - Focus leaving the editor clears the selection (switching windows or tabs keeps it)
- A Space or Shift held when focus leaves the editor is released, so panning and snapping can't stay stuck on
- The shortcuts panel is generated from the same keymap as the keys, so it can't drift
- Breaking for direct
useCanvasInteractionusers: the hook no longer listens for keys. It returns the commands (handleDelete,handleCopy,handleCut,handlePaste,stepSelectionFontSize,cancelGesture,setSpaceHeld,setShiftSnap,releaseHeldKeys) for your own key handler;DiagramCanvaswires them up for you - Ctrl+Y no longer redoes on macOS (use ⌘⇧Z), matching the shortcuts panel
Zoom controls in the editor:
- A zoom card in the bottom-right of the canvas replaces the zoom % in the header: a log-scale slider (10–500%, soft stop at 100%), Zoom to fit, and a reset button that shows the live % and is highlighted when zoom isn't 100%
- New keys while the editor has focus: Ctrl/⌘ +
+/-step through 10, 25, 50, 75, 100, 150, 200, 300, 400, 500%; Shift+1 zooms to fit; Shift+0 resets to 100% - Zoom to fit frames all content and never zooms in past 100%
- New
fitOnLoadprop onDiagramCanvasframes the initial document on mount (default keeps the saved viewport) fitViewport,MIN_ZOOMandMAX_ZOOMare exported from@scribblesvg/react-utils/editor- The "Skipped invalid icons" notice moved to the bottom-left of the canvas, clear of the zoom card
Editor state in one place, for direct users of the reducer and hooks (DiagramCanvas works as before):
-
The canvas size is reducer state:
CanvasStatehassizeandfitPending, and the newRESIZEaction sets the size (and fits the content on the first one whenfitPending).useCanvasReducer(document, { fitOnLoad })setsfitPending -
New reducer actions for events that used to read refs:
ZOOM_AT(wheel and pinch zoom around the pointer),PAN_BY(wheel scroll) andINSERT_IMAGE(place, select and switch to the select tool in one step). Quick wheel events between renders now all count instead of some reading a stale viewport -
New reducer action
CANCEL_HISTORYcloses an openBEGIN_HISTORYgroup and puts back the elements and selection from when it began, leaving no undo step -
Breaking for direct
useCanvasInteractionusers: the hook reads the canvas size fromstate.size, so itscontainerSizeargument is gone: calluseCanvasInteraction(state, dispatch, svgRef, icons) -
Placement uses one
PLACE_ELEMENTtransition (also shared byINSERT_IMAGE);SELECT_ELEMENTselects an existing element and switches tools. Undo restores the previous elements and selection, including grouped creation. -
Drag, resize and group-scale use
UPDATE_ELEMENTS.reanchorto update bound connectors from current reducer state. Pointer-up no longer writes anchors from a potentially older render. -
Breaking for direct users: removed
useElementDraganduseElementResize. Use the exported purestartDrag/dragPatchesandstartResize/startGroupScale/resizePatcheshelpers; store their sessions inGesture, dispatchBEGIN_HISTORYon start,UPDATE_ELEMENTSwithreanchor: trueon moves, andEND_HISTORYon release.resizePatchesaccepts a fourth text-measurement argument for host glyph metrics. The unusedisDragging/isResizingcallbacks and duplicate refs are gone. -
Connector previews are derived from start, pointer, snapping threshold and Shift inputs against current elements.
useArrowCreationkeeps its existing returns and addssetShiftSnapplus an optional third (current snap threshold) argument.useCanvasInteraction.setShiftSnapstill re-snaps without pointer movement; leaving connector tools cancels creation.
0.2.3 / 0.2.6
Editor and geometry improvements:
- Shift + draw snaps arrows/lines to 22.5° steps via
constrainToStraightAngle - Standalone text bounds hug live glyph metrics (selection, resize, and font-size changes stay in sync)
- Core exports
measureTextSize,TEXT_LINE_HEIGHT, andTEXT_CHAR_WIDTHfor shared text sizing - Font-size control and inline text editing resize with content
0.2.2 / 0.2.5
Made the libraries lighter:
- Dropped Zod from
@scribblesvg/corein favor of hand-rolled validation - Removed lucide-react from
@scribblesvg/react-utils; toolbar icons are in-house SVGs
0.2.x
- Core document model with scribble-style rendering (Rough.js)
- React
DiagramCanvaseditor andDiagramRendererread-only view - Icon catalog via
iconId+ consumericonsarray - Color presets for the renderer
- Fumadocs documentation site (
docs/)