MCPcopy
hub / github.com/clientIO/joint / processLink

Function processLink

packages/joint-react/src/utils/cell/set-cells.ts:25–46  ·  view source on GitHub ↗
(link: dia.Link | GraphLink)

Source from the content-addressed store, hash-verified

23 * A standard JointJS link or a JSON representation of the link.
24 */
25export function processLink(link: dia.Link | GraphLink): dia.Link | dia.Cell.JSON {
26 if (isLinkInstance(link)) {
27 const json = link.toJSON();
28
29 const source = getTargetOrSource(json.source);
30 const target = getTargetOrSource(json.target);
31 return {
32 ...json,
33 source,
34 target,
35 };
36 }
37
38 const source = getTargetOrSource(link.source);
39 const target = getTargetOrSource(link.target);
40 return {
41 ...link,
42 type: link.type ?? 'standard.Link',
43 source,
44 target,
45 } as dia.Cell.JSON;
46}
47
48/**
49 * Set links to the graph.

Callers 2

useCreateLinkFunction · 0.90
setLinksFunction · 0.85

Calls 3

isLinkInstanceFunction · 0.90
getTargetOrSourceFunction · 0.90
toJSONMethod · 0.80

Tested by

no test coverage detected