MCPcopy Index your code
hub / github.com/simstudioai/sim / parseBaseProps

Function parseBaseProps

apps/sim/lib/pptx-renderer/model/nodes/base-node.ts:118–169  ·  view source on GitHub ↗
(spNode: SafeXmlNode)

Source from the content-addressed store, hash-verified

116 * Returns everything except `nodeType`, which the caller must set.
117 */
118export function parseBaseProps(spNode: SafeXmlNode): Omit<BaseNodeData, 'nodeType'> {
119 const { cNvPr, nvPr } = findNvProps(spNode)
120
121 const id = cNvPr.attr('id') ?? ''
122 const name = cNvPr.attr('name') ?? ''
123
124 // --- Transform ---
125 const xfrm = findXfrm(spNode)
126 const off = xfrm.child('off')
127 const ext = xfrm.child('ext')
128
129 const position: Position = {
130 x: emuToPx(off.numAttr('x') ?? 0),
131 y: emuToPx(off.numAttr('y') ?? 0),
132 }
133
134 const size: Size = {
135 w: emuToPx(ext.numAttr('cx') ?? 0),
136 h: emuToPx(ext.numAttr('cy') ?? 0),
137 }
138
139 const rotation = angleToDeg(xfrm.numAttr('rot') ?? 0)
140 const flipH = xfrm.attr('flipH') === '1' || xfrm.attr('flipH') === 'true'
141 const flipV = xfrm.attr('flipV') === '1' || xfrm.attr('flipV') === 'true'
142
143 // --- Placeholder ---
144 const placeholder = parsePlaceholder(nvPr)
145
146 // --- Shape-level hyperlink action (cNvPr > a:hlinkClick) ---
147 let hlinkClick: HlinkAction | undefined
148 const hlinkNode = cNvPr.child('hlinkClick')
149 if (hlinkNode.exists()) {
150 hlinkClick = {
151 action: hlinkNode.attr('action') ?? undefined,
152 rId: hlinkNode.attr('id') ?? hlinkNode.attr('r:id') ?? undefined,
153 tooltip: hlinkNode.attr('tooltip') ?? undefined,
154 }
155 }
156
157 return {
158 id,
159 name,
160 position,
161 size,
162 rotation,
163 flipH,
164 flipV,
165 placeholder,
166 hlinkClick,
167 source: spNode,
168 }
169}

Callers 7

parseOleFrameAsPictureFunction · 0.90
parseDiagramFrameFunction · 0.90
parseTableNodeFunction · 0.90
parseShapeNodeFunction · 0.90
parseGroupNodeFunction · 0.90
parsePicNodeFunction · 0.90
parseChartNodeFunction · 0.90

Calls 9

emuToPxFunction · 0.90
angleToDegFunction · 0.90
findNvPropsFunction · 0.85
findXfrmFunction · 0.85
parsePlaceholderFunction · 0.85
attrMethod · 0.80
childMethod · 0.80
numAttrMethod · 0.80
existsMethod · 0.80

Tested by

no test coverage detected