gojs-extensions
v4.0.2
Published
GoJS extension classes (tools, layouts, figures, and more) for the gojs diagramming library
Readme
gojs-extensions
Extension classes for GoJS — custom tools, layouts, links, figures, and other reusable components that build on the main GoJS diagramming library.
These are the same extensions documented on the
Extensions introduction page and used throughout the GoJS
samples. This package requires GoJS itself, which is published separately as
gojs.
In production, we recommend you copy the extension code
Extensions are not part of the core GoJS API. Their behavior and API may change with any version, even point releases. If you intend to use an extension in production, you should either pin the version or copy its source into your own project and maintain it there, rather than importing it from this package as a long-lived dependency.
Every extension file repeats this guidance in its own header comment. Treat this package as a convenient, versioned source of extension code to read, learn from, and copy.
Installation
npm install gojs
npm install gojs-extensionsThe package contains two parallel copies of every extension:
| Folder | Format | Use when |
| ---------------- | --------------------------------- | --------------------------------------------------------- |
| extensionsJSM/ | ES modules (.ts source + .js) | Using import go from 'gojs' |
| extensions/ | Plain browser scripts (.js) | Loading GoJS from a <script> tag to use the global go |
The extensionsJSM/ files are the TypeScript source of truth; the extensions/ files
are the same classes with the import/export statements stripped for use as globals.
Usage
As ES modules (extensionsJSM/)
Each extension imports GoJS from 'gojs' and exports its class:
import * as go from 'gojs';
import { BalloonLink } from 'gojs-extensions/extensionsJSM/BalloonLink';
const diagram = new go.Diagram('myDiagramDiv');
diagram.linkTemplate = new BalloonLink(/* ... */);As plain browser scripts (extensions/)
Load go.js first, then the extension script; the class is added to the global scope:
<script src="https://cdn.jsdelivr.net/npm/gojs/release/go.js"></script>
<script src="path/to/gojs-extensions/extensions/BalloonLink.js"></script>
<script>
const diagram = new go.Diagram('myDiagramDiv');
diagram.linkTemplate = new BalloonLink(/* ... */);
</script>Recommended workflow
- Browse the extension you want on the Extensions introduction page or in the Samples.
- Either pin your version of
gojs-extensions, or copy the relevant file fromextensionsJSM/(orextensions/) into your own source tree. - If copied, further adapt it as your own code.
Links
- GoJS website: https://gojs.net
- Extensions introduction page: https://gojs.net/latest/learn/extensions
- Samples: https://gojs.net/latest/samples
- Support: https://nwoods.com/support
- Forum: https://forum.nwoods.com/c/gojs
License
See license.html. GoJS and Northwoods Software are registered trademarks of Northwoods
Software Corporation.
