fix: set header and footer data error #224

pr675
Hufe921 3 years ago
parent 1b25afb664
commit b22f0b4541

@ -93,9 +93,7 @@ export class Draw {
private options: DeepRequired<IEditorOption> private options: DeepRequired<IEditorOption>
private position: Position private position: Position
private zone: Zone private zone: Zone
private headerElementList: IElement[]
private elementList: IElement[] private elementList: IElement[]
private footerElementList: IElement[]
private listener: Listener private listener: Listener
private eventBus: EventBus<EventBusMap> private eventBus: EventBus<EventBusMap>
@ -159,9 +157,7 @@ export class Draw {
this.pagePixelRatio = null this.pagePixelRatio = null
this.mode = options.mode this.mode = options.mode
this.options = options this.options = options
this.headerElementList = data.header || []
this.elementList = data.main this.elementList = data.main
this.footerElementList = data.footer || []
this.listener = listener this.listener = listener
this.eventBus = eventBus this.eventBus = eventBus
@ -189,8 +185,8 @@ export class Draw {
this.pageNumber = new PageNumber(this) this.pageNumber = new PageNumber(this)
this.waterMark = new Watermark(this) this.waterMark = new Watermark(this)
this.placeholder = new Placeholder(this) this.placeholder = new Placeholder(this)
this.header = new Header(this) this.header = new Header(this, data.header)
this.footer = new Footer(this) this.footer = new Footer(this, data.footer)
this.hyperlinkParticle = new HyperlinkParticle(this) this.hyperlinkParticle = new HyperlinkParticle(this)
this.dateParticle = new DateParticle(this) this.dateParticle = new DateParticle(this)
this.separatorParticle = new SeparatorParticle() this.separatorParticle = new SeparatorParticle()
@ -440,7 +436,7 @@ export class Draw {
} }
public getHeaderElementList(): IElement[] { public getHeaderElementList(): IElement[] {
return this.headerElementList return this.header.getElementList()
} }
public getTableElementList(sourceElementList: IElement[]): IElement[] { public getTableElementList(sourceElementList: IElement[]): IElement[] {
@ -467,10 +463,10 @@ export class Draw {
public getOriginalElementList() { public getOriginalElementList() {
const zoneManager = this.getZone() const zoneManager = this.getZone()
if (zoneManager.isHeaderActive()) { if (zoneManager.isHeaderActive()) {
return this.header.getElementList() return this.getHeaderElementList()
} }
if (zoneManager.isFooterActive()) { if (zoneManager.isFooterActive()) {
return this.footer.getElementList() return this.getFooterElementList()
} }
return this.elementList return this.elementList
} }
@ -480,7 +476,7 @@ export class Draw {
} }
public getFooterElementList(): IElement[] { public getFooterElementList(): IElement[] {
return this.footerElementList return this.footer.getElementList()
} }
public insertElementList(payload: IElement[]) { public insertElementList(payload: IElement[]) {
@ -849,9 +845,9 @@ export class Draw {
) )
} }
const data: IEditorData = { const data: IEditorData = {
header: zipElementList(this.headerElementList), header: zipElementList(this.getHeaderElementList()),
main: zipElementList(mainElementList), main: zipElementList(mainElementList),
footer: zipElementList(this.footerElementList) footer: zipElementList(this.getFooterElementList())
} }
return { return {
version, version,

@ -16,12 +16,12 @@ export class Footer {
private rowList: IRow[] private rowList: IRow[]
private positionList: IElementPosition[] private positionList: IElementPosition[]
constructor(draw: Draw) { constructor(draw: Draw, data?: IElement[]) {
this.draw = draw this.draw = draw
this.position = draw.getPosition() this.position = draw.getPosition()
this.options = draw.getOptions() this.options = draw.getOptions()
this.elementList = draw.getFooterElementList() this.elementList = data || []
this.rowList = [] this.rowList = []
this.positionList = [] this.positionList = []
} }

@ -16,12 +16,12 @@ export class Header {
private rowList: IRow[] private rowList: IRow[]
private positionList: IElementPosition[] private positionList: IElementPosition[]
constructor(draw: Draw) { constructor(draw: Draw, data?: IElement[]) {
this.draw = draw this.draw = draw
this.position = draw.getPosition() this.position = draw.getPosition()
this.options = draw.getOptions() this.options = draw.getOptions()
this.elementList = draw.getHeaderElementList() this.elementList = data || []
this.rowList = [] this.rowList = []
this.positionList = [] this.positionList = []
} }

Loading…
Cancel
Save