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