ScribbleSVG

Changelog

Recent ScribbleSVG package versions

Package versions in this monorepo (see each package’s package.json for the source of truth):

PackageVersion
@scribblesvg/core0.2.3
@scribblesvg/react-utils0.2.6
docs site0.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 onChange fires 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 freedraw element 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_ELEMENT takes an optional select (default true). With select: false it clears the selection and keeps the current tool, which is how each pencil stroke is placed.
  • Behaviour change for embedders: DiagramElement and ToolType each gain a member (freedraw, pencil), so an exhaustive switch over either needs a new case. isBindable now returns false for strokes. CanvasState gains pencilSmoothing.

Element groups:

  • Elements can be grouped: new optional groupId on 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 autoFocus prop on DiagramCanvas focuses the canvas on mount, so shortcuts work before the first click
  • The canvas shows a focus ring for keyboard focus (:focus-visible in editor.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 useCanvasInteraction users: 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; DiagramCanvas wires 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 fitOnLoad prop on DiagramCanvas frames the initial document on mount (default keeps the saved viewport)
  • fitViewport, MIN_ZOOM and MAX_ZOOM are 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: CanvasState has size and fitPending, and the new RESIZE action sets the size (and fits the content on the first one when fitPending). useCanvasReducer(document, { fitOnLoad }) sets fitPending

  • New reducer actions for events that used to read refs: ZOOM_AT (wheel and pinch zoom around the pointer), PAN_BY (wheel scroll) and INSERT_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_HISTORY closes an open BEGIN_HISTORY group and puts back the elements and selection from when it began, leaving no undo step

  • Breaking for direct useCanvasInteraction users: the hook reads the canvas size from state.size, so its containerSize argument is gone: call useCanvasInteraction(state, dispatch, svgRef, icons)

  • Placement uses one PLACE_ELEMENT transition (also shared by INSERT_IMAGE); SELECT_ELEMENT selects an existing element and switches tools. Undo restores the previous elements and selection, including grouped creation.

  • Drag, resize and group-scale use UPDATE_ELEMENTS.reanchor to update bound connectors from current reducer state. Pointer-up no longer writes anchors from a potentially older render.

  • Breaking for direct users: removed useElementDrag and useElementResize. Use the exported pure startDrag / dragPatches and startResize / startGroupScale / resizePatches helpers; store their sessions in Gesture, dispatch BEGIN_HISTORY on start, UPDATE_ELEMENTS with reanchor: true on moves, and END_HISTORY on release. resizePatches accepts a fourth text-measurement argument for host glyph metrics. The unused isDragging / isResizing callbacks and duplicate refs are gone.

  • Connector previews are derived from start, pointer, snapping threshold and Shift inputs against current elements. useArrowCreation keeps its existing returns and adds setShiftSnap plus an optional third (current snap threshold) argument. useCanvasInteraction.setShiftSnap still 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, and TEXT_CHAR_WIDTH for 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/core in 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 DiagramCanvas editor and DiagramRenderer read-only view
  • Icon catalog via iconId + consumer icons array
  • Color presets for the renderer
  • Fumadocs documentation site (docs/)

On this page