feat: insert table in list element
This commit is contained in:
@@ -507,7 +507,15 @@ export class CommandAdapt {
|
||||
const { startIndex, endIndex } = this.range.getRange()
|
||||
if (!~startIndex && !~endIndex) return
|
||||
const elementList = this.draw.getElementList()
|
||||
const innerWidth = this.draw.getOriginalInnerWidth()
|
||||
let offsetX = 0
|
||||
if (elementList[startIndex]?.listId) {
|
||||
const positionList = this.position.getPositionList()
|
||||
const { rowIndex } = positionList[startIndex]
|
||||
const rowList = this.draw.getRowList()
|
||||
const row = rowList[rowIndex]
|
||||
offsetX = row?.offsetX || 0
|
||||
}
|
||||
const innerWidth = this.draw.getOriginalInnerWidth() - offsetX
|
||||
// colgroup
|
||||
const colgroup: IColgroup[] = []
|
||||
const colWidth = innerWidth / col
|
||||
|
||||
@@ -68,7 +68,7 @@ export class Position {
|
||||
}
|
||||
|
||||
public computePageRowPosition(payload: IComputePageRowPositionPayload): IComputePageRowPositionResult {
|
||||
const { positionList, rowList, pageNo, startX, startY, startIndex, innerWidth } = payload
|
||||
const { positionList, rowList, pageNo, startX, startY, startRowIndex, startIndex, innerWidth } = payload
|
||||
const { scale, tdPadding } = this.options
|
||||
let x = startX
|
||||
let y = startY
|
||||
@@ -100,6 +100,7 @@ export class Position {
|
||||
pageNo,
|
||||
index,
|
||||
value: element.value,
|
||||
rowIndex: startRowIndex + i,
|
||||
rowNo: i,
|
||||
metrics,
|
||||
ascent: offsetY,
|
||||
@@ -128,6 +129,7 @@ export class Position {
|
||||
positionList: td.positionList,
|
||||
rowList,
|
||||
pageNo,
|
||||
startRowIndex: 0,
|
||||
startIndex: 0,
|
||||
startX: (td.x! + tdPadding) * scale + tablePreX,
|
||||
startY: td.y! * scale + tablePreY,
|
||||
@@ -178,6 +180,7 @@ export class Position {
|
||||
const header = this.draw.getHeader()
|
||||
const extraHeight = header.getExtraHeight()
|
||||
const startY = margins[0] + extraHeight
|
||||
let startRowIndex = 0
|
||||
for (let i = 0; i < pageRowList.length; i++) {
|
||||
const rowList = pageRowList[i]
|
||||
const startIndex = rowList[0].startIndex
|
||||
@@ -185,11 +188,13 @@ export class Position {
|
||||
positionList: this.positionList,
|
||||
rowList,
|
||||
pageNo: i,
|
||||
startRowIndex,
|
||||
startIndex,
|
||||
startX,
|
||||
startY,
|
||||
innerWidth
|
||||
})
|
||||
startRowIndex += rowList.length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ export interface IElementPosition {
|
||||
pageNo: number;
|
||||
index: number;
|
||||
value: string,
|
||||
rowIndex: number;
|
||||
rowNo: number;
|
||||
ascent: number;
|
||||
lineHeight: number;
|
||||
|
||||
@@ -46,6 +46,7 @@ export interface IComputePageRowPositionPayload {
|
||||
positionList: IElementPosition[];
|
||||
rowList: IRow[];
|
||||
pageNo: number;
|
||||
startRowIndex: number;
|
||||
startIndex: number;
|
||||
startX: number;
|
||||
startY: number;
|
||||
|
||||
Reference in New Issue
Block a user