From 4cc55b02abbad0f515c50b790dedf1c4d96e5e83 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 23 Sep 2025 20:18:02 +0300 Subject: [PATCH] feat(client/text): provide a way to disable slash commands --- apps/client/src/translations/en/translation.json | 3 ++- apps/client/src/widgets/type_widgets/ckeditor/config.ts | 4 ++++ apps/client/src/widgets/type_widgets/options/text_notes.tsx | 1 + apps/server/src/routes/api/options.ts | 1 + apps/server/src/services/options_init.ts | 1 + packages/commons/src/lib/options_interface.ts | 2 ++ 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index af9c47ee3..5c7f0d056 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1962,7 +1962,8 @@ "editorfeatures": { "title": "Features", "emoji_completion_enabled": "Enable Emoji auto-completion", - "note_completion_enabled": "Enable note auto-completion" + "note_completion_enabled": "Enable note auto-completion", + "slash_commands_enabled": "Enable slash commands" }, "table_view": { "new-row": "New row", diff --git a/apps/client/src/widgets/type_widgets/ckeditor/config.ts b/apps/client/src/widgets/type_widgets/ckeditor/config.ts index 7bb78aa93..a923ad92f 100644 --- a/apps/client/src/widgets/type_widgets/ckeditor/config.ts +++ b/apps/client/src/widgets/type_widgets/ckeditor/config.ts @@ -244,5 +244,9 @@ function getDisabledPlugins() { disabledPlugins.push("EmojiMention"); } + if (options.get("textNoteSlashCommandsEnabled") !== "true") { + disabledPlugins.push("SlashCommand"); + } + return disabledPlugins; } diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsx index 9003a5230..500fbbd5f 100644 --- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx +++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx @@ -73,6 +73,7 @@ function EditorFeatures() { + ); } diff --git a/apps/server/src/routes/api/options.ts b/apps/server/src/routes/api/options.ts index 4f76acd68..8e9d6e1a6 100644 --- a/apps/server/src/routes/api/options.ts +++ b/apps/server/src/routes/api/options.ts @@ -91,6 +91,7 @@ const ALLOWED_OPTIONS = new Set([ "textNoteEditorMultilineToolbar", "textNoteEmojiCompletionEnabled", "textNoteCompletionEnabled", + "textNoteSlashCommandsEnabled", "layoutOrientation", "backgroundEffects", "allowedHtmlTags", diff --git a/apps/server/src/services/options_init.ts b/apps/server/src/services/options_init.ts index a89ad6a10..0908a0512 100644 --- a/apps/server/src/services/options_init.ts +++ b/apps/server/src/services/options_init.ts @@ -184,6 +184,7 @@ const defaultOptions: DefaultOption[] = [ { name: "textNoteEditorMultilineToolbar", value: "false", isSynced: true }, { name: "textNoteEmojiCompletionEnabled", value: "true", isSynced: true }, { name: "textNoteCompletionEnabled", value: "true", isSynced: true }, + { name: "textNoteSlashCommandsEnabled", value: "true", isSynced: true }, // HTML import configuration { name: "layoutOrientation", value: "vertical", isSynced: false }, diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.ts index a94b25857..78e0cc609 100644 --- a/packages/commons/src/lib/options_interface.ts +++ b/packages/commons/src/lib/options_interface.ts @@ -127,6 +127,8 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions