1- // import { yUndoPluginKey } from "@y/prosemirror";
21import * as Y from "@y/y" ;
32import {
43 createExtension ,
54 createStore ,
65 ExtensionOptions ,
76} from "../../editor/BlockNoteExtension.js" ;
87import { CollaborationOptions } from "./index.js" ;
9- // import { YCursorExtension } from "./YCursorPlugin.js";
8+ import { YCursorExtension } from "./YCursorPlugin.js" ;
109import { YSyncExtension } from "./YSync.js" ;
11- // import { YUndoExtension } from "./YUndo.js";
1210
1311// TODO rewrite
1412
@@ -59,7 +57,6 @@ export const ForkYDocExtension = createExtension(
5957 let forkedState :
6058 | {
6159 originalFragment : Y . Type ;
62- // undoStack: Y.UndoManager["undoStack"];
6360 forkedFragment : Y . Type ;
6461 }
6562 | undefined = undefined ;
@@ -103,28 +100,18 @@ export const ForkYDocExtension = createExtension(
103100 const forkedFragment = findTypeInOtherYdoc ( originalFragment , doc ) ;
104101
105102 forkedState = {
106- // undoStack: yUndoPluginKey.getState(editor.prosemirrorState)!
107- // .undoManager.undoStack,
108103 originalFragment,
109104 forkedFragment,
110105 } ;
111106
112107 // Need to reset all the yjs plugins
113- editor . unregisterExtension ( [
114- // YUndoExtension,
115- // YCursorExtension,
116- YSyncExtension ,
117- ] ) ;
108+ editor . unregisterExtension ( [ YCursorExtension , YSyncExtension ] ) ;
118109 const newOptions = {
119110 ...options ,
120111 fragment : forkedFragment ,
121112 } ;
122113 // Register them again, based on the new forked fragment
123- editor . registerExtension ( [
124- YSyncExtension ( newOptions ) ,
125- // No need to register the cursor plugin again, it's a local fork
126- // YUndoExtension(),
127- ] ) ;
114+ editor . registerExtension ( [ YSyncExtension ( newOptions ) ] ) ;
128115
129116 // Tell the store that the editor is now forked
130117 store . setState ( { isForked : true } ) ;
@@ -140,25 +127,15 @@ export const ForkYDocExtension = createExtension(
140127 return ;
141128 }
142129 // Remove the forked fragment's plugins
143- editor . unregisterExtension ( [ "ySync" , "yCursor" , "yUndo" ] ) ;
130+ editor . unregisterExtension ( [ "ySync" , "yCursor" ] ) ;
144131
145- const {
146- originalFragment,
147- forkedFragment,
148- //, undoStack
149- } = forkedState ;
132+ const { originalFragment, forkedFragment } = forkedState ;
150133 // Register the plugins again, based on the original fragment (which is still in the original options)
151134 editor . registerExtension ( [
152135 YSyncExtension ( options ) ,
153- // YCursorExtension(options),
154- // YUndoExtension(),
136+ YCursorExtension ( options ) ,
155137 ] ) ;
156138
157- // Reset the undo stack to the original undo stack
158- // yUndoPluginKey.getState(
159- // editor.prosemirrorState,
160- // )!.undoManager.undoStack = undoStack;
161-
162139 if ( keepChanges ) {
163140 // Apply any changes that have been made to the fork, onto the original doc
164141 const update = Y . encodeStateAsUpdate (
0 commit comments