From ff4aa48a345f4a9976c6383be86eb3f74d12d184 Mon Sep 17 00:00:00 2001 From: benya Date: Sun, 8 Mar 2026 22:43:09 +0300 Subject: [PATCH] web: add markdown formatting keyboard shortcuts in composer --- docs/core-checklist-status.md | 2 +- web/src/components/MessageComposer.tsx | 35 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/core-checklist-status.md b/docs/core-checklist-status.md index 3a9b412..7052de9 100644 --- a/docs/core-checklist-status.md +++ b/docs/core-checklist-status.md @@ -28,7 +28,7 @@ Legend: 19. Stickers - `PARTIAL` (web sticker picker with preset pack + favorites) 20. GIF - `PARTIAL` (web GIF picker with Tenor search + preset fallback + favorites) 21. Message History/Search - `DONE` (history/pagination/chat+global search) -22. Text Formatting - `PARTIAL` (bold/italic/underline/spoiler/mono/links + strikethrough + quote/code block; toolbar still evolving) +22. Text Formatting - `PARTIAL` (bold/italic/underline/spoiler/mono/links + strikethrough + quote/code block; web composer now supports keyboard shortcuts `Ctrl/Cmd+B/I/U/K`, `Ctrl/Cmd+Shift+X`, `Ctrl/Cmd+Shift+\``; toolbar still evolving) 23. Groups - `PARTIAL` (create/add/remove/invite link; join-by-invite and invite permissions covered by integration tests; members API now returns profile fields (`username/name/avatar_url`) and web Chat Info consumes them to avoid extra per-member profile requests; add-member search also shows avatars; advanced moderation still partial) 24. Roles - `DONE` (owner/admin/member) 25. Admin Rights - `PARTIAL` (delete/pin/edit info + explicit ban APIs for groups/channels including ban list endpoint; web Chat Info now shows searchable `Banned users` with both inline and right-click `Unban` actions for owner/admin, member search, avatars in moderation lists, invite-link copy/regenerate actions, ban metadata (`who banned/when`), explicit member action button for touch/trackpad UX, `@username`-friendly moderation filters, and resilient profile hydration (`allSettled`) for partially missing users; add-member and banned-filters now show explicit empty-state hints; moderation actions (`add/remove/ban/unban/promote/demote/transfer owner`) now force full panel refresh to keep members/bans/counters in sync without manual reopen; integration tests cover channel member read-only, channel admin full-delete, channel message delete-for-all permissions, group profile edit permissions, owner-only role management rules, and admin-visible/member-forbidden ban-list access; remaining UX moderation tools limited) diff --git a/web/src/components/MessageComposer.tsx b/web/src/components/MessageComposer.tsx index 33242d0..034850b 100644 --- a/web/src/components/MessageComposer.tsx +++ b/web/src/components/MessageComposer.tsx @@ -525,6 +525,41 @@ export function MessageComposer() { }, [gifQuery, showGifMenu]); function onComposerKeyDown(event: KeyboardEvent) { + const hasModifier = event.ctrlKey || event.metaKey; + if (hasModifier) { + const key = event.key.toLowerCase(); + if (key === "b") { + event.preventDefault(); + insertFormatting("**", "**"); + return; + } + if (key === "i") { + event.preventDefault(); + insertFormatting("*", "*"); + return; + } + if (key === "u") { + event.preventDefault(); + insertFormatting("__", "__"); + return; + } + if (key === "k") { + event.preventDefault(); + insertLink(); + return; + } + if (event.shiftKey && key === "x") { + event.preventDefault(); + insertFormatting("~~", "~~"); + return; + } + if (event.shiftKey && (event.key === "`" || event.code === "Backquote")) { + event.preventDefault(); + insertFormatting("`", "`"); + return; + } + } + if (event.key !== "Enter") { return; }