1+ import { msg } from '@lingui/core/macro' ;
2+ import { useLingui } from '@lingui/react' ;
13import { NodeIcon } from '@uipath/apollo-react/canvas' ;
24import { ApTooltip } from '@uipath/apollo-react/material/components' ;
3- import { memo , type RefObject , useCallback } from 'react' ;
5+ import { memo , type RefObject , useCallback , useMemo } from 'react' ;
46import type { ActiveFormats } from './markdown-formatting' ;
57import {
68 toggleBold ,
@@ -16,6 +18,10 @@ import {
1618} from './StickyNoteNode.styles' ;
1719import type { TextSelection } from './StickyNoteNode.types' ;
1820
21+ const isMac = ( ) => typeof navigator !== 'undefined' && / M a c / . test ( navigator . userAgent ) ;
22+
23+ const getModifierKey = ( ) => ( isMac ( ) ? '⌘' : 'Ctrl+' ) ;
24+
1925interface FormattingToolbarProps {
2026 textAreaRef : RefObject < HTMLTextAreaElement | null > ;
2127 borderColor : string ;
@@ -29,6 +35,9 @@ const FormattingToolbarComponent = ({
2935 activeFormats,
3036 onFormat,
3137} : FormattingToolbarProps ) => {
38+ const { _ } = useLingui ( ) ;
39+ const mod = useMemo ( ( ) => getModifierKey ( ) , [ ] ) ;
40+
3241 const applyFormat = useCallback (
3342 ( formatFn : ( input : TextSelection ) => TextSelection ) => {
3443 const textarea = textAreaRef . current ;
@@ -52,36 +61,75 @@ const FormattingToolbarComponent = ({
5261 const handleBulletList = useCallback ( ( ) => applyFormat ( toggleBulletList ) , [ applyFormat ] ) ;
5362 const handleNumberedList = useCallback ( ( ) => applyFormat ( toggleNumberedList ) , [ applyFormat ] ) ;
5463
64+ const boldShortcut = `${ mod } B` ;
65+ const italicShortcut = `${ mod } I` ;
66+ const strikethroughShortcut = `${ mod } ⇧X` ;
67+
5568 return (
5669 < FormattingToolbarContainer
5770 borderColor = { borderColor }
5871 onMouseDown = { ( e ) => e . preventDefault ( ) }
5972 className = "nodrag nowheel"
6073 >
61- < ApTooltip content = "Bold (⌘B)" placement = "top" delay >
74+ < ApTooltip
75+ content = { _ (
76+ msg ( {
77+ id : 'sticky-note.formatting.bold' ,
78+ message : `Bold (${ boldShortcut } )` ,
79+ } )
80+ ) }
81+ placement = "top"
82+ delay
83+ >
6284 < FormattingButton isActive = { activeFormats . bold } onClick = { handleBold } >
6385 < NodeIcon icon = "bold" size = { 14 } />
6486 </ FormattingButton >
6587 </ ApTooltip >
66- < ApTooltip content = "Italic (⌘I)" placement = "top" delay >
88+ < ApTooltip
89+ content = { _ (
90+ msg ( {
91+ id : 'sticky-note.formatting.italic' ,
92+ message : `Italic (${ italicShortcut } )` ,
93+ } )
94+ ) }
95+ placement = "top"
96+ delay
97+ >
6798 < FormattingButton isActive = { activeFormats . italic } onClick = { handleItalic } >
6899 < NodeIcon icon = "italic" size = { 14 } />
69100 </ FormattingButton >
70101 </ ApTooltip >
71- < ApTooltip content = "Strikethrough (⌘⇧X)" placement = "top" delay >
102+ < ApTooltip
103+ content = { _ (
104+ msg ( {
105+ id : 'sticky-note.formatting.strikethrough' ,
106+ message : `Strikethrough (${ strikethroughShortcut } )` ,
107+ } )
108+ ) }
109+ placement = "top"
110+ delay
111+ >
72112 < FormattingButton isActive = { activeFormats . strikethrough } onClick = { handleStrikethrough } >
73113 < NodeIcon icon = "strikethrough" size = { 14 } />
74114 </ FormattingButton >
75115 </ ApTooltip >
76116
77117 < ToolbarSeparator />
78118
79- < ApTooltip content = "Bullet list" placement = "top" delay >
119+ < ApTooltip
120+ content = { _ ( msg ( { id : 'sticky-note.formatting.bullet-list' , message : 'Bullet list' } ) ) }
121+ placement = "top"
122+ delay
123+ >
80124 < FormattingButton isActive = { activeFormats . bulletList } onClick = { handleBulletList } >
81125 < NodeIcon icon = "list" size = { 14 } />
82126 </ FormattingButton >
83127 </ ApTooltip >
84- < ApTooltip content = "Numbered list" placement = "top" delay >
128+ < ApTooltip
129+ content = { _ ( msg ( { id : 'sticky-note.formatting.numbered-list' , message : 'Numbered list' } ) ) }
130+ placement = "top"
131+ delay
132+ >
85133 < FormattingButton isActive = { activeFormats . numberedList } onClick = { handleNumberedList } >
86134 < NodeIcon icon = "list-ordered" size = { 14 } />
87135 </ FormattingButton >
0 commit comments