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

Function processElement

packages/joint-react/src/utils/cell/set-cells.ts:87–110  ·  view source on GitHub ↗
(
  element: T,
  unsizedIds?: Set<string>
)

Source from the content-addressed store, hash-verified

85 * @private
86 */
87export function processElement<T extends dia.Element | GraphElement>(
88 element: T,
89 unsizedIds?: Set<string>
90): dia.Element | dia.Cell.JSON {
91 const stringId = String(element.id);
92 if (isCellInstance(element)) {
93 const size = element.size();
94 if (isReactElement(element) && isUnsized(size.width, size.height)) {
95 unsizedIds?.add(stringId);
96 }
97 return element;
98 }
99 const { type = REACT_TYPE, x, y, width, height } = element;
100 if (isUnsized(width, height)) {
101 unsizedIds?.add(stringId);
102 }
103
104 return {
105 type,
106 position: { x, y },
107 size: { width, height },
108 ...element,
109 } as dia.Cell.JSON;
110}
111/**
112 * Set elements to the graph.
113 * @param options - The options for setting elements.

Callers 2

useCreateElementFunction · 0.90
setElementsFunction · 0.85

Calls 4

isCellInstanceFunction · 0.90
isReactElementFunction · 0.90
isUnsizedFunction · 0.90
addMethod · 0.80

Tested by

no test coverage detected