Skip to content

Commit

Permalink
fix: add context param to the shrinkBoundary function #503
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Apr 8, 2024
1 parent 632f8f5 commit 6f690a8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/editor/core/draw/control/Control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/editor/core/draw/control/text/TextControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
// 移除选区元素
Expand Down
7 changes: 4 additions & 3 deletions src/editor/core/range/RangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 6f690a8

Please sign in to comment.