import { PageContent , Color } from "../pageModel" ; import { StructureNode } from "./structureModel" ; import { SENTINEL_INDEX } from "../tree/tree" ; import { insertNode , fixInsert } from "../tree/insert" ; import { InsertStructureProps } from "./actions" ; param page param insertStructureAction export function insertStructureNode ( page , insertStructureAction ) { const { attributes , id , style , tag , tagType , offset , length , insertAfterNode , } = insertStructureAction ; const newNode = { color : Color . Red , id , left : SENTINEL_INDEX , leftSubTreeLength : 0 , length , parent : SENTINEL_INDEX , right : SENTINEL_INDEX , tag , tagType , } ; if ( style ) { newNode . style = style ; } if ( attributes ) { newNode . attributes = attributes ; } insertNode ( page . structure , newNode , offset , insertAfterNode ) ; fixInsert ( page . structure , page . structure . nodes . length - 1 ) ; }