Skip to content

Commit

Permalink
fix: set header and footer data error #224
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Jul 31, 2023
1 parent 1b25afb commit b22f0b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
20 changes: 8 additions & 12 deletions src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ export class Draw {
private options: DeepRequired<IEditorOption>
private position: Position
private zone: Zone
private headerElementList: IElement[]
private elementList: IElement[]
private footerElementList: IElement[]
private listener: Listener
private eventBus: EventBus<EventBusMap>

Expand Down Expand Up @@ -159,9 +157,7 @@ export class Draw {
this.pagePixelRatio = null
this.mode = options.mode
this.options = options
this.headerElementList = data.header || []
this.elementList = data.main
this.footerElementList = data.footer || []
this.listener = listener
this.eventBus = eventBus

Expand Down Expand Up @@ -189,8 +185,8 @@ export class Draw {
this.pageNumber = new PageNumber(this)
this.waterMark = new Watermark(this)
this.placeholder = new Placeholder(this)
this.header = new Header(this)
this.footer = new Footer(this)
this.header = new Header(this, data.header)
this.footer = new Footer(this, data.footer)
this.hyperlinkParticle = new HyperlinkParticle(this)
this.dateParticle = new DateParticle(this)
this.separatorParticle = new SeparatorParticle()
Expand Down Expand Up @@ -440,7 +436,7 @@ export class Draw {
}

public getHeaderElementList(): IElement[] {
return this.headerElementList
return this.header.getElementList()
}

public getTableElementList(sourceElementList: IElement[]): IElement[] {
Expand All @@ -467,10 +463,10 @@ export class Draw {
public getOriginalElementList() {
const zoneManager = this.getZone()
if (zoneManager.isHeaderActive()) {
return this.header.getElementList()
return this.getHeaderElementList()
}
if (zoneManager.isFooterActive()) {
return this.footer.getElementList()
return this.getFooterElementList()
}
return this.elementList
}
Expand All @@ -480,7 +476,7 @@ export class Draw {
}

public getFooterElementList(): IElement[] {
return this.footerElementList
return this.footer.getElementList()
}

public insertElementList(payload: IElement[]) {
Expand Down Expand Up @@ -849,9 +845,9 @@ export class Draw {
)
}
const data: IEditorData = {
header: zipElementList(this.headerElementList),
header: zipElementList(this.getHeaderElementList()),
main: zipElementList(mainElementList),
footer: zipElementList(this.footerElementList)
footer: zipElementList(this.getFooterElementList())
}
return {
version,
Expand Down
4 changes: 2 additions & 2 deletions src/editor/core/draw/frame/Footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export class Footer {
private rowList: IRow[]
private positionList: IElementPosition[]

constructor(draw: Draw) {
constructor(draw: Draw, data?: IElement[]) {
this.draw = draw
this.position = draw.getPosition()
this.options = draw.getOptions()

this.elementList = draw.getFooterElementList()
this.elementList = data || []
this.rowList = []
this.positionList = []
}
Expand Down
4 changes: 2 additions & 2 deletions src/editor/core/draw/frame/Header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export class Header {
private rowList: IRow[]
private positionList: IElementPosition[]

constructor(draw: Draw) {
constructor(draw: Draw, data?: IElement[]) {
this.draw = draw
this.position = draw.getPosition()
this.options = draw.getOptions()

this.elementList = draw.getHeaderElementList()
this.elementList = data || []
this.rowList = []
this.positionList = []
}
Expand Down

0 comments on commit b22f0b4

Please sign in to comment.