feat: add page break option
This commit is contained in:
@@ -89,5 +89,8 @@ interface ILang {
|
||||
header: string
|
||||
footer: string
|
||||
}
|
||||
pageBreak: {
|
||||
displayName: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -62,6 +62,7 @@ interface IEditorOption {
|
||||
title?: ITitleOption // Title configuration.{ defaultFirstSize?: number; defaultSecondSize?: number; defaultThirdSize?: number defaultFourthSize?: number; defaultFifthSize?: number; defaultSixthSize?: number;}
|
||||
placeholder?: IPlaceholder // Placeholder text
|
||||
group?: IGroup // Group option. {opacity?:number; backgroundColor?:string; activeOpacity?:number; activeBackgroundColor?:string; disabled?:boolean}
|
||||
pageBreak?: IPageBreak // PageBreak option。{font?:string; fontSize?:number; lineDash?:number[];}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -89,5 +89,8 @@ interface ILang {
|
||||
header: string
|
||||
footer: string
|
||||
}
|
||||
pageBreak: {
|
||||
displayName: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -62,6 +62,7 @@ interface IEditorOption {
|
||||
title?: ITitleOption // 标题配置。{ defaultFirstSize?: number; defaultSecondSize?: number; defaultThirdSize?: number defaultFourthSize?: number; defaultFifthSize?: number; defaultSixthSize?: number;}
|
||||
placeholder?: IPlaceholder // 编辑器空白占位文本
|
||||
group?: IGroup // 成组配置。{opacity?:number; backgroundColor?:string; activeOpacity?:number; activeBackgroundColor?:string; disabled?:boolean}
|
||||
pageBreak?: IPageBreak // 分页符配置。{font?:string; fontSize?:number; lineDash?:number[];}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import { DeepRequired } from '../../../interface/Common'
|
||||
import { IEditorOption } from '../../../interface/Editor'
|
||||
import { IRowElement } from '../../../interface/Row'
|
||||
import { I18n } from '../../i18n/I18n'
|
||||
import { Draw } from '../Draw'
|
||||
|
||||
export class PageBreakParticle {
|
||||
static readonly font: string = 'Yahei'
|
||||
static readonly fontSize: number = 12
|
||||
static readonly displayName: string = '分页符'
|
||||
static readonly lineDash: number[] = [3, 1]
|
||||
|
||||
private draw: Draw
|
||||
private options: Required<IEditorOption>
|
||||
private options: DeepRequired<IEditorOption>
|
||||
private i18n: I18n
|
||||
|
||||
constructor(draw: Draw) {
|
||||
this.draw = draw
|
||||
this.options = draw.getOptions()
|
||||
this.i18n = draw.getI18n()
|
||||
}
|
||||
|
||||
public render(
|
||||
@@ -22,7 +21,10 @@ export class PageBreakParticle {
|
||||
x: number,
|
||||
y: number
|
||||
) {
|
||||
const { font, fontSize, displayName, lineDash } = PageBreakParticle
|
||||
const {
|
||||
pageBreak: { font, fontSize, lineDash }
|
||||
} = this.options
|
||||
const displayName = this.i18n.t('pageBreak.displayName')
|
||||
const { scale, defaultRowMargin } = this.options
|
||||
const size = fontSize * scale
|
||||
const elementWidth = element.width!
|
||||
|
||||
@@ -69,5 +69,8 @@
|
||||
"frame": {
|
||||
"header": "Header",
|
||||
"footer": "Footer"
|
||||
},
|
||||
"pageBreak": {
|
||||
"displayName": "Page Break"
|
||||
}
|
||||
}
|
||||
@@ -69,5 +69,8 @@
|
||||
"frame": {
|
||||
"header": "页眉",
|
||||
"footer": "页脚"
|
||||
},
|
||||
"pageBreak": {
|
||||
"displayName": "分页符"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { IPageBreak } from '../../interface/PageBreak'
|
||||
|
||||
export const defaultPageBreakOption: Readonly<Required<IPageBreak>> = {
|
||||
font: 'Yahei',
|
||||
fontSize: 12,
|
||||
lineDash: [3, 1]
|
||||
}
|
||||
+8
-1
@@ -63,6 +63,8 @@ import { IGroup } from './interface/Group'
|
||||
import { defaultGroupOption } from './dataset/constant/Group'
|
||||
import { IRangeStyle } from './interface/Listener'
|
||||
import { Override } from './core/override/Override'
|
||||
import { defaultPageBreakOption } from './dataset/constant/PageBreak'
|
||||
import { IPageBreak } from './interface/PageBreak'
|
||||
|
||||
export default class Editor {
|
||||
public command: Command
|
||||
@@ -118,6 +120,10 @@ export default class Editor {
|
||||
...defaultGroupOption,
|
||||
...options.group
|
||||
}
|
||||
const pageBreakOptions: Required<IPageBreak> = {
|
||||
...defaultPageBreakOption,
|
||||
...options.pageBreak
|
||||
}
|
||||
|
||||
const editorOptions: DeepRequired<IEditorOption> = {
|
||||
mode: EditorMode.EDIT,
|
||||
@@ -168,7 +174,8 @@ export default class Editor {
|
||||
cursor: cursorOptions,
|
||||
title: titleOptions,
|
||||
placeholder: placeholderOptions,
|
||||
group: groupOptions
|
||||
group: groupOptions,
|
||||
pageBreak: pageBreakOptions
|
||||
}
|
||||
// 数据处理
|
||||
let headerElementList: IElement[] = []
|
||||
|
||||
@@ -12,6 +12,7 @@ import { IFooter } from './Footer'
|
||||
import { IGroup } from './Group'
|
||||
import { IHeader } from './Header'
|
||||
import { IMargin } from './Margin'
|
||||
import { IPageBreak } from './PageBreak'
|
||||
import { IPageNumber } from './PageNumber'
|
||||
import { IPlaceholder } from './Placeholder'
|
||||
import { ITitleOption } from './Title'
|
||||
@@ -72,6 +73,7 @@ export interface IEditorOption {
|
||||
title?: ITitleOption
|
||||
placeholder?: IPlaceholder
|
||||
group?: IGroup
|
||||
pageBreak?: IPageBreak
|
||||
}
|
||||
|
||||
export interface IEditorResult {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface IPageBreak {
|
||||
font?: string
|
||||
fontSize?: number
|
||||
lineDash?: number[]
|
||||
}
|
||||
Reference in New Issue
Block a user