(link: dia.Link | GraphLink)
| 23 | * A standard JointJS link or a JSON representation of the link. |
| 24 | */ |
| 25 | export 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. |
no test coverage detected