import * as React from 'react'; import ToolbarButton from '../ToolbarButton/ToolbarButton'; import { ToolbarButtonInfo } from '@joplin/lib/services/commands/ToolbarButtonUtils'; import CommandService from '@joplin/lib/services/CommandService'; import { themeStyle } from '@joplin/lib/theme'; import { AppState } from '../../app.reducer'; import { connect } from 'react-redux'; import { TagEntity } from '@joplin/lib/services/database/types'; import TagList from '../TagList'; import { _ } from '@joplin/lib/locale'; import { useCallback } from 'react'; import KeymapService from '@joplin/lib/services/KeymapService'; interface Props { themeId: number; tabMovesFocus: boolean; noteId: string; setTagsToolbarButtonInfo: ToolbarButtonInfo; selectedNoteTags: TagEntity[]; } interface StatusIndicatorProps { commandName: string; showWhenUnfocused: boolean; // Even if not visible, [label] should reflect the current state // of the indicator. label: string; } const StatusIndicator: React.FC = props => { const runCommand = useCallback(() => { void CommandService.instance().execute(props.commandName); }, [props.commandName]); const keyshortcuts = KeymapService.instance().getAriaKeyShortcuts(props.commandName); return ; }; const StatusBar: React.FC = props => { function renderTagButton() { return ; } function renderTagBar() { const theme = themeStyle(props.themeId); const noteIds = [props.noteId]; const instructions = { void CommandService.instance().execute('setTags', noteIds); }} style={{ ...theme.clickableTextStyle, whiteSpace: 'nowrap' }}>{_('Click to add tags...')}; const tagList = props.selectedNoteTags.length ? : null; return
{renderTagButton()}
{tagList}{instructions}
; } const keyboardStatus = ; return
{renderTagBar()}
{keyboardStatus}
; }; export default connect((state: AppState) => { return { themeId: state.settings.theme, tabMovesFocus: state.settings['editor.tabMovesFocus'], }; })(StatusBar);