fix: add context param to the shrinkBoundary function #503
This commit is contained in:
@@ -197,8 +197,8 @@ export class Control {
|
||||
return this.range.getRange()
|
||||
}
|
||||
|
||||
public shrinkBoundary() {
|
||||
this.range.shrinkBoundary()
|
||||
public shrinkBoundary(context: IControlContext = {}) {
|
||||
this.range.shrinkBoundary(context)
|
||||
}
|
||||
|
||||
public getActiveControl(): IControlInstance | null {
|
||||
|
||||
@@ -74,7 +74,7 @@ export class TextControl implements IControlInstance {
|
||||
const elementList = context.elementList || this.control.getElementList()
|
||||
const range = context.range || this.control.getRange()
|
||||
// 收缩边界到Value内
|
||||
this.control.shrinkBoundary()
|
||||
this.control.shrinkBoundary(context)
|
||||
const { startIndex, endIndex } = range
|
||||
const draw = this.control.getDraw()
|
||||
// 移除选区元素
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ZERO } from '../../dataset/constant/Common'
|
||||
import { TEXTLIKE_ELEMENT_TYPE } from '../../dataset/constant/Element'
|
||||
import { ControlComponent } from '../../dataset/enum/Control'
|
||||
import { EditorContext } from '../../dataset/enum/Editor'
|
||||
import { IControlContext } from '../../interface/Control'
|
||||
import { IEditorOption } from '../../interface/Editor'
|
||||
import { IElement } from '../../interface/Element'
|
||||
import { EventBusMap } from '../../interface/EventBus'
|
||||
@@ -480,9 +481,9 @@ export class RangeManager {
|
||||
}
|
||||
}
|
||||
|
||||
public shrinkBoundary() {
|
||||
const elementList = this.draw.getElementList()
|
||||
const range = this.getRange()
|
||||
public shrinkBoundary(context: IControlContext = {}) {
|
||||
const elementList = context.elementList || this.draw.getElementList()
|
||||
const range = context.range || this.getRange()
|
||||
const { startIndex, endIndex } = range
|
||||
if (!~startIndex && !~endIndex) return
|
||||
const startElement = elementList[startIndex]
|
||||
|
||||
Reference in New Issue
Block a user