22 * Helper functions for processing different ADF node types
33 */
44
5- import { AdfNode } from './types.js' ;
5+ import { AdfNode } from './adf- types.util .js' ;
66
77/**
88 * Process ADF content nodes
@@ -99,7 +99,7 @@ export function processParagraph(node: AdfNode): string {
9999
100100 // Process each child node and join them with proper spacing
101101 return node . content
102- . map ( ( childNode , index ) => {
102+ . map ( ( childNode : AdfNode , index : number ) => {
103103 // Add a space between text nodes if needed
104104 const needsSpace =
105105 index > 0 &&
@@ -124,7 +124,7 @@ export function processHeading(node: AdfNode): string {
124124 const level = typeof node . attrs . level === 'number' ? node . attrs . level : 1 ;
125125 const headingMarker = '#' . repeat ( level ) ;
126126 const content = node . content
127- . map ( ( childNode ) => processAdfNode ( childNode ) )
127+ . map ( ( childNode : AdfNode ) => processAdfNode ( childNode ) )
128128 . join ( '' ) ;
129129
130130 return `${ headingMarker } ${ content } ` ;
@@ -138,7 +138,7 @@ export function processBulletList(node: AdfNode): string {
138138 return '' ;
139139 }
140140
141- return node . content . map ( ( item ) => processAdfNode ( item ) ) . join ( '\n' ) ;
141+ return node . content . map ( ( item : AdfNode ) => processAdfNode ( item ) ) . join ( '\n' ) ;
142142}
143143
144144/**
@@ -150,7 +150,7 @@ export function processOrderedList(node: AdfNode): string {
150150 }
151151
152152 return node . content
153- . map ( ( item , index ) => {
153+ . map ( ( item : AdfNode , index : number ) => {
154154 const processedItem = processAdfNode ( item ) ;
155155 // Replace the first "- " with "1. ", "2. ", etc.
156156 return processedItem . replace ( / ^ - / , `${ index + 1 } . ` ) ;
@@ -167,7 +167,7 @@ export function processListItem(node: AdfNode): string {
167167 }
168168
169169 const content = node . content
170- . map ( ( childNode ) => {
170+ . map ( ( childNode : AdfNode ) => {
171171 const processed = processAdfNode ( childNode ) ;
172172 // For nested lists, add indentation
173173 if (
@@ -176,7 +176,7 @@ export function processListItem(node: AdfNode): string {
176176 ) {
177177 return processed
178178 . split ( '\n' )
179- . map ( ( line ) => ` ${ line } ` )
179+ . map ( ( line : string ) => ` ${ line } ` )
180180 . join ( '\n' ) ;
181181 }
182182 return processed ;
@@ -196,7 +196,7 @@ export function processCodeBlock(node: AdfNode): string {
196196
197197 const language = node . attrs ?. language || '' ;
198198 const code = node . content
199- . map ( ( childNode ) => processAdfNode ( childNode ) )
199+ . map ( ( childNode : AdfNode ) => processAdfNode ( childNode ) )
200200 . join ( '' ) ;
201201
202202 return `\`\`\`${ language } \n${ code } \n\`\`\`` ;
@@ -211,13 +211,13 @@ export function processBlockquote(node: AdfNode): string {
211211 }
212212
213213 const content = node . content
214- . map ( ( childNode ) => processAdfNode ( childNode ) )
214+ . map ( ( childNode : AdfNode ) => processAdfNode ( childNode ) )
215215 . join ( '\n\n' ) ;
216216
217217 // Add > to each line
218218 return content
219219 . split ( '\n' )
220- . map ( ( line ) => `> ${ line } ` )
220+ . map ( ( line : string ) => `> ${ line } ` )
221221 . join ( '\n' ) ;
222222}
223223
@@ -230,7 +230,7 @@ export function processMediaGroup(node: AdfNode): string {
230230 }
231231
232232 return node . content
233- . map ( ( mediaNode ) => {
233+ . map ( ( mediaNode : AdfNode ) => {
234234 if ( mediaNode . type === 'media' && mediaNode . attrs ) {
235235 const { id, type } = mediaNode . attrs ;
236236 if ( type === 'file' ) {
@@ -279,18 +279,18 @@ export function processTable(node: AdfNode): string {
279279 const rows : string [ ] [ ] = [ ] ;
280280
281281 // Process table rows
282- node . content . forEach ( ( row ) => {
282+ node . content . forEach ( ( row : AdfNode ) => {
283283 if ( row . type === 'tableRow' && row . content ) {
284284 const cells : string [ ] = [ ] ;
285285
286- row . content . forEach ( ( cell ) => {
286+ row . content . forEach ( ( cell : AdfNode ) => {
287287 if (
288288 ( cell . type === 'tableCell' ||
289289 cell . type === 'tableHeader' ) &&
290290 cell . content
291291 ) {
292292 const cellContent = cell . content
293- . map ( ( cellNode ) => processAdfNode ( cellNode ) )
293+ . map ( ( cellNode : AdfNode ) => processAdfNode ( cellNode ) )
294294 . join ( '' ) ;
295295 cells . push ( cellContent . trim ( ) ) ;
296296 }
0 commit comments