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