mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop, Mobile: Resolves #5593: Enable safe mode for Markdown editor too
This commit is contained in:
parent
aa3cbbd165
commit
0b01b5b0ef
@ -812,6 +812,7 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
||||
onChange={codeMirror_change}
|
||||
onScroll={editor_scroll}
|
||||
onEditorPaste={onEditorPaste}
|
||||
isSafeMode={props.isSafeMode}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -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<string, any> = {
|
||||
value: props.value,
|
||||
};
|
||||
|
||||
const unsafeOptions: Record<string, any> = {
|
||||
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<string, any> = { ...safeOptions };
|
||||
|
||||
if (!props.isSafeMode) {
|
||||
cmOptions = {
|
||||
...cmOptions,
|
||||
...unsafeOptions,
|
||||
...userOptions,
|
||||
};
|
||||
}
|
||||
|
||||
const cm = CodeMirror(editorParent.current, cmOptions);
|
||||
setEditor(cm);
|
||||
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user