Spell out punctuation command shortcuts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Maintainer-controlled web client version.
|
||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||
window.CHGRID_WEB_VERSION = "2026.03.08 R336";
|
||||
window.CHGRID_WEB_VERSION = "2026.03.08 R337";
|
||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { describeCharacter } from './textInput';
|
||||
|
||||
export type ModeInput = {
|
||||
code: string;
|
||||
key: string;
|
||||
@@ -13,7 +15,22 @@ export type CommandDescriptor<CommandId extends string = string> = {
|
||||
section: string;
|
||||
};
|
||||
|
||||
function formatShortcutToken(token: string): string {
|
||||
const trimmed = token.trim();
|
||||
if (trimmed.length === 1) {
|
||||
return describeCharacter(trimmed);
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function formatCommandShortcut(shortcut: string): string {
|
||||
return shortcut
|
||||
.split('+')
|
||||
.map((token) => formatShortcutToken(token))
|
||||
.join('+');
|
||||
}
|
||||
|
||||
/** Formats a palette/menu label as `Name: Key`. */
|
||||
export function formatCommandMenuLabel(command: Pick<CommandDescriptor, 'label' | 'shortcut'>): string {
|
||||
return `${command.label}: ${command.shortcut}`;
|
||||
return `${command.label}: ${formatCommandShortcut(command.shortcut)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user