]> BookStack Code Mirror - bookstack/blobdiff - resources/js/markdown/inputs/codemirror.ts
Deps: Updated PHP composer dependancy versions, fixed test namespaces
[bookstack] / resources / js / markdown / inputs / codemirror.ts
index 029d238fe85a19d2f558e21d5c9a77da30aefb4c..827068238e0e70c400525a55a484966a05a95cb5 100644 (file)
@@ -10,6 +10,10 @@ export class CodemirrorInput implements MarkdownEditorInput {
         this.cm = cm;
     }
 
+    teardown(): void {
+        this.cm.destroy();
+    }
+
     focus(): void {
         if (!this.cm.hasFocus) {
             this.cm.focus();
@@ -68,8 +72,8 @@ export class CodemirrorInput implements MarkdownEditorInput {
         return this.cm.state.doc.lineAt(index).text;
     }
 
-    coordsToSelection(x: number, y: number): MarkdownEditorInputSelection {
-        const cursorPos = this.cm.posAtCoords({x, y}, false);
+    eventToPosition(event: MouseEvent): MarkdownEditorInputSelection {
+        const cursorPos = this.cm.posAtCoords({x: event.screenX, y: event.screenY}, false);
         return {from: cursorPos, to: cursorPos};
     }