-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
Bugfix/duplicated load of yjs
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Get instance of Editor component | ||
* Using singleton approach here to avoid duplicate yjs import error | ||
* @return {Promise<*>} | ||
*/ | ||
export default async function getEditorInstance() { | ||
if (!window._nc_text_editor_instance) { | ||
if (window._nc_text_editor_importing) { | ||
return await new Promise((resolve) => { | ||
const intervalId = setInterval(() => { | ||
if (!window._nc_text_editor_instance) { | ||
return | ||
} | ||
resolve(window._nc_text_editor_instance) | ||
clearInterval(intervalId) | ||
}, 200) | ||
}) | ||
} else { | ||
window._nc_text_editor_importing = true | ||
} | ||
const Editor = await import(/* webpackChunkName: "editor" */'./Editor.vue') | ||
window._nc_text_editor_instance = Editor.default | ||
} | ||
return window._nc_text_editor_instance | ||
} |