From 96e4c4ed06a7f66aa9a92d3e1a19ad4c81970b5d Mon Sep 17 00:00:00 2001 From: Chris Klimas Date: Tue, 5 Nov 2024 22:33:28 -0500 Subject: [PATCH] Add preference to disable CodeMirror --- public/locales/en-US.json | 3 +- .../control/code-area/__mocks__/code-area.tsx | 22 ++--- .../code-area/__tests__/code-area.test.tsx | 93 ++++++++++++++----- .../control/code-area/code-area.css | 15 +-- .../control/code-area/code-area.tsx | 76 ++++++++++++--- src/dialogs/__tests__/app-prefs.test.tsx | 57 ++++++++++++ .../__tests__/story-javascript.test.tsx | 58 +++++++++++- src/dialogs/__tests__/story-search.test.tsx | 16 ++++ .../__tests__/story-stylesheet.test.tsx | 58 +++++++++++- src/dialogs/app-prefs.tsx | 16 ++++ .../__tests__/passage-edit-contents.test.tsx | 42 +++++++-- .../__tests__/passage-text.test.tsx | 14 +++ .../__tests__/passage-toolbar.test.tsx | 30 +++++- .../passage-edit/passage-edit-contents.tsx | 5 +- src/dialogs/passage-edit/passage-text.tsx | 19 ++-- src/dialogs/passage-edit/passage-toolbar.tsx | 19 ++-- src/dialogs/story-javascript.tsx | 22 ++--- src/dialogs/story-search.tsx | 22 ++--- src/dialogs/story-stylesheet.tsx | 22 ++--- src/store/prefs/defaults.ts | 1 + src/store/prefs/prefs.types.ts | 4 + src/test-util/fakes.ts | 3 + 22 files changed, 492 insertions(+), 125 deletions(-) diff --git a/public/locales/en-US.json b/public/locales/en-US.json index 438de350a..616317053 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -175,7 +175,8 @@ "themeDark": "Dark", "themeSystem": "System", "theme": "Theme", - "title": "Preferences" + "title": "Preferences", + "useEnhancedEditors": "Use Enhanced Editors" }, "passageEdit": { "editorCrashed": "Something went wrong with this editor. Try closing it and editing this passage again.", diff --git a/src/components/control/code-area/__mocks__/code-area.tsx b/src/components/control/code-area/__mocks__/code-area.tsx index 3aa229534..f289f0fd9 100644 --- a/src/components/control/code-area/__mocks__/code-area.tsx +++ b/src/components/control/code-area/__mocks__/code-area.tsx @@ -3,19 +3,14 @@ import {CodeAreaProps} from '../code-area'; export const CodeArea: React.FC = props => { function handleOnChange(e: React.ChangeEvent) { - props.onBeforeChange( - { - historySize: () => ({ - redo: 0, - undo: 0 - }), - mockCodeMirrorEditor: true - } as any, - { - mockCodeMirrorChange: true - } as any, - e.target.value - ); + props.onChangeEditor?.({ + historySize: () => ({ + redo: 0, + undo: 0 + }), + mockCodeMirrorEditor: true + } as any); + props.onChangeText(e.target.value); } return ( @@ -24,6 +19,7 @@ export const CodeArea: React.FC = props => { data-font-family={props.fontFamily} data-font-scale={props.fontScale} data-options={JSON.stringify(props.options)} + data-use-code-mirror={props.useCodeMirror} >