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