diff --git a/src/editor/core/command/CommandAdapt.ts b/src/editor/core/command/CommandAdapt.ts index 58d88dc..dc1dda8 100644 --- a/src/editor/core/command/CommandAdapt.ts +++ b/src/editor/core/command/CommandAdapt.ts @@ -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 diff --git a/src/editor/core/position/Position.ts b/src/editor/core/position/Position.ts index 3aa6c95..df2191d 100644 --- a/src/editor/core/position/Position.ts +++ b/src/editor/core/position/Position.ts @@ -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 } } diff --git a/src/editor/interface/Element.ts b/src/editor/interface/Element.ts index aa184c0..d42347d 100644 --- a/src/editor/interface/Element.ts +++ b/src/editor/interface/Element.ts @@ -126,6 +126,7 @@ export interface IElementPosition { pageNo: number; index: number; value: string, + rowIndex: number; rowNo: number; ascent: number; lineHeight: number; diff --git a/src/editor/interface/Position.ts b/src/editor/interface/Position.ts index ca59b02..75594ae 100644 --- a/src/editor/interface/Position.ts +++ b/src/editor/interface/Position.ts @@ -46,6 +46,7 @@ export interface IComputePageRowPositionPayload { positionList: IElementPosition[]; rowList: IRow[]; pageNo: number; + startRowIndex: number; startIndex: number; startX: number; startY: number;