Skip to content

Commit

Permalink
fix: verify control integrity boundary error #920
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Dec 6, 2024
1 parent 190785a commit 77a2550
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/editor/core/draw/control/Control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,33 @@ export class Control {
return this.activeControl
}

public getControlElementList(context: IControlContext = {}): IElement[] {
const elementList = context.elementList || this.getElementList()
const { startIndex } = context.range || this.getRange()
const startElement = elementList[startIndex]
const data: IElement[] = []
// 向左查找
let preIndex = startIndex
while (preIndex > 0) {
const preElement = elementList[preIndex]
if (preElement.controlId !== startElement.controlId) break
data.unshift(preElement)
preIndex--
}
// 向右查找
let nextIndex = startIndex + 1
while (nextIndex < elementList.length) {
const nextElement = elementList[nextIndex]
if (nextElement.controlId !== startElement.controlId) break
data.push(nextElement)
nextIndex++
}
return data
}

public updateActiveControlValue() {
if (this.activeControl) {
this.activeControlValue = this.activeControl.getValue()
this.activeControlValue = this.getControlElementList()
}
}

Expand Down

0 comments on commit 77a2550

Please sign in to comment.