Files
TREK/client/src/components/Studio/studioShortcut.ts
T
Maurice 2f4644d434 feat(studio): groups, a layers panel, marquee, nudge, multi-resize, align and paste style
Elements can be grouped on a page and picked, moved, resized, aligned and
restacked as one. A layers panel lists the page front to back with lock,
visibility, rename and drag to restack. The sheet gains marquee selection,
arrow-key nudge, one box that resizes a multi-selection with Shift holding
the proportions, and the design-tool shortcuts. The inspector lines a
selection up and spaces it out, and copies and pastes a style.

The assistant gets the same through the group, ungroup, name and hide
operations, and describe_book_page lists the groups. The format gains the
optional group, name and hidden fields and a spread's group names, so
BOOK_SCHEMA_REV goes to 2.
2026-10-23 19:31:14 +02:00

20 lines
876 B
TypeScript

import { useTranslation } from '../../i18n';
import { isApplePlatform } from '../../utils/applePlatform';
/**
* The keys of a Studio shortcut as the tooltip shows them: ⌘ and ⌥ on a Mac,
* Ctrl and Alt elsewhere, always with the command key first. `alt` stands for
* the option key so callers do not each decide how to spell it.
*/
export function shortcutKeys(apple: boolean, ctrl: string, keys: readonly string[]): string[] {
const mod = apple ? '⌘' : ctrl;
return [mod, ...keys.map((k) => (k === 'alt' ? (apple ? '⌥' : 'Alt') : k))];
}
/** `keys('⇧', 'G')` reads as ⌘ ⇧ G or Ctrl ⇧ G, for the platform the page runs on. */
export function useStudioShortcut(): (...keys: string[]) => string[] {
const { t } = useTranslation();
const apple = isApplePlatform();
return (...keys) => shortcutKeys(apple, t('assistant.launcher.ctrlKey'), keys);
}