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 4fd0662 commit 8af3a99Copy full SHA for 8af3a99
website/src/index.js
@@ -270,9 +270,14 @@ class HdxEditor extends HTMLElement {
270
} else if (event.type == "click" || event.type === "focusin") {
271
codeFromUrl.set(this.code);
272
codeFromLocal.set(this.code);
273
- const pos = this.view.posAtCoords(event);
274
const tree = syntaxTree(this.view.state);
275
- let cursor = tree.cursorAt(pos);
+ let cursor;
+ if (event.x && event.y) {
276
+ const pos = this.view.posAtCoords(event);
277
+ cursor = tree.cursorAt(pos);
278
+ } else {
279
+ cursor = tree.cursorAt(this.view.state.selection.anchor);
280
+ }
281
this.dispatchEvent(
282
new EditorFocus({ start: cursor.from, end: cursor.to }),
283
);
0 commit comments