Skip to content

Commit b5a0634

Browse files
Added checks to stop prevent listening if Editor instance is dead (#27)
2 parents c460d15 + 67aaf2f commit b5a0634

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/editor/core/draw/Draw.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export class Draw {
143143
private intersectionPageNo: number
144144
private lazyRenderIntersectionObserver: IntersectionObserver | null
145145

146+
private isDestroyed: boolean = false;
147+
146148
constructor(
147149
rootContainer: HTMLElement,
148150
options: DeepRequired<IEditorOption>,
@@ -357,6 +359,7 @@ export class Draw {
357359
}
358360

359361
public setIntersectionPageNo(payload: number) {
362+
if (this.isDestroyed) return;
360363
this.intersectionPageNo = payload
361364
if (this.listener.intersectionPageNoChange) {
362365
this.listener.intersectionPageNoChange(this.intersectionPageNo)
@@ -1716,6 +1719,7 @@ export class Draw {
17161719
}
17171720

17181721
public render(payload?: IDrawOption) {
1722+
if (this.isDestroyed) return;
17191723
const { header, footer } = this.options
17201724
const {
17211725
isSubmitHistory = true,
@@ -1849,6 +1853,7 @@ export class Draw {
18491853
}
18501854

18511855
public destroy() {
1856+
this.isDestroyed = true;
18521857
this.container.remove()
18531858
this.globalEvent.removeEvent()
18541859
this.scrollObserver.removeEvent()

src/editor/core/range/RangeManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ export class RangeManager {
318318
}
319319

320320
public setRangeStyle() {
321+
if (!this.eventBus || !this.listener) return;
321322
const rangeStyleChangeListener = this.listener.rangeStyleChange
322323
const isSubscribeRangeStyleChange =
323324
this.eventBus.isSubscribe('rangeStyleChange')

0 commit comments

Comments
 (0)