From 1b988d34f66c3dd1127593dc4ba78fb21a29c7b9 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Tue, 23 Jan 2024 09:46:27 +0100 Subject: [PATCH] Secret function PLUTO_TOGGLE_CM_SPELLCHECK to enable spellchecking in codemirrors --- frontend/components/CellInput.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/components/CellInput.js b/frontend/components/CellInput.js index 0caf8d0ff7..c4dab5e4d0 100644 --- a/frontend/components/CellInput.js +++ b/frontend/components/CellInput.js @@ -62,6 +62,7 @@ import { useEventListener } from "../common/useEventListener.js" import { moveLineDown } from "../imports/CodemirrorPlutoSetup.js" export const ENABLE_CM_MIXED_PARSER = window.localStorage.getItem("ENABLE_CM_MIXED_PARSER") === "true" +export const ENABLE_CM_SPELLCHECK = window.localStorage.getItem("ENABLE_CM_SPELLCHECK") === "true" if (ENABLE_CM_MIXED_PARSER) { console.log(`YOU ENABLED THE CODEMIRROR MIXED LANGUAGE PARSER @@ -73,8 +74,14 @@ If enough people do this, we can make it the default parser. // Added this so we can have people test the mixed parser, because I LIKE IT SO MUCH - DRAL // @ts-ignore -window.PLUTO_TOGGLE_CM_MIXED_PARSER = () => { - window.localStorage.setItem("ENABLE_CM_MIXED_PARSER", String(!ENABLE_CM_MIXED_PARSER)) +window.PLUTO_TOGGLE_CM_MIXED_PARSER = (val = !ENABLE_CM_MIXED_PARSER) => { + window.localStorage.setItem("ENABLE_CM_MIXED_PARSER", String(val)) + window.location.reload() +} + +// @ts-ignore +window.PLUTO_TOGGLE_CM_SPELLCHECK = (val = !ENABLE_CM_SPELLCHECK) => { + window.localStorage.setItem("ENABLE_CM_SPELLCHECK", String(val)) window.location.reload() } @@ -751,6 +758,8 @@ export const CellInput = ({ keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...historyKeymap, ...foldKeymap]), placeholder("Enter cell code..."), + EditorView.contentAttributes.of({ spellcheck: String(ENABLE_CM_SPELLCHECK) }), + EditorView.lineWrapping, // Wowww this has been enabled for some time now... wonder if there are issues about this yet ;) - DRAL awesome_line_wrapping,