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

Function parsePicNode

apps/sim/lib/pptx-renderer/model/nodes/pic-node.ts:35–102  ·  view source on GitHub ↗
(picNode: SafeXmlNode)

Source from the content-addressed store, hash-verified

33 * Parse a picture XML node (`p:pic`) into PicNodeData.
34 */
35export function parsePicNode(picNode: SafeXmlNode): PicNodeData {
36 const base = parseBaseProps(picNode)
37
38 // --- Blip fill ---
39 const blipFill = picNode.child('blipFill')
40 const blip = blipFill.child('blip')
41
42 // Try both namespaced and non-namespaced embed attribute
43 const blipEmbed = blip.attr('embed') ?? blip.attr('r:embed')
44 const blipLink = blip.attr('link') ?? blip.attr('r:link')
45
46 // --- Crop (srcRect) ---
47 const srcRect = blipFill.child('srcRect')
48 let crop: CropRect | undefined
49 if (srcRect.exists()) {
50 const t = srcRect.numAttr('t')
51 const b = srcRect.numAttr('b')
52 const l = srcRect.numAttr('l')
53 const r = srcRect.numAttr('r')
54 if (t !== undefined || b !== undefined || l !== undefined || r !== undefined) {
55 crop = {
56 top: (t ?? 0) / CROP_DIVISOR,
57 bottom: (b ?? 0) / CROP_DIVISOR,
58 left: (l ?? 0) / CROP_DIVISOR,
59 right: (r ?? 0) / CROP_DIVISOR,
60 }
61 }
62 }
63
64 // --- Shape properties (fill + line) ---
65 const spPr = picNode.child('spPr')
66 const solidFill = spPr.child('solidFill')
67 const gradFill = spPr.child('gradFill')
68 const fill = solidFill.exists() ? solidFill : gradFill.exists() ? gradFill : undefined
69
70 const ln = spPr.child('ln')
71 const line = ln.exists() ? ln : undefined
72
73 // --- Video / Audio detection ---
74 const nvPicPr = picNode.child('nvPicPr')
75 const nvPr = nvPicPr.child('nvPr')
76
77 const videoFile = nvPr.child('videoFile')
78 const audioFile = nvPr.child('audioFile')
79
80 const isVideo = videoFile.exists()
81 const isAudio = audioFile.exists()
82
83 let mediaRId: string | undefined
84 if (isVideo) {
85 mediaRId = videoFile.attr('link') ?? videoFile.attr('r:link')
86 } else if (isAudio) {
87 mediaRId = audioFile.attr('link') ?? audioFile.attr('r:link')
88 }
89
90 return {
91 ...base,
92 nodeType: 'picture',

Callers 3

parseTemplateShapesFunction · 0.90
parseGroupChildFunction · 0.90
parseChildNodeFunction · 0.90

Calls 5

parseBasePropsFunction · 0.90
childMethod · 0.80
attrMethod · 0.80
existsMethod · 0.80
numAttrMethod · 0.80

Tested by

no test coverage detected