Skip to content

Commit

Permalink
improve: timing of updating range style #985
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Feb 15, 2025
1 parent fd34310 commit cfb09ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,8 @@ export class Draw {
}
// 信息变动回调
nextTick(() => {
// 选区样式
this.range.setRangeStyle()
// 重新唤起弹窗类控件
if (isCompute && this.control.getActiveControl()) {
this.control.reAwakeControl()
Expand Down
16 changes: 3 additions & 13 deletions src/editor/core/event/GlobalEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export class GlobalEvent {

private addEvent() {
window.addEventListener('blur', this.clearSideEffect)
document.addEventListener('keyup', this.setRangeStyle)
document.addEventListener('click', this.clearSideEffect)
document.addEventListener('mousedown', this.clearSideEffect)
document.addEventListener('mouseup', this.setCanvasEventAbility)
document.addEventListener('wheel', this.setPageScale, { passive: false })
document.addEventListener('visibilitychange', this._handleVisibilityChange)
Expand All @@ -60,8 +59,7 @@ export class GlobalEvent {

public removeEvent() {
window.removeEventListener('blur', this.clearSideEffect)
document.removeEventListener('keyup', this.setRangeStyle)
document.removeEventListener('click', this.clearSideEffect)
document.removeEventListener('mousedown', this.clearSideEffect)
document.removeEventListener('mouseup', this.setCanvasEventAbility)
document.removeEventListener('wheel', this.setPageScale)
document.removeEventListener(
Expand All @@ -81,10 +79,7 @@ export class GlobalEvent {
(node: any) => pageList.includes(node),
true
)
if (innerEditorDom) {
this.setRangeStyle()
return
}
if (innerEditorDom) return
// 编辑器外部组件dom
const outerEditorDom = findParent(
target,
Expand All @@ -93,7 +88,6 @@ export class GlobalEvent {
true
)
if (outerEditorDom) {
this.setRangeStyle()
this.watchCursorActive()
return
}
Expand All @@ -112,10 +106,6 @@ export class GlobalEvent {
this.canvasEvent.setIsAllowSelection(false)
}

public setRangeStyle = () => {
this.range.setRangeStyle()
}

public watchCursorActive() {
// 选区闭合&实际光标移出光标代理
if (!this.range.getIsCollapsed()) return
Expand Down

0 comments on commit cfb09ce

Please sign in to comment.