diff --git a/src/components/Editor.singleton.js b/src/components/Editor.singleton.js new file mode 100644 index 00000000000..b8f89a24ffc --- /dev/null +++ b/src/components/Editor.singleton.js @@ -0,0 +1,24 @@ +/** + * Get instance of Editor component + * @return {Promise<*>} + */ +export default async function getEditorInstance() { + if (!window.EditorInstance) { + if (window.EditorInstanceImporting) { + return await new Promise((resolve) => { + const intervalId = setInterval(() => { + if (!window.EditorInstance) { + return + } + resolve(window.EditorInstance) + clearInterval(intervalId) + }, 200) + }) + } else { + window.EditorInstanceImporting = true + } + const Editor = await import(/* webpackChunkName: "editor" */'./Editor.vue') + window.EditorInstance = Editor.default + } + return window.EditorInstance +} diff --git a/src/components/ViewerComponent.vue b/src/components/ViewerComponent.vue index 6ddb359ae4f..43fa7530fba 100644 --- a/src/components/ViewerComponent.vue +++ b/src/components/ViewerComponent.vue @@ -32,11 +32,12 @@