1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-11 14:09:55 +02:00

Desktop,Mobile: Add setting to disable markup autocompletion (#11222)

This commit is contained in:
Henry Heino 2024-10-26 13:04:04 -07:00 committed by GitHub
parent d7f4f5f2b8
commit 92c13c2991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 4 deletions

View File

@ -381,6 +381,7 @@ const CodeMirror = (props: NoteBodyEditorProps, ref: ForwardedRef<NoteBodyEditor
monospaceFont: Setting.value('style.editor.monospaceFontFamily'), monospaceFont: Setting.value('style.editor.monospaceFontFamily'),
}, },
automatchBraces: Setting.value('editor.autoMatchingBraces'), automatchBraces: Setting.value('editor.autoMatchingBraces'),
autocompleteMarkup: Setting.value('editor.autocompleteMarkup'),
useExternalSearch: false, useExternalSearch: false,
ignoreModifiers: true, ignoreModifiers: true,
spellcheckEnabled: Setting.value('editor.spellcheckBeta'), spellcheckEnabled: Setting.value('editor.spellcheckBeta'),

View File

@ -345,6 +345,7 @@ function NoteEditor(props: Props, ref: any) {
automatchBraces: false, automatchBraces: false,
ignoreModifiers: false, ignoreModifiers: false,
autocompleteMarkup: Setting.value('editor.autocompleteMarkup'),
indentWithTabs: true, indentWithTabs: true,
}), [props.themeId, props.readOnly]); }), [props.themeId, props.readOnly]);

View File

@ -28,11 +28,21 @@ const configFromSettings = (settings: EditorSettings) => {
settings.katexEnabled ? MarkdownMathExtension : [], settings.katexEnabled ? MarkdownMathExtension : [],
], ],
codeLanguages: lookUpLanguage, codeLanguages: lookUpLanguage,
...(settings.autocompleteMarkup ? {
// Most Markup completion is enabled by default
} : {
addKeymap: false,
completeHTMLTags: false,
htmlTagLanguage: html({ matchClosingTags: false, autoCloseTags: false }),
}),
}),
markdownLanguage.data.of({
closeBrackets: openingBrackets,
}), }),
markdownLanguage.data.of({ closeBrackets: openingBrackets }),
]; ];
} else if (language === EditorLanguageType.Html) { } else if (language === EditorLanguageType.Html) {
return html(); return html({ autoCloseTags: settings.autocompleteMarkup });
} else { } else {
const exhaustivenessCheck: never = language; const exhaustivenessCheck: never = language;
return exhaustivenessCheck; return exhaustivenessCheck;

View File

@ -7,7 +7,7 @@ import { classHighlighter } from '@lezer/highlight';
import { import {
EditorView, drawSelection, highlightSpecialChars, ViewUpdate, Command, rectangularSelection, EditorView, drawSelection, highlightSpecialChars, ViewUpdate, Command, rectangularSelection,
} from '@codemirror/view'; } from '@codemirror/view';
import { history, undoDepth, redoDepth, standardKeymap } from '@codemirror/commands'; import { history, undoDepth, redoDepth, standardKeymap, insertTab } from '@codemirror/commands';
import { keymap, KeyBinding } from '@codemirror/view'; import { keymap, KeyBinding } from '@codemirror/view';
import { searchKeymap } from '@codemirror/search'; import { searchKeymap } from '@codemirror/search';
@ -186,7 +186,13 @@ const createEditor = (
notifyLinkEditRequest(); notifyLinkEditRequest();
return true; return true;
}), }),
keyCommand('Tab', insertOrIncreaseIndent, true), keyCommand('Tab', (view: EditorView) => {
if (settings.autocompleteMarkup) {
return insertOrIncreaseIndent(view);
}
// Use the default indent behavior (which doesn't adjust markup)
return insertTab(view);
}, true),
keyCommand('Shift-Tab', (view) => { keyCommand('Shift-Tab', (view) => {
// When at the beginning of the editor, allow shift-tab to act // When at the beginning of the editor, allow shift-tab to act
// normally. // normally.

View File

@ -10,6 +10,7 @@ const createEditorSettings = (themeId: number) => {
readOnly: false, readOnly: false,
automatchBraces: false, automatchBraces: false,
ignoreModifiers: false, ignoreModifiers: false,
autocompleteMarkup: true,
keymap: EditorKeymap.Default, keymap: EditorKeymap.Default,
language: EditorLanguageType.Markdown, language: EditorLanguageType.Markdown,

View File

@ -152,6 +152,7 @@ export interface EditorSettings {
useExternalSearch: boolean; useExternalSearch: boolean;
automatchBraces: boolean; automatchBraces: boolean;
autocompleteMarkup: boolean;
// True if internal command keyboard shortcuts should be ignored (thus // True if internal command keyboard shortcuts should be ignored (thus
// allowing Joplin shortcuts to run). // allowing Joplin shortcuts to run).

View File

@ -641,6 +641,18 @@ const builtInMetadata = (Setting: typeof SettingType) => {
storage: SettingStorage.File, storage: SettingStorage.File,
isGlobal: true, isGlobal: true,
}, },
'editor.autocompleteMarkup': {
value: true,
advanced: true,
type: SettingItemType.Bool,
public: true,
section: 'note',
appTypes: [AppType.Desktop, AppType.Mobile],
label: () => _('Autocomplete Markdown and HTML'),
description: () => _('Enables Markdown list continuation, auto-closing HTML tags, and other markup autocompletions.'),
storage: SettingStorage.File,
isGlobal: true,
},
'notes.columns': { 'notes.columns': {
value: defaultListColumns(), value: defaultListColumns(),
public: false, public: false,