MCPcopy Index your code
hub / github.com/codeaashu/claude-code / squashTextNodes

Function squashTextNodes

src/ink/squash-text-nodes.ts:69–90  ·  view source on GitHub ↗

* Squash text nodes into a plain string (without styles). * Used for text measurement in layout calculations.

(node: DOMElement)

Source from the content-addressed store, hash-verified

67 * Used for text measurement in layout calculations.
68 */
69function squashTextNodes(node: DOMElement): string {
70 let text = ''
71
72 for (const childNode of node.childNodes) {
73 if (childNode === undefined) {
74 continue
75 }
76
77 if (childNode.nodeName === '#text') {
78 text += childNode.nodeValue
79 } else if (
80 childNode.nodeName === 'ink-text' ||
81 childNode.nodeName === 'ink-virtual-text'
82 ) {
83 text += squashTextNodes(childNode)
84 } else if (childNode.nodeName === 'ink-link') {
85 text += squashTextNodes(childNode)
86 }
87 }
88
89 return text
90}
91
92export default squashTextNodes
93

Callers 1

measureTextNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected