Skip to content

Commit 8739ad8

Browse files
committed
fix: delay live preview focus to allow for click events
1 parent fd6ea7b commit 8739ad8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,18 @@ ${editor.getDoc().getSelection()}
373373
if (ev.defaultPrevented || ev.detail > 1 || ev.shiftKey)
374374
return;
375375
try {
376-
const pos = editor.posAtDOM(admonitionElement);
377-
editor.focus();
378-
editor.dispatch({
379-
selection: {
380-
head: pos,
381-
anchor: pos
382-
}
383-
});
376+
setTimeout(() => {
377+
try {
378+
const pos = editor.posAtDOM(admonitionElement);
379+
editor.focus();
380+
editor.dispatch({
381+
selection: {
382+
head: pos,
383+
anchor: pos
384+
}
385+
});
386+
} catch (e) {}
387+
}, 10);
384388
} catch (e) {}
385389
});
386390
}

0 commit comments

Comments
 (0)