Undo after loading an editor causes whole document to clear (TipTap with collaboration & HocusPocus) #4400
Unanswered
EricHasegawa
asked this question in
Questions & Help
Replies: 1 comment
-
Not sure if this will be helpful as I do not use collaboration mode yet, however I experienced the same problem when initialising editor. const editor = useEditor(
{
immediatelyRender: true,
shouldRerenderOnTransaction: false,
//My guess is that setContent could be problematic here as it may introduce some middle state?
onCreate: (ctx) => {
ctx.editor.commands.setContent(initialContent);
ctx.editor.commands.focus("start", { scrollIntoView: true });
},
},
[]
); but when I changed const editor = useEditor(
{
immediatelyRender: true,
shouldRerenderOnTransaction: false,
content: initialContent,
},
[]
); Maybe that might be useful to make some workaround :) so in your case you can just pass |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Running into quite a serious editor in which after a document loads, a user can click undo and clear the whole document. I’m not sure what’s causing it, but here’s how we’re using TipTap: We have a NextJS app with a page that creates a new
HocusPocusProvider
with anew Y.doc()
, then passes that provider and doc into a dynamically renderedRichTextEditor
component.In
RichTextEditor
weuseEditor(…)
and set up Collaboration, configured with the passed in doc (also we sethistory: false
. In a separateuseEffect
(triggered when the editor is set) we fetch the data for the doc from our DB and runeditor.comands.setContent(…)
.Now the bug doesn’t happen all the time, but when it does, basically what happens is immediately after load the undo button is displayed (it’s normally greyed out at first since there’s nothing to undo), and if you click it, the whole page clears. This feels similar to the issue here #1786, but the solution doesn’t help since we’re never doing
Y.applyUpdate
or anything (we initialize withsetContent
). Are we doing something wrong here? Been trying to debug this for quite some time.Simplified version of code:
Outer page file
Inner component
Beta Was this translation helpful? Give feedback.
All reactions