-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathEditor.singleton.js
More file actions
32 lines (31 loc) · 985 Bytes
/
Editor.singleton.js
File metadata and controls
32 lines (31 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/**
* 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')
const { default: Vue } = await import('vue')
const EditorConstructor = Vue.extend(Editor.default)
window._nc_text_editor_instance = EditorConstructor
}
return window._nc_text_editor_instance
}