import { PageActionPartial } from "../actions" ; import { KeyValueStr , TagType } from "./structureModel" ; import { UpdateStructureValues } from "./update" ; export const INSERT_STRUCTURE_NODE = "INSERT_STRUCTURE_NODE" ; export interface InsertStructureProps { tag : keyof HTMLElementTagNameMap ; tagType : TagType ; id : string ; style ? : KeyValueStr ; attributes ? : KeyValueStr ; offset : number ; length : number ; insertAfterNode ? : number ; } export interface InsertStructureAction extends PageActionPartial { tag : keyof HTMLElementTagNameMap ; tagType : TagType ; id : string ; style ? : KeyValueStr ; attributes ? : KeyValueStr ; offset : number ; length : number ; } /**
 * Action creator for `InsertStructureAction`.
 */ export const insertStructure = ( pageId , offset , length , tag , tagType , id , style ? , attributes ? ) : InsertStructureAction => ( { attributes , id , length , offset , pageId , style , tag , tagType , type : INSERT_STRUCTURE_NODE , } ) ; export const DELETE_STRUCTURE_NODE = "DELETE_STRUCTURE_NODE" ; export interface DeleteStructureAction extends PageActionPartial { nodeIndex : number ; } export const deleteStructure = ( pageId , index ) : DeleteStructureAction => ( { nodeIndex : index , pageId , type : DELETE_STRUCTURE_NODE , } ) ; export const UPDATE_STRUCTURE_NODE = "UPDATE_STRUCTURE_NODE" ; export interface UpdateStructureAction extends PageActionPartial { nodeIndex : number ; values : UpdateStructureValues ; } export const updateStructure = ( pageId , nodeIndex , values ) : UpdateStructureAction => ( { nodeIndex , pageId , type : UPDATE_STRUCTURE_NODE , values , } ) ; export const SPLIT_STRUCTURE_NODE = "SPLIT_STRUCTURE_NODE" ; export interface SplitStructureAction extends PageActionPartial { nodeIndex : number ; localOffset : number ; nodeOffset : number ; } export const splitStructureNode = ( pageId , nodeIndex , nodeOffset , localOffset ) : SplitStructureAction => ( { localOffset , nodeIndex , nodeOffset , pageId , type : SPLIT_STRUCTURE_NODE , } ) ;