# gojs-extensions

Extension classes for [GoJS](https://gojs.net) — 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](https://gojs.net/learn/extensions) and used throughout the GoJS
samples. This package requires GoJS itself, which is published separately as
[`gojs`](https://www.npmjs.com/package/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

```bash
npm install gojs
npm install gojs-extensions
```

The 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:

```ts
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:

```html
<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

1. Browse the extension you want on the
   [Extensions introduction page](https://gojs.net/latest/learn/extensions) or in the
   [Samples](https://gojs.net/latest/samples#extensions).
2. Either pin your version of `gojs-extensions`, or copy the relevant file from `extensionsJSM/` (or `extensions/`) into your own source tree.
3. 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.
