diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx index edb28bfa3..7a153e319 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.tsx @@ -812,6 +812,7 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) { onChange={codeMirror_change} onScroll={editor_scroll} onEditorPaste={onEditorPaste} + isSafeMode={props.isSafeMode} /> ); diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx index 4d6fa64a4..e423a46a5 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx @@ -92,6 +92,7 @@ export interface EditorProps { onChange: any; onScroll: any; onEditorPaste: any; + isSafeMode: boolean; } function Editor(props: EditorProps, ref: any) { @@ -149,11 +150,13 @@ function Editor(props: EditorProps, ref: any) { useEffect(() => { if (!editorParent.current) return () => {}; - // const userOptions = eventManager.filterEmit('codeMirrorOptions', {}); const userOptions = {}; - const cmOptions = Object.assign({}, { + const safeOptions: Record = { value: props.value, + }; + + const unsafeOptions: Record = { screenReaderLabel: props.value, theme: props.codeMirrorTheme, mode: props.mode, @@ -167,7 +170,17 @@ function Editor(props: EditorProps, ref: any) { spellcheck: true, allowDropFileTypes: [''], // disable codemirror drop handling keyMap: props.keyMap ? props.keyMap : 'default', - }, userOptions); + }; + + let cmOptions: Record = { ...safeOptions }; + + if (!props.isSafeMode) { + cmOptions = { + ...cmOptions, + ...unsafeOptions, + ...userOptions, + }; + } const cm = CodeMirror(editorParent.current, cmOptions); setEditor(cm); diff --git a/packages/app-desktop/gui/NoteEditor/NoteEditor.tsx b/packages/app-desktop/gui/NoteEditor/NoteEditor.tsx index 2b4942a17..645d0ae83 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteEditor.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteEditor.tsx @@ -409,6 +409,7 @@ function NoteEditor(props: NoteEditorProps) { plugins: props.plugins, fontSize: Setting.value('style.editor.fontSize'), contentMaxWidth: props.contentMaxWidth, + isSafeMode: props.isSafeMode, }; let editor = null; @@ -611,6 +612,7 @@ const mapStateToProps = (state: AppState) => { 'setTags', ], whenClauseContext)[0], contentMaxWidth: state.settings['style.editor.contentMaxWidth'], + isSafeMode: state.settings.isSafeMode, }; }; diff --git a/packages/app-desktop/gui/NoteEditor/utils/types.ts b/packages/app-desktop/gui/NoteEditor/utils/types.ts index 24d9c39b4..f42fb33f4 100644 --- a/packages/app-desktop/gui/NoteEditor/utils/types.ts +++ b/packages/app-desktop/gui/NoteEditor/utils/types.ts @@ -43,6 +43,7 @@ export interface NoteEditorProps { setTagsToolbarButtonInfo: ToolbarButtonInfo; richTextBannerDismissed: boolean; contentMaxWidth: number; + isSafeMode: boolean; } export interface NoteBodyEditorProps { @@ -74,6 +75,7 @@ export interface NoteBodyEditorProps { plugins: PluginStates; fontSize: number; contentMaxWidth: number; + isSafeMode: boolean; } export interface FormNote {