feat: add table row and col size option #214

pr675
Hufe921 3 years ago
parent abcc241796
commit 8d1100cdb1

@ -44,6 +44,7 @@ interface IEditorOption {
pageMode?: PageMode; // 纸张模式:连页、分页。默认:分页
tdPadding?: number; // 单元格内边距。默认5
defaultTrMinHeight?: number; // 默认表格行最小高度。默认40
defaultColMinWidth?: number; // 默认表格列最小宽度整体宽度足够时应用否则会按比例缩小。默认40
defaultHyperlinkColor?: string; // 默认超链接颜色。默认:#0000FF
header?: IHeader; // 页眉信息。{top?:number; maxHeightRadio?:MaxHeightRatio;}
footer?: IFooter; // 页脚信息。{bottom?:number; maxHeightRadio?:MaxHeightRatio;}

@ -35,11 +35,8 @@ import { Position } from '../position/Position'
import { RangeManager } from '../range/RangeManager'
import { WorkerManager } from '../worker/WorkerManager'
export class CommandAdapt {
private readonly defaultWidth: number = 40
private draw: Draw
private range: RangeManager
private position: Position
@ -533,7 +530,7 @@ export class CommandAdapt {
for (let r = 0; r < row; r++) {
const tdList: ITd[] = []
const tr: ITr = {
height: 40,
height: this.options.defaultTrMinHeight,
tdList
}
for (let c = 0; c < col; c++) {
@ -726,7 +723,7 @@ export class CommandAdapt {
// 重新计算宽度
const colgroup = element.colgroup!
colgroup.splice(curTdIndex, 0, {
width: this.defaultWidth
width: this.options.defaultColMinWidth
})
const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0)
const width = this.draw.getOriginalInnerWidth()
@ -783,7 +780,7 @@ export class CommandAdapt {
// 重新计算宽度
const colgroup = element.colgroup!
colgroup.splice(curTdIndex, 0, {
width: this.defaultWidth
width: this.options.defaultColMinWidth
})
const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0)
const width = this.draw.getOriginalInnerWidth()

@ -125,6 +125,7 @@ export default class Editor {
pageMode: PageMode.PAGING,
tdPadding: 5,
defaultTrMinHeight: 40,
defaultColMinWidth: 40,
defaultHyperlinkColor: '#0000FF',
paperDirection: PaperDirection.VERTICAL,
inactiveAlpha: 0.6,

@ -48,6 +48,7 @@ export interface IEditorOption {
pageMode?: PageMode;
tdPadding?: number;
defaultTrMinHeight?: number;
defaultColMinWidth?: number;
defaultHyperlinkColor?: string;
paperDirection?: PaperDirection;
inactiveAlpha?: number;

Loading…
Cancel
Save