feat: add table row and col size option #214
This commit is contained in:
@@ -44,6 +44,7 @@ interface IEditorOption {
|
|||||||
pageMode?: PageMode; // 纸张模式:连页、分页。默认:分页
|
pageMode?: PageMode; // 纸张模式:连页、分页。默认:分页
|
||||||
tdPadding?: number; // 单元格内边距。默认:5
|
tdPadding?: number; // 单元格内边距。默认:5
|
||||||
defaultTrMinHeight?: number; // 默认表格行最小高度。默认:40
|
defaultTrMinHeight?: number; // 默认表格行最小高度。默认:40
|
||||||
|
defaultColMinWidth?: number; // 默认表格列最小宽度(整体宽度足够时应用,否则会按比例缩小)。默认:40
|
||||||
defaultHyperlinkColor?: string; // 默认超链接颜色。默认:#0000FF
|
defaultHyperlinkColor?: string; // 默认超链接颜色。默认:#0000FF
|
||||||
header?: IHeader; // 页眉信息。{top?:number; maxHeightRadio?:MaxHeightRatio;}
|
header?: IHeader; // 页眉信息。{top?:number; maxHeightRadio?:MaxHeightRatio;}
|
||||||
footer?: IFooter; // 页脚信息。{bottom?:number; maxHeightRadio?:MaxHeightRatio;}
|
footer?: IFooter; // 页脚信息。{bottom?:number; maxHeightRadio?:MaxHeightRatio;}
|
||||||
|
|||||||
@@ -35,11 +35,8 @@ import { Position } from '../position/Position'
|
|||||||
import { RangeManager } from '../range/RangeManager'
|
import { RangeManager } from '../range/RangeManager'
|
||||||
import { WorkerManager } from '../worker/WorkerManager'
|
import { WorkerManager } from '../worker/WorkerManager'
|
||||||
|
|
||||||
|
|
||||||
export class CommandAdapt {
|
export class CommandAdapt {
|
||||||
|
|
||||||
private readonly defaultWidth: number = 40
|
|
||||||
|
|
||||||
private draw: Draw
|
private draw: Draw
|
||||||
private range: RangeManager
|
private range: RangeManager
|
||||||
private position: Position
|
private position: Position
|
||||||
@@ -533,7 +530,7 @@ export class CommandAdapt {
|
|||||||
for (let r = 0; r < row; r++) {
|
for (let r = 0; r < row; r++) {
|
||||||
const tdList: ITd[] = []
|
const tdList: ITd[] = []
|
||||||
const tr: ITr = {
|
const tr: ITr = {
|
||||||
height: 40,
|
height: this.options.defaultTrMinHeight,
|
||||||
tdList
|
tdList
|
||||||
}
|
}
|
||||||
for (let c = 0; c < col; c++) {
|
for (let c = 0; c < col; c++) {
|
||||||
@@ -726,7 +723,7 @@ export class CommandAdapt {
|
|||||||
// 重新计算宽度
|
// 重新计算宽度
|
||||||
const colgroup = element.colgroup!
|
const colgroup = element.colgroup!
|
||||||
colgroup.splice(curTdIndex, 0, {
|
colgroup.splice(curTdIndex, 0, {
|
||||||
width: this.defaultWidth
|
width: this.options.defaultColMinWidth
|
||||||
})
|
})
|
||||||
const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0)
|
const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0)
|
||||||
const width = this.draw.getOriginalInnerWidth()
|
const width = this.draw.getOriginalInnerWidth()
|
||||||
@@ -783,7 +780,7 @@ export class CommandAdapt {
|
|||||||
// 重新计算宽度
|
// 重新计算宽度
|
||||||
const colgroup = element.colgroup!
|
const colgroup = element.colgroup!
|
||||||
colgroup.splice(curTdIndex, 0, {
|
colgroup.splice(curTdIndex, 0, {
|
||||||
width: this.defaultWidth
|
width: this.options.defaultColMinWidth
|
||||||
})
|
})
|
||||||
const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0)
|
const colgroupWidth = colgroup.reduce((pre, cur) => pre + cur.width, 0)
|
||||||
const width = this.draw.getOriginalInnerWidth()
|
const width = this.draw.getOriginalInnerWidth()
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ export default class Editor {
|
|||||||
pageMode: PageMode.PAGING,
|
pageMode: PageMode.PAGING,
|
||||||
tdPadding: 5,
|
tdPadding: 5,
|
||||||
defaultTrMinHeight: 40,
|
defaultTrMinHeight: 40,
|
||||||
|
defaultColMinWidth: 40,
|
||||||
defaultHyperlinkColor: '#0000FF',
|
defaultHyperlinkColor: '#0000FF',
|
||||||
paperDirection: PaperDirection.VERTICAL,
|
paperDirection: PaperDirection.VERTICAL,
|
||||||
inactiveAlpha: 0.6,
|
inactiveAlpha: 0.6,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export interface IEditorOption {
|
|||||||
pageMode?: PageMode;
|
pageMode?: PageMode;
|
||||||
tdPadding?: number;
|
tdPadding?: number;
|
||||||
defaultTrMinHeight?: number;
|
defaultTrMinHeight?: number;
|
||||||
|
defaultColMinWidth?: number;
|
||||||
defaultHyperlinkColor?: string;
|
defaultHyperlinkColor?: string;
|
||||||
paperDirection?: PaperDirection;
|
paperDirection?: PaperDirection;
|
||||||
inactiveAlpha?: number;
|
inactiveAlpha?: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user