Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong timeout object #112

Merged
merged 1 commit into from
May 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/plugins/sync-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const ySyncPlugin = (yXmlFragment, {
onFirstRender = () => {}
} = {}) => {
let changedInitialContent = false
let rerenderTimeoutId
let rerenderTimeout
const plugin = new Plugin({
props: {
editable: (state) => {
Expand Down Expand Up @@ -140,11 +140,11 @@ export const ySyncPlugin = (yXmlFragment, {
},
view: view => {
const binding = new ProsemirrorBinding(yXmlFragment, view)
if (rerenderTimeoutId != null) {
clearTimeout(rerenderTimeoutId)
if (rerenderTimeout != null) {
rerenderTimeout.destroy()
}
// Make sure this is called in a separate context
rerenderTimeoutId = eventloop.timeout(0, () => {
rerenderTimeout = eventloop.timeout(0, () => {
binding._forceRerender()
view.dispatch(view.state.tr.setMeta(ySyncPluginKey, { binding }))
onFirstRender()
Expand All @@ -160,7 +160,7 @@ export const ySyncPlugin = (yXmlFragment, {
}
},
destroy: () => {
clearTimeout(rerenderTimeoutId)
rerenderTimeout.destroy()
binding.destroy()
}
}
Expand Down