feat: header,footer,page number disabled option #180
This commit is contained in:
@@ -1329,7 +1329,7 @@ export class Draw {
|
||||
|
||||
private _drawPage(payload: IDrawPagePayload) {
|
||||
const { elementList, positionList, rowList, pageNo } = payload
|
||||
const { inactiveAlpha, pageMode } = this.options
|
||||
const { inactiveAlpha, pageMode, header, footer, pageNumber } = this.options
|
||||
const innerWidth = this.getInnerWidth()
|
||||
const ctx = this.ctxList[pageNo]
|
||||
// 判断当前激活区域-非正文区域时元素透明度降低
|
||||
@@ -1351,11 +1351,17 @@ export class Draw {
|
||||
zone: EditorZone.MAIN
|
||||
})
|
||||
// 绘制页眉
|
||||
this.header.render(ctx, pageNo)
|
||||
if (!header.disabled) {
|
||||
this.header.render(ctx, pageNo)
|
||||
}
|
||||
// 绘制页码
|
||||
this.pageNumber.render(ctx, pageNo)
|
||||
if (!pageNumber.disabled) {
|
||||
this.pageNumber.render(ctx, pageNo)
|
||||
}
|
||||
// 绘制页脚
|
||||
this.footer.render(ctx, pageNo)
|
||||
if (!footer.disabled) {
|
||||
this.footer.render(ctx, pageNo)
|
||||
}
|
||||
// 搜索匹配绘制
|
||||
if (this.search.getSearchKeyword()) {
|
||||
this.search.render(ctx, pageNo)
|
||||
@@ -1402,7 +1408,7 @@ export class Draw {
|
||||
}
|
||||
|
||||
public render(payload?: IDrawOption) {
|
||||
const { pageMode } = this.options
|
||||
const { pageMode, header, footer } = this.options
|
||||
const {
|
||||
isSubmitHistory = true,
|
||||
isSetCursor = true,
|
||||
@@ -1414,9 +1420,13 @@ export class Draw {
|
||||
// 计算文档信息
|
||||
if (isCompute) {
|
||||
// 页眉信息
|
||||
this.header.compute()
|
||||
if (!header.disabled) {
|
||||
this.header.compute()
|
||||
}
|
||||
// 页脚信息
|
||||
this.footer.compute()
|
||||
if (!footer.disabled) {
|
||||
this.footer.compute()
|
||||
}
|
||||
// 行信息
|
||||
this.rowList = this.computeRowList(innerWidth, this.elementList)
|
||||
// 页面信息
|
||||
|
||||
@@ -81,7 +81,8 @@ export class Footer {
|
||||
}
|
||||
|
||||
public getFooterBottom(): number {
|
||||
const { footer: { bottom }, scale } = this.options
|
||||
const { footer: { bottom, disabled }, scale } = this.options
|
||||
if (disabled) return 0
|
||||
return Math.floor(bottom * scale)
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,8 @@ export class Header {
|
||||
}
|
||||
|
||||
public getHeaderTop(): number {
|
||||
const { header: { top }, scale } = this.options
|
||||
const { header: { top, disabled }, scale } = this.options
|
||||
if (disabled) return 0
|
||||
return Math.floor(top * scale)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,6 @@ import { MaxHeightRatio } from '../enum/Common'
|
||||
|
||||
export const defaultFooterOption: Readonly<Required<IFooter>> = {
|
||||
bottom: 30,
|
||||
maxHeightRadio: MaxHeightRatio.HALF
|
||||
maxHeightRadio: MaxHeightRatio.HALF,
|
||||
disabled: false
|
||||
}
|
||||
@@ -3,5 +3,6 @@ import { MaxHeightRatio } from '../enum/Common'
|
||||
|
||||
export const defaultHeaderOption: Readonly<Required<IHeader>> = {
|
||||
top: 30,
|
||||
maxHeightRadio: MaxHeightRatio.HALF
|
||||
maxHeightRadio: MaxHeightRatio.HALF,
|
||||
disabled: false
|
||||
}
|
||||
@@ -14,5 +14,6 @@ export const defaultPageNumberOption: Readonly<Required<IPageNumber>> = {
|
||||
color: '#000000',
|
||||
rowFlex: RowFlex.CENTER,
|
||||
format: FORMAT_PLACEHOLDER.PAGE_NO,
|
||||
numberType: NumberType.ARABIC
|
||||
numberType: NumberType.ARABIC,
|
||||
disabled: false
|
||||
}
|
||||
@@ -3,4 +3,5 @@ import { MaxHeightRatio } from '../dataset/enum/Common'
|
||||
export interface IFooter {
|
||||
bottom?: number;
|
||||
maxHeightRadio?: MaxHeightRatio;
|
||||
disabled?: boolean;
|
||||
}
|
||||
@@ -3,4 +3,5 @@ import { MaxHeightRatio } from '../dataset/enum/Common'
|
||||
export interface IHeader {
|
||||
top?: number;
|
||||
maxHeightRadio?: MaxHeightRatio;
|
||||
disabled?: boolean;
|
||||
}
|
||||
@@ -9,4 +9,5 @@ export interface IPageNumber {
|
||||
rowFlex?: RowFlex;
|
||||
format?: string;
|
||||
numberType?: NumberType;
|
||||
disabled?: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user