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

Function extractTextFromCanvasLayout

apps/sim/tools/sharepoint/utils.ts:43–103  ·  view source on GitHub ↗
(canvasLayout: CanvasLayout | null | undefined)

Source from the content-addressed store, hash-verified

41}
42
43export function extractTextFromCanvasLayout(canvasLayout: CanvasLayout | null | undefined): string {
44 logger.info('Extracting text from canvas layout', {
45 hasCanvasLayout: !!canvasLayout,
46 hasHorizontalSections: !!canvasLayout?.horizontalSections,
47 sectionsCount: canvasLayout?.horizontalSections?.length || 0,
48 })
49
50 if (!canvasLayout?.horizontalSections) {
51 logger.info('No canvas layout or horizontal sections found')
52 return ''
53 }
54
55 const textParts: string[] = []
56
57 for (const section of canvasLayout.horizontalSections) {
58 logger.info('Processing section', {
59 sectionId: section.id,
60 hasColumns: !!section.columns,
61 hasWebparts: !!section.webparts,
62 columnsCount: section.columns?.length || 0,
63 })
64
65 if (section.columns) {
66 for (const column of section.columns) {
67 if (column.webparts) {
68 for (const webpart of column.webparts) {
69 logger.info('Processing webpart', {
70 webpartId: webpart.id,
71 hasInnerHtml: !!webpart.innerHtml,
72 innerHtml: webpart.innerHtml,
73 })
74
75 if (webpart.innerHtml) {
76 const text = stripHtmlTags(webpart.innerHtml)
77 if (text) {
78 textParts.push(text)
79 logger.info('Extracted text', { text })
80 }
81 }
82 }
83 }
84 }
85 } else if (section.webparts) {
86 for (const webpart of section.webparts) {
87 if (webpart.innerHtml) {
88 const text = stripHtmlTags(webpart.innerHtml)
89 if (text) textParts.push(text)
90 }
91 }
92 }
93 }
94
95 const finalContent = textParts.join('\n\n')
96 logger.info('Final extracted content', {
97 textPartsCount: textParts.length,
98 finalContentLength: finalContent.length,
99 finalContent,
100 })

Callers 1

read_page.tsFile · 0.90

Calls 4

infoMethod · 0.80
joinMethod · 0.80
stripHtmlTagsFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected