Skip to content

Commit

Permalink
fix: delay live preview focus to allow for click events
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Sep 16, 2023
1 parent fd6ea7b commit 8739ad8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,18 @@ ${editor.getDoc().getSelection()}
if (ev.defaultPrevented || ev.detail > 1 || ev.shiftKey)
return;
try {
const pos = editor.posAtDOM(admonitionElement);
editor.focus();
editor.dispatch({
selection: {
head: pos,
anchor: pos
}
});
setTimeout(() => {
try {
const pos = editor.posAtDOM(admonitionElement);
editor.focus();
editor.dispatch({
selection: {
head: pos,
anchor: pos
}
});
} catch (e) {}
}, 10);
} catch (e) {}
});
}
Expand Down

0 comments on commit 8739ad8

Please sign in to comment.