We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f8d6fc commit 1e29666Copy full SHA for 1e29666
src/utils/monaco/insertSnippet.ts
@@ -1,6 +1,25 @@
1
-export function insertSnippetToEditor(input: string) {
2
- if (!window.ydbEditor) {
+export async function insertSnippetToEditor(input: string) {
+ let retry = 1;
3
+
4
+ const checkEditor = async () => {
5
+ if (!window.ydbEditor) {
6
+ if (retry) {
7
+ await new Promise((r) => {
8
+ window.setTimeout(r, 100);
9
+ });
10
+ retry -= 1;
11
+ checkEditor();
12
+ } else {
13
+ return false;
14
+ }
15
16
+ return true;
17
+ };
18
+ const editor = await checkEditor();
19
+ if (!editor) {
20
console.error('Monaco editor not found');
21
+ return;
22
}
23
24
window.ydbEditor?.trigger(undefined, 'insertSnippetToEditor', input);
25
0 commit comments