Changelog
All notable changes to @draw/editor. The format follows Keep a Changelog. New entries go under Unreleased.
Unreleased
Section titled “Unreleased”- Text styling.
TextStyle(fontSize,fontFamily,align),DEFAULT_TEXT_STYLE(20, hand-drawn, left) andSession.textStyle, which new text and new labels use in place of the fixed defaults. A new label is always centred, whatevertextStyle.alignis.restyleText(session, change, env)andrestyleTextSelection(editor, change, env)restyle every selected text and every selected container’s label as one history entry and fit the frames again: auto text re-measures, fixed-width text re-wraps and a container grows to fit its label. A change that alters nothing adds no entry, andrestyleTextthen returns the same session. - Live bindings.
bindEndinfeatures/bind.tsbinds an arrow end to the shape at a point withinbindingDistance(zoom)page units (15 at 100% zoom and above, 20 at zoom 0.5, at most 30). Drawing an arrow binds both ends from the first frame, and a terminal handle drag rebinds or unbinds its end.bindingHighlightreturns the target of the end being drawn or dragged, for the shell to outline.CreateGestureandHandleGesturecarry thezoomof the press, andbeginHandletakes it.createTo,finishCreateandhandleTotake anEditorEnv. - Text inside shapes (ADR 0010).
canOpenText,beginTextandstartTextaccept a rectangle, ellipse or diamond as well as a text shape, sodoubleClick(after group entry) and the Text tool edit the shape’s label.typeTextfits the frame to the label througheditLabel,editedTextreads it, andfinishTextclears the label on blank text and keeps the shape.TextEdit.createdis true for a shape that had no label, and the edit starts with an empty label so the shell can place its text box. - Groups (ADR 0009).
groupSelection,ungroupSelection,pickedGroup,membersOfandexpandPickinfeatures/group.ts, and the session commandsgroup,ungroupandenterwithSession.enteredGroup. A click selects a whole group, a double-click enters it, and a marquee selects a group only when every member is inside. Grouping nests, ungrouping removes the outermost level, and paste and duplicate mint fresh group ids through the newEditorEnv.newGroupId. - Shapes the create gestures build start with an empty
groupIds, the newShapefield (ADR 0009). - Multi-select. Shift+click adds a shape to the selection or removes it on a click release, and a Shift press on a selected shape still drags the whole set. A press on empty canvas starts the new
marqueegesture (MarqueeGesture,marqueeBox), which selects every shape whose bounds lie fully inside and adds to the selection with Shift.selectAllselects every shape.pickAttakes anadditiveflag, andMoveGesturehas an optionaldeselect. Tool.text,Session.editing,TextEdit,startText,setText,endText,doubleClickandeditedText. A press with the Text tool, or a double click on text or empty canvas, opens a text edit. Typing previews, and committing is one history entry. Blank text removes the shape, and a created shape that ends blank leaves no entry.performends an open edit first.zoomToFit,resetZoom,wheelZoomFactor,FIT_MARGINandFIT_MAX_ZOOM. Zoom to fit centres all shapes with a 48 px margin and never zooms in past 100%, like Excalidraw’s Shift+1. The wheel factor isexp(-delta / 100)with the delta clamped to 10.Pointer.zoom.pickAtandgrabAttake the zoom, and the 6 px pick and handle tolerance is now in screen pixels (6 / zoom page units).- Rotation.
RotateGesture,GestureKind.rotate,beginRotate,rotateTo,rotationHandlePoint,ROTATION_HANDLE_OFFSET(24 screen pixels, like Excalidraw) andROTATION_SNAP(15 degrees).grabAtoffers the rotation handle above the selection box except for a lone line or arrow. One shape turns about its own centre, several turn together about the centre of their bounds, and a drag is one undo step. - Package scaffold.
OrderandreorderSelection. Brings the selection forward or backward one overlapping step, or to the front or back, as one history entry. Selected shapes keep their relative order, and a reorder that changes nothing pushes no entry.Doc, a branded document of shapes and bindings keyed by id, with the ids written since its base intouched.EMPTY_DOC,putShapes,updateShapes,removeShapes,putBindingsandremoveBindingswrite it and record only what they changed.updateShapeskeeps the old object when the result is data-equal.fromShapeDocumentandtoShapeDocumentconvert to and from the serializable form.Change,Patch,diff,apply,invert,isEmptyPatchandchangedShapeIds.diffcompares records by reference and reads only touched ids, so it costs O(changes).settle, which drops dangling bindings, detaches an arrow terminal moved away from an unchanged target, and re-resolves affected bound arrows in one pass.Editor,Selection,Entry,History,CommitOptions,createEditor,preview,commit,undo,redo,selectandload. One commit is one undo step. Selection is recorded with each edit but never undone alone, andloadstarts a fresh history.Camera,View,MIN_ZOOM,MAX_ZOOM,screenToPage,pageToScreen,zoomAt,panBy,visibleBoxandvisibleShapes. The camera lives outsideEditorand the history.zoomAtkeeps the page point under the anchor fixed and clamps the zoom to 0.1 to 30.- Editing features ported from the playground: drag and ink creation, moving the selection, single and group resize, line and arrow handle drags, picking with a tolerance of 6,
restyleSelectionanddeleteSelection. Public:Tool,Pointer,EditorEnv, the gesture records (CreateGesture,InkGesture,MoveGesture,ResizeGesture,HandleGesture,DragTool,PageSample),selectionFrameandshapeHandles. copySelection,parseClip,pasteClip,duplicateSelectionandDUPLICATE_OFFSET. A copied selection is aShapeDocumentclip. A paste centres it on a page point, a duplicate offsets it by 10. Both mint fresh ids and seeds, remap or drop bindings, stack the copies on top, select them and push one history entry.Session,ActiveGesture,Gesture,GestureKind,createSession,liveEditor,pointerDown,pointerMove,pointerUp,cancel,performandrestyle. Pointer events go in and editor state comes out. A gesture previews from its base editor on every move and commits once on release.performcancels an open gesture before undo, redo or any other command.