File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/editor/src/controllers Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { tiptapContext } from '@/context/tiptapContext.ts';
55
66export 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}
You can’t perform that action at this time.
0 commit comments