From 7731b282033a00542c4e925d389fd72fc3bff313 Mon Sep 17 00:00:00 2001 From: Fernando Serboncini Date: Tue, 8 Oct 2024 15:06:33 -0400 Subject: [PATCH] auto close brackets setting (#1110) --- type/config.ts | 2 ++ web/editor_state.ts | 4 +++- website/SETTINGS.md | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/type/config.ts b/type/config.ts index 584a86b5..c80bfee0 100644 --- a/type/config.ts +++ b/type/config.ts @@ -43,6 +43,7 @@ export type Config = { // Format: compatible with docker ignore spaceIgnore?: string; emoji?: EmojiConfig; + autoCloseBrackets: string; schema: SchemaConfig; @@ -64,6 +65,7 @@ export const defaultConfig: Config = { maximumAttachmentSize: 10, // MiB defaultLinkStyle: "wikilink", // wikilink [[]] or markdown []() actionButtons: [], // Actually defaults to defaultActionButtons + autoCloseBrackets: "([{`", schema: { config: { diff --git a/web/editor_state.ts b/web/editor_state.ts index 2cac3918..189afccd 100644 --- a/web/editor_state.ts +++ b/web/editor_state.ts @@ -100,7 +100,9 @@ export function createEditorState( addKeymap: true, }), extendedMarkdownLanguage.data.of({ - closeBrackets: { brackets: ["(", "{", "[", "`"] }, + closeBrackets: { + brackets: client.config?.autoCloseBrackets.split(""), + }, }), syntaxHighlighting(customMarkdownStyle()), autocompletion({ diff --git a/website/SETTINGS.md b/website/SETTINGS.md index 51e8da8e..3f5fbca4 100644 --- a/website/SETTINGS.md +++ b/website/SETTINGS.md @@ -58,6 +58,8 @@ shortcuts: # Toggles between “smart” ‘quotes’ (left and right) and "simple" 'quotes' (good ol' ASCII) useSmartQuotes: true +# Choose which characters to auto-close +autoCloseBrackets: "([{`" # Defines files to ignore in a format compatible with .gitignore spaceIgnore: |