linkAttributes()
function linkAttributes(link): Attributes;
Expands the declarative React link shorthand (style, labelMap) into the
native attributes JointJS understands, so you can describe a link with the
friendly preset fields instead of raw attrs and labels.
style→ SVGattrsvia linkStyle.labelMap→ a nativelabelsarray via linkLabels.labels(array) → passed through unchanged.
Parameters
| Parameter | Type | Description |
|---|---|---|
link | LinkAttributes | The link record to convert. |
Returns
Attributes
JointJS-compatible cell attributes.
Throws
When link is not an object, or when both labelMap and labels are set on the same link.
Example
Expand the declarative preset input into native attributes and hand them to a cell model:
import { LinkModel, linkAttributes } from '@joint/react';
const link = new LinkModel(
linkAttributes({
source: { id: 'a' },
target: { id: 'b' },
style: { color: '#333', width: 2 }, // preset shorthand
labelMap: { mid: { text: 'edge', position: 0.5 } },
})
);