Hi , I wanna use LinkLabelOnPathDraggingTool in my react-gojs-project but when I try draging linkLabel I get error diagram is null.
I read documentation and code LinkLabelOnPathDraggingTool. It is child of go.Tool. go.Tool has diagram property, but I did not find it definition neither go.Tool nor LinkLabelOnPathDraggingTool.
I use next code
import * as go from 'gojs';
import { LinkLabelOnPathDraggingTool } from 'gojs/extensionsJSM/LinkLabelOnPathDraggingTool';
const $ = go.GraphObject.make;
const MainDiagram = $(
go.Diagram,
{
'undoManager.isEnabled': true,
contentAlignment: go.Spot.Center,
model: $(go.GraphLinksModel, { linkKeyProperty: 'key' }),
},
);
MainDiagram.toolManager.mouseMoveTools.insertAt(0, new LinkLabelOnPathDraggingTool());
The extensionsJSM subdirectory holds code that is compiled to produce ES modules and to import ../release/go-module.js. But your import statement is loading the GoJS library that is a UMD module. Which module system did you want to use?
You cannot load the any library twice because that could cause very subtle errors.
You didn’t answer which module system you wanted to use.
Better yet, copy the extension file into your project and just treat it like any other code in your project, compiled and bundled and imported however you like.
If I copy extension LinkLabelOnPathDraggingTool in my directory, how I can define diagram field for LinkLabelOnPathDraggingTool. I cannot find how to define it
for example:
LinkLabelOnPathDraggingTool has findLabel() method and next code const diagram = this.diagram;
this.diagram = is not exist, because code this.diagram = ANY_DIAGRAM is lost.
That means you can’t have more than one instance of your component. OK.
Did you change the import reference not to use the ES6 module but the UMD module for the extension? As I pointed out earlier, that is a problem. Make sure all of your import statements import exactly the same GoJS library file.
OK, you’ll need to debug that then. You already have three samples demonstrating correct usage. The latter two also demonstrate using TypeScript, although it isn’t clear to me whether you are using TypeScript.