Skip to content

Commit

Permalink
fix:table cursor position in page header
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Mar 18, 2023
1 parent 7b4b33b commit 85a2bbe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ export class Draw {
const positionContext = this.position.getPositionContext()
if (positionContext.isTable) {
const { index, trIndex, tdIndex } = positionContext
const elementList = this.getElementList()
const elementList = this.getOriginalElementList()
const tablePositionList = elementList[index!].trList?.[trIndex!].tdList[tdIndex!].positionList
if (curIndex === undefined && tablePositionList) {
curIndex = tablePositionList.length - 1
Expand Down
4 changes: 2 additions & 2 deletions src/editor/core/event/handlers/click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function dblclick(host: CanvasEvent, evt: MouseEvent) {
y: evt.offsetY
})
if (!~positionContext.index && positionContext.zone) {
const zoneManager = draw.getZone()
zoneManager.setZone(positionContext.zone)
draw.getZone().setZone(positionContext.zone)
draw.getRange().clearRange()
draw.render({
isSubmitHistory: false,
isSetCursor: false,
Expand Down
6 changes: 2 additions & 4 deletions src/editor/core/position/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ export class Position {
}

public getPositionList(): IElementPosition[] {
const elementList = this.draw.getElementList()
return this.positionContext.isTable
? this.getTablePositionList(elementList)
? this.getTablePositionList(this.draw.getOriginalElementList())
: this.getOriginalPositionList()
}

public getMainPositionList(): IElementPosition[] {
const elementList = this.draw.getMainElementList()
return this.positionContext.isTable
? this.getTablePositionList(elementList)
? this.getTablePositionList(this.draw.getOriginalMainElementList())
: this.positionList
}

Expand Down
4 changes: 4 additions & 0 deletions src/editor/core/range/RangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export class RangeManager {
return this.range
}

public clearRange() {
this.setRange(-1, -1)
}

public getSelection(): IElement[] | null {
const { startIndex, endIndex } = this.range
if (startIndex === endIndex) return null
Expand Down

0 comments on commit 85a2bbe

Please sign in to comment.