diff --git a/packages/text-editor/src/components/CollaboratorEditor.svelte b/packages/text-editor/src/components/CollaboratorEditor.svelte index 14d7614ff1..e95628b21e 100644 --- a/packages/text-editor/src/components/CollaboratorEditor.svelte +++ b/packages/text-editor/src/components/CollaboratorEditor.svelte @@ -96,14 +96,7 @@ }) let loading = true - - if (contextProvider === undefined) { - provider?.on('synced', () => { - loading = false - }) - } else { - loading = false - } + provider.loaded.then(() => (loading = false)) const currentUser = getCurrentAccount() diff --git a/packages/text-editor/src/provider.ts b/packages/text-editor/src/provider.ts index 24ec65c202..0196484198 100644 --- a/packages/text-editor/src/provider.ts +++ b/packages/text-editor/src/provider.ts @@ -19,8 +19,14 @@ export type TiptapCollabProviderConfiguration = HocuspocusProviderConfiguration Required> export class TiptapCollabProvider extends HocuspocusProvider { + loaded: Promise + constructor (configuration: TiptapCollabProviderConfiguration) { super(configuration as HocuspocusProviderConfiguration) + + this.loaded = new Promise((resolve) => { + this.on('synced', resolve) + }) } copyContent (sourceId: string, targetId: string): void {