Skip to content

When iterating over a layoutList, the page iterator moves on to layoutText after iterating over each individual list item #177

Description

@rsanaie

When I'm traversing a layout object, after visiting a layout list, the iterator then moves on to individual list items, causing duplication of nodes visited. Is this intended?

This happens in .html() function as well. I know that you can use the childBlockIds of LayoutList to mark down which nodes have been visited and skip them later, but wanted to confirm this behaviour.

Thank you, you guys are awesome!

const ignoredBlocks: ApiBlockType[] = [
    ApiBlockType.LayoutHeader, 
    ApiBlockType.LayoutFooter,
    ApiBlockType.LayoutPageNumber
]

for (const page of doc.iterPages()) {
    for (const layItem of page.layout.iterItems()) {
        if (!ignoredBlocks.includes(layItem.blockType)) {
            console.log(layItem.blockType)
            console.log(layItem.text + "\n")
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjavascriptRelates to the JavaScript/TypeScript version of TRP

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions