Skip to content

Commit 80d88cc

Browse files
committed
chore(138): clean up controller
1 parent 70fe362 commit 80d88cc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/editor/src/controllers/TipTapController.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { tiptapContext } from '@/context/tiptapContext.ts';
55

66
export class TipTapController implements ReactiveController {
77
private readonly host: ReactiveControllerHost;
8-
private unbindTransaction?: Editor;
98
// @ts-expect-error TypeScript cannot infer the type correctly here
109
private readonly editorConsumer: ContextConsumer<
1110
{ __context__: Editor | undefined },
@@ -32,11 +31,9 @@ export class TipTapController implements ReactiveController {
3231
}
3332

3433
private handleEditorChange(editor?: Editor) {
35-
// Clean up existing listener
36-
// this.unbindTransaction?.();
3734
if (editor) {
3835
this._editor = editor;
39-
this.unbindTransaction = editor.on('transaction', () => {
36+
editor.on('transaction', () => {
4037
this.host.requestUpdate();
4138
});
4239
}
@@ -47,6 +44,11 @@ export class TipTapController implements ReactiveController {
4744
}
4845

4946
hostDisconnected() {
50-
// this.unbindTransaction?.();
47+
// Context consumer handles the subscription
48+
if (this._editor) {
49+
this._editor.off('transaction', () => {
50+
this.host.requestUpdate();
51+
});
52+
}
5153
}
5254
}

0 commit comments

Comments
 (0)