From 1d9b34711edd0d99ca7a2698280def64770f3d97 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Mon, 7 Oct 2024 09:25:48 -0500 Subject: [PATCH] Add a scroll event handler that refreshes the view on scroll. This seems to be a bug in CodeMirror 6. When scrolling down in a long document, eventually the text is invisible until you click inside the editor window. This event handler refreshes the view on scroll so that doesn't happen. --- package.json | 2 +- src/pg-codemirror-editor.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ba65fcf..0652b13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openwebwork/pg-codemirror-editor", - "version": "0.0.1-beta.1", + "version": "0.0.1-beta.2", "description": "PG CodeMirror Editor", "author": "The WeBWorK Project", "license": "MIT", diff --git a/src/pg-codemirror-editor.ts b/src/pg-codemirror-editor.ts index d1436d8..aee860a 100644 --- a/src/pg-codemirror-editor.ts +++ b/src/pg-codemirror-editor.ts @@ -141,6 +141,11 @@ export class View { ...completionKeymap, indentWithTab ]), + EditorView.domEventHandlers({ + scroll: () => { + this.refresh('scroll-update'); + } + }), this.theme.of(lightTheme), this.language.of([]) ];