ngDiagram v1.3.0 - Awaitable API, Cancelable Gestures & 15+ Stability Fixes #791
lukasz-jazwa
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
We're excited to announce ngDiagram v1.3.0, one of our biggest releases so far, focused on stability and control! 🚀
Awaitable API ⏳
Every mutating method on the public services (
NgDiagramModelService,NgDiagramNodeService,NgDiagramSelectionService,NgDiagramClipboardService,NgDiagramGroupsService,NgDiagramViewportService) now returns aPromise<void>that resolves once the change has been applied to the model. The next line of code reads the updated state:Need real dimensions, for example before
zoomToFit()orcenterOnNode()? Pass{ waitForMeasurements: true }directly to the method:transaction()andinvalidateMeasurements()are awaitable too: everytransaction()overload now returns the commit promise, andinvalidateMeasurements()resolves once the triggered re-measurements have settled.No breaking changes: the return types changed from
voidtoPromise<void>, so existing call sites keep working and ignoring the promise is fine. One caveat: do not await these promises from inside a middleware, the update pipeline is not re-entrant. Fire-and-forget calls are safe there.Cancel gestures ⌨️
The new
NgDiagramService.cancelActiveInteraction()aborts the active drag, resize, rotate, linking or pan gesture and restores the pre-gesture state: dragged nodes snap back, resized and rotated nodes regain their original geometry, and the temporary edge is discarded. It's bound to Escape by default via the newcancelInteractionshortcut action.To let you react to cancellations,
edgeDrawEndedgains acancelledreason, andnodeDragEnded,nodeResizeEndedandnodeRotateEndedgain an optionalcancelReasonfield.Resize control 📐
Two new ways to fine-tune resizing:
activeSidesinput onng-diagram-node-resize-adornmentlimits which sides of a node can be grabbed, for example[activeSides]="['right', 'bottom']"for a node anchored at its top-left corner. Omitting the input keeps all four sides active, so existing templates are unaffected.computeSnapOffsetForNodeSizeanddefaultResizeSnapOffsetoptions onSnappingConfig, snapped node sizes follow the sequenceoffset + n * snapper axis. A node with a 60px header and a 50px vertical snap can now snap to 60, 110, 160 instead of 50, 100, 150.Public default edge label 🧩
NgDiagramDefaultEdgeLabelComponentis now exported from the package, so custom edge templates can compose it insideng-diagram-base-edge-labeland reuse the default label look: theme-aware chip, hover and selection highlights included. The new--edge-label-border-color-hoverand--edge-label-border-color-selectedCSS variables let you override the highlight colors.Stability: 15+ fixes 🛡️
This release puts a lot of work into making the update pipeline and gestures predictable:
The full list is in the changelog.
Growing with the Community
Big thanks to @logan-brd for the reports, reproductions and suggestions that shaped parts of this release! 🙏
If you're building with ngDiagram, we'd love to hear about it. Share your project, ask questions, or just say hi in Discord or right here in Discussions.
Links:
All reactions