mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-16 12:10:28 +03:00
Room input improvements (#1502)
* prevent context menu when editing message * send sticker body (#1479) * update emojiboard search text reaction input label * stop generating upload image thumbnail (#1475) * maintain upload order * Fix message options spinner variant * add markdown toggle in editor toolbar * fix heading toggle icon update with cursor move * add hotkeys for heading * change editor markdown btn style * use Ctrl + Enter to send message (#1470) * fix reaction tooltip word-break * add shift in editor hokeys with number * stop parsing markdown in link
This commit is contained in:
parent
c7e5c1fce8
commit
2957a45c4b
13 changed files with 162 additions and 71 deletions
|
|
@ -15,12 +15,15 @@ export const INLINE_HOTKEYS: Record<string, MarkType> = {
|
|||
const INLINE_KEYS = Object.keys(INLINE_HOTKEYS);
|
||||
|
||||
export const BLOCK_HOTKEYS: Record<string, BlockType> = {
|
||||
'mod+7': BlockType.OrderedList,
|
||||
'mod+8': BlockType.UnorderedList,
|
||||
'mod+shift+7': BlockType.OrderedList,
|
||||
'mod+shift+8': BlockType.UnorderedList,
|
||||
"mod+'": BlockType.BlockQuote,
|
||||
'mod+;': BlockType.CodeBlock,
|
||||
};
|
||||
const BLOCK_KEYS = Object.keys(BLOCK_HOTKEYS);
|
||||
const isHeading1 = isKeyHotkey('mod+shift+1');
|
||||
const isHeading2 = isKeyHotkey('mod+shift+2');
|
||||
const isHeading3 = isKeyHotkey('mod+shift+3');
|
||||
|
||||
/**
|
||||
* @return boolean true if shortcut is toggled.
|
||||
|
|
@ -86,6 +89,18 @@ export const toggleKeyboardShortcut = (editor: Editor, event: KeyboardEvent<Elem
|
|||
return false;
|
||||
});
|
||||
if (blockToggled) return true;
|
||||
if (isHeading1(event)) {
|
||||
toggleBlock(editor, BlockType.Heading, { level: 1 });
|
||||
return true;
|
||||
}
|
||||
if (isHeading2(event)) {
|
||||
toggleBlock(editor, BlockType.Heading, { level: 2 });
|
||||
return true;
|
||||
}
|
||||
if (isHeading3(event)) {
|
||||
toggleBlock(editor, BlockType.Heading, { level: 3 });
|
||||
return true;
|
||||
}
|
||||
|
||||
const inlineToggled = isBlockActive(editor, BlockType.CodeBlock)
|
||||
? false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue