-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Luka Trovic <[email protected]>
- Loading branch information
1 parent
7a506ff
commit 5c116c9
Showing
3 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters