From 5fb6f8eccf837eff9d6fc6fea9d1d2f00fc972c1 Mon Sep 17 00:00:00 2001 From: Johnny Date: Sun, 30 Nov 2025 10:30:55 +0800 Subject: [PATCH] refactor: remove legacy disable markdown shortcuts setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove disable_markdown_shortcuts field from proto definitions - Remove setting UI from MemoRelatedSettings component - Enable markdown shortcuts permanently in MemoEditor - Remove translations from all 32 locale files - Fix TypeScript error in useMemoSave hook by using typed translation function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- proto/api/v1/instance_service.proto | 2 -- proto/gen/api/v1/instance_service.pb.go | 16 +++------------- proto/gen/openapi.yaml | 3 --- proto/gen/store/instance_setting.pb.go | 14 ++------------ proto/store/instance_setting.proto | 2 -- server/router/api/v1/instance_service.go | 2 -- .../components/MemoEditor/hooks/useMemoSave.ts | 3 ++- web/src/components/MemoEditor/index.tsx | 4 +--- .../components/Settings/MemoRelatedSettings.tsx | 7 ------- web/src/locales/ar.json | 1 - web/src/locales/ca.json | 1 - web/src/locales/cs.json | 1 - web/src/locales/de.json | 1 - web/src/locales/en.json | 1 - web/src/locales/es.json | 1 - web/src/locales/fa.json | 1 - web/src/locales/fr.json | 1 - web/src/locales/hi.json | 1 - web/src/locales/hr.json | 1 - web/src/locales/hu.json | 1 - web/src/locales/id.json | 1 - web/src/locales/it.json | 1 - web/src/locales/ja.json | 1 - web/src/locales/ka-GE.json | 1 - web/src/locales/ko.json | 1 - web/src/locales/mr.json | 1 - web/src/locales/nb.json | 1 - web/src/locales/nl.json | 1 - web/src/locales/pl.json | 1 - web/src/locales/pt-BR.json | 1 - web/src/locales/pt-PT.json | 1 - web/src/locales/sl.json | 1 - web/src/locales/sv.json | 1 - web/src/locales/th.json | 1 - web/src/locales/tr.json | 1 - web/src/locales/uk.json | 1 - web/src/locales/vi.json | 1 - web/src/locales/zh-Hans.json | 1 - web/src/locales/zh-Hant.json | 1 - web/src/types/proto/api/v1/instance_service.ts | 15 --------------- 40 files changed, 8 insertions(+), 90 deletions(-) diff --git a/proto/api/v1/instance_service.proto b/proto/api/v1/instance_service.proto index 55303a688..1101c9a62 100644 --- a/proto/api/v1/instance_service.proto +++ b/proto/api/v1/instance_service.proto @@ -163,8 +163,6 @@ message InstanceSetting { bool enable_link_preview = 5; // reactions is the list of reactions. repeated string reactions = 7; - // disable_markdown_shortcuts disallow the registration of markdown shortcuts. - bool disable_markdown_shortcuts = 8; // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). bool enable_blur_nsfw_content = 9; // nsfw_tags is the list of tags that mark content as NSFW for blurring. diff --git a/proto/gen/api/v1/instance_service.pb.go b/proto/gen/api/v1/instance_service.pb.go index b7530da46..014e88bd2 100644 --- a/proto/gen/api/v1/instance_service.pb.go +++ b/proto/gen/api/v1/instance_service.pb.go @@ -667,8 +667,6 @@ type InstanceSetting_MemoRelatedSetting struct { EnableLinkPreview bool `protobuf:"varint,5,opt,name=enable_link_preview,json=enableLinkPreview,proto3" json:"enable_link_preview,omitempty"` // reactions is the list of reactions. Reactions []string `protobuf:"bytes,7,rep,name=reactions,proto3" json:"reactions,omitempty"` - // disable_markdown_shortcuts disallow the registration of markdown shortcuts. - DisableMarkdownShortcuts bool `protobuf:"varint,8,opt,name=disable_markdown_shortcuts,json=disableMarkdownShortcuts,proto3" json:"disable_markdown_shortcuts,omitempty"` // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). EnableBlurNsfwContent bool `protobuf:"varint,9,opt,name=enable_blur_nsfw_content,json=enableBlurNsfwContent,proto3" json:"enable_blur_nsfw_content,omitempty"` // nsfw_tags is the list of tags that mark content as NSFW for blurring. @@ -749,13 +747,6 @@ func (x *InstanceSetting_MemoRelatedSetting) GetReactions() []string { return nil } -func (x *InstanceSetting_MemoRelatedSetting) GetDisableMarkdownShortcuts() bool { - if x != nil { - return x.DisableMarkdownShortcuts - } - return false -} - func (x *InstanceSetting_MemoRelatedSetting) GetEnableBlurNsfwContent() bool { if x != nil { return x.EnableBlurNsfwContent @@ -935,7 +926,7 @@ const file_api_v1_instance_service_proto_rawDesc = "" + "\aversion\x18\x02 \x01(\tR\aversion\x12\x12\n" + "\x04mode\x18\x03 \x01(\tR\x04mode\x12!\n" + "\finstance_url\x18\x06 \x01(\tR\vinstanceUrl\"\x1b\n" + - "\x19GetInstanceProfileRequest\"\x8b\x11\n" + + "\x19GetInstanceProfileRequest\"\xcd\x10\n" + "\x0fInstanceSetting\x12\x17\n" + "\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12W\n" + "\x0fgeneral_setting\x18\x02 \x01(\v2,.memos.api.v1.InstanceSetting.GeneralSettingH\x00R\x0egeneralSetting\x12W\n" + @@ -972,15 +963,14 @@ const file_api_v1_instance_service_proto_rawDesc = "" + "\x18STORAGE_TYPE_UNSPECIFIED\x10\x00\x12\f\n" + "\bDATABASE\x10\x01\x12\t\n" + "\x05LOCAL\x10\x02\x12\x06\n" + - "\x02S3\x10\x03\x1a\xd8\x03\n" + + "\x02S3\x10\x03\x1a\x9a\x03\n" + "\x12MemoRelatedSetting\x12<\n" + "\x1adisallow_public_visibility\x18\x01 \x01(\bR\x18disallowPublicVisibility\x127\n" + "\x18display_with_update_time\x18\x02 \x01(\bR\x15displayWithUpdateTime\x120\n" + "\x14content_length_limit\x18\x03 \x01(\x05R\x12contentLengthLimit\x127\n" + "\x18enable_double_click_edit\x18\x04 \x01(\bR\x15enableDoubleClickEdit\x12.\n" + "\x13enable_link_preview\x18\x05 \x01(\bR\x11enableLinkPreview\x12\x1c\n" + - "\treactions\x18\a \x03(\tR\treactions\x12<\n" + - "\x1adisable_markdown_shortcuts\x18\b \x01(\bR\x18disableMarkdownShortcuts\x127\n" + + "\treactions\x18\a \x03(\tR\treactions\x127\n" + "\x18enable_blur_nsfw_content\x18\t \x01(\bR\x15enableBlurNsfwContent\x12\x1b\n" + "\tnsfw_tags\x18\n" + " \x03(\tR\bnsfwTags\"F\n" + diff --git a/proto/gen/openapi.yaml b/proto/gen/openapi.yaml index 150b3a68b..9927c8ccf 100644 --- a/proto/gen/openapi.yaml +++ b/proto/gen/openapi.yaml @@ -2344,9 +2344,6 @@ components: items: type: string description: reactions is the list of reactions. - disableMarkdownShortcuts: - type: boolean - description: disable_markdown_shortcuts disallow the registration of markdown shortcuts. enableBlurNsfwContent: type: boolean description: enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). diff --git a/proto/gen/store/instance_setting.pb.go b/proto/gen/store/instance_setting.pb.go index 924d9799b..7146b04d1 100644 --- a/proto/gen/store/instance_setting.pb.go +++ b/proto/gen/store/instance_setting.pb.go @@ -671,8 +671,6 @@ type InstanceMemoRelatedSetting struct { EnableLinkPreview bool `protobuf:"varint,5,opt,name=enable_link_preview,json=enableLinkPreview,proto3" json:"enable_link_preview,omitempty"` // reactions is the list of reactions. Reactions []string `protobuf:"bytes,7,rep,name=reactions,proto3" json:"reactions,omitempty"` - // disable markdown shortcuts - DisableMarkdownShortcuts bool `protobuf:"varint,8,opt,name=disable_markdown_shortcuts,json=disableMarkdownShortcuts,proto3" json:"disable_markdown_shortcuts,omitempty"` // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). EnableBlurNsfwContent bool `protobuf:"varint,9,opt,name=enable_blur_nsfw_content,json=enableBlurNsfwContent,proto3" json:"enable_blur_nsfw_content,omitempty"` // nsfw_tags is the list of tags that mark content as NSFW for blurring. @@ -753,13 +751,6 @@ func (x *InstanceMemoRelatedSetting) GetReactions() []string { return nil } -func (x *InstanceMemoRelatedSetting) GetDisableMarkdownShortcuts() bool { - if x != nil { - return x.DisableMarkdownShortcuts - } - return false -} - func (x *InstanceMemoRelatedSetting) GetEnableBlurNsfwContent() bool { if x != nil { return x.EnableBlurNsfwContent @@ -821,15 +812,14 @@ const file_store_instance_setting_proto_rawDesc = "" + "\bendpoint\x18\x03 \x01(\tR\bendpoint\x12\x16\n" + "\x06region\x18\x04 \x01(\tR\x06region\x12\x16\n" + "\x06bucket\x18\x05 \x01(\tR\x06bucket\x12$\n" + - "\x0euse_path_style\x18\x06 \x01(\bR\fusePathStyle\"\xe0\x03\n" + + "\x0euse_path_style\x18\x06 \x01(\bR\fusePathStyle\"\xa2\x03\n" + "\x1aInstanceMemoRelatedSetting\x12<\n" + "\x1adisallow_public_visibility\x18\x01 \x01(\bR\x18disallowPublicVisibility\x127\n" + "\x18display_with_update_time\x18\x02 \x01(\bR\x15displayWithUpdateTime\x120\n" + "\x14content_length_limit\x18\x03 \x01(\x05R\x12contentLengthLimit\x127\n" + "\x18enable_double_click_edit\x18\x04 \x01(\bR\x15enableDoubleClickEdit\x12.\n" + "\x13enable_link_preview\x18\x05 \x01(\bR\x11enableLinkPreview\x12\x1c\n" + - "\treactions\x18\a \x03(\tR\treactions\x12<\n" + - "\x1adisable_markdown_shortcuts\x18\b \x01(\bR\x18disableMarkdownShortcuts\x127\n" + + "\treactions\x18\a \x03(\tR\treactions\x127\n" + "\x18enable_blur_nsfw_content\x18\t \x01(\bR\x15enableBlurNsfwContent\x12\x1b\n" + "\tnsfw_tags\x18\n" + " \x03(\tR\bnsfwTags*q\n" + diff --git a/proto/store/instance_setting.proto b/proto/store/instance_setting.proto index 0fa0f5b02..a9ea9c1c1 100644 --- a/proto/store/instance_setting.proto +++ b/proto/store/instance_setting.proto @@ -108,8 +108,6 @@ message InstanceMemoRelatedSetting { bool enable_link_preview = 5; // reactions is the list of reactions. repeated string reactions = 7; - // disable markdown shortcuts - bool disable_markdown_shortcuts = 8; // enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). bool enable_blur_nsfw_content = 9; // nsfw_tags is the list of tags that mark content as NSFW for blurring. diff --git a/server/router/api/v1/instance_service.go b/server/router/api/v1/instance_service.go index 116107b51..b40f845ea 100644 --- a/server/router/api/v1/instance_service.go +++ b/server/router/api/v1/instance_service.go @@ -261,7 +261,6 @@ func convertInstanceMemoRelatedSettingFromStore(setting *storepb.InstanceMemoRel EnableDoubleClickEdit: setting.EnableDoubleClickEdit, EnableLinkPreview: setting.EnableLinkPreview, Reactions: setting.Reactions, - DisableMarkdownShortcuts: setting.DisableMarkdownShortcuts, EnableBlurNsfwContent: setting.EnableBlurNsfwContent, NsfwTags: setting.NsfwTags, } @@ -278,7 +277,6 @@ func convertInstanceMemoRelatedSettingToStore(setting *v1pb.InstanceSetting_Memo EnableDoubleClickEdit: setting.EnableDoubleClickEdit, EnableLinkPreview: setting.EnableLinkPreview, Reactions: setting.Reactions, - DisableMarkdownShortcuts: setting.DisableMarkdownShortcuts, EnableBlurNsfwContent: setting.EnableBlurNsfwContent, NsfwTags: setting.NsfwTags, } diff --git a/web/src/components/MemoEditor/hooks/useMemoSave.ts b/web/src/components/MemoEditor/hooks/useMemoSave.ts index 5981ea7cf..16f3731e3 100644 --- a/web/src/components/MemoEditor/hooks/useMemoSave.ts +++ b/web/src/components/MemoEditor/hooks/useMemoSave.ts @@ -6,6 +6,7 @@ import { memoServiceClient } from "@/grpcweb"; import { attachmentStore, memoStore } from "@/store"; import { Attachment } from "@/types/proto/api/v1/attachment_service"; import type { Location, Memo, MemoRelation, Visibility } from "@/types/proto/api/v1/memo_service"; +import type { Translations } from "@/utils/i18n"; interface MemoSaveContext { /** Current memo name (for update mode) */ @@ -40,7 +41,7 @@ interface MemoSaveCallbacks { /** Called to reset after save */ onReset: () => void; /** Translation function */ - t: (key: string) => string; + t: (key: Translations, params?: Record) => string; } /** diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx index e232c30f0..a3bd2288b 100644 --- a/web/src/components/MemoEditor/index.tsx +++ b/web/src/components/MemoEditor/index.tsx @@ -209,9 +209,7 @@ const MemoEditor = observer((props: MemoEditorProps) => { handleSaveBtnClick(); return; } - if (!instanceMemoRelatedSetting.disableMarkdownShortcuts) { - handleEditorKeydownWithMarkdownShortcuts(event, editorRef.current); - } + handleEditorKeydownWithMarkdownShortcuts(event, editorRef.current); } if (event.key === "Tab" && !state.isComposing) { event.preventDefault(); diff --git a/web/src/components/Settings/MemoRelatedSettings.tsx b/web/src/components/Settings/MemoRelatedSettings.tsx index 05697a93a..65dcaf7c1 100644 --- a/web/src/components/Settings/MemoRelatedSettings.tsx +++ b/web/src/components/Settings/MemoRelatedSettings.tsx @@ -98,13 +98,6 @@ const MemoRelatedSettings = observer(() => { /> - - updatePartialSetting({ disableMarkdownShortcuts: checked })} - /> - - e) || []; - message.disableMarkdownShortcuts = object.disableMarkdownShortcuts ?? false; message.enableBlurNsfwContent = object.enableBlurNsfwContent ?? false; message.nsfwTags = object.nsfwTags?.map((e) => e) || []; return message;