Skip to content

Commit 8f170a2

Browse files
committed
feat: keyboard shortcut info inside formatter's tooltip
1 parent 89e85b7 commit 8f170a2

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
export const formatter = [
2-
{ name: 'bold', pattern: '*{{text}}*', tooltip: 'Bold' },
3-
{ name: 'italic', pattern: '_{{text}}_', tooltip: 'Italic' },
4-
{ name: 'strike', pattern: '~{{text}}~', tooltip: 'Strikethrough' },
5-
{ name: 'code', pattern: '`{{text}}`', tooltip: 'Inline code' },
6-
{
7-
name: 'multiline',
8-
pattern: '```\n{{text}}\n```',
9-
tooltip: 'Multi-line code',
10-
},
2+
{ name: 'bold', pattern: '*{{text}}*', tooltip: 'Bold', shortcut: 'Ctrl + B' },
3+
{ name: 'italic', pattern: '_{{text}}_', tooltip: 'Italic', shortcut: 'Ctrl + I' },
4+
{ name: 'strike', pattern: '~{{text}}~', tooltip: 'Strikethrough', shortcut: '' },
5+
{ name: 'code', pattern: '`{{text}}`', tooltip: 'Inline code', shortcut: '' },
6+
{ name: 'multiline', pattern: '```\n{{text}}\n```', tooltip: 'Multi-line code', shortcut: ''}
117
];

packages/react/src/views/ChatInput/ChatInputFormattingToolbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const ChatInputFormattingToolbar = ({
214214
</>
215215
) : (
216216
<Tooltip
217-
text={item.name}
217+
text={`${item.name} ${item.shortcut && `(${item.shortcut})`}`}
218218
position="top"
219219
key={`formatter-${item.name}`}
220220
>
@@ -294,7 +294,7 @@ const ChatInputFormattingToolbar = ({
294294
if (itemInFormatter) {
295295
return (
296296
<Tooltip
297-
text={itemInFormatter.name}
297+
text={`${itemInFormatter.name} ${itemInFormatter.shortcut && `(${itemInFormattershortcut})`}`}
298298
position="top"
299299
key={`formatter-${itemInFormatter.name}`}
300300
>

0 commit comments

Comments
 (0)