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