This example demonstrates a custom CommandHandler. It uses localStorage as the repository for the clipboard, rather than an in-memory global variable. It is defined in its own file, as LocalStorageCommandHandler.js.
Try copying and pasting between the above Diagrams, or between tabs/windows that contain Diagrams using LocalStorageCommandHandler. Note that when copying and pasting between Diagrams, it will work best if they have similar templates.
GoJS can be extended in a variety of ways. The most common way to change the standard behavior is to set properties on the GraphObject, Diagram, CommandHandler, Tool, or Layout. But when the desired property does not exist, you might need to override methods of CommandHandler, Tool, Layout, Link, or Node. Methods that you can override are documented in the API reference. Various features of GoJS can be overriden, either by replacing a method on an instance (a feature of JavaScript) or by defining a subclass. You should not modify the prototypes of any of the GoJS classes.
In addition to our samples, GoJS provides an extensions gallery,
showcasing the creation of custom tools and layouts.
Those classes and samples are written in TypeScript, available at ../extensionsJSM/
,
as ECMAScript/JavaScript modules -- these use the ../release/go-module.js
library.
We recommend that you copy the files that you need into your project, so that you can adjust how they refer to the GoJS library
that you choose and so that you can include them into your own building and packaging procedures.
More information can be found in the GoJS Intro.
Storing GoJS model data in cloud storage is an excellent way to save, load, create, and delete diagram data files without worrying about local system concerns. Interfacing with popular cloud storage services is made easy with the GoCloudStorage library. Note that this library is not pre-packaged with GoJS and can be found here.
The GoCloudStorage class system lets developers easily store their GoJS diagram model data to popular cloud storage services. The GoCloudStorage class itself is an abstract class, never to be instantiated. Instead, its subclasses are used, each interfacing with a different cloud storage service. Currently, the GoCloudStorage system supports Dropbox, Google Drive, Microsoft OneDrive, and Local Storage.
More information and demonstrations can be found in the GoJS Intro.