Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions apps/web/src/components/workplane/ShortcutsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,27 @@ function comboKeys(combo: string) {
return parts.length > 0 ? parts : [combo];
}

function ShortcutKeys({ combos }: { combos: string[] }) {
/**
* Whether the keyboard is an Apple one - a Mac, or an iPad with a keyboard,
* which reports itself as a Mac. Browsers do not say "Darwin"; the user agent
* says Macintosh. The editor takes Cmd wherever it takes Ctrl, and Option is
* Alt, so the list shows the keys under the names on that keyboard.
*/
function appleKeyboard() {
return typeof navigator !== "undefined" && /Macintosh|Mac OS X|iPhone|iPad|iPod/.test(navigator.userAgent);
}

const APPLE_KEY_NAMES: Record<string, string> = { Ctrl: "Cmd", Alt: "Option" };

function keyLabel(key: string, apple: boolean) {
if (key === "Click") return t("shortcuts.click");
if (key === "RightClick") return t("shortcuts.rightClick");
if (key === "Drag") return t("shortcuts.drag");
if (key === "Wheel") return t("shortcuts.wheel");
return apple ? APPLE_KEY_NAMES[key] ?? key : key;
}

function ShortcutKeys({ combos, apple }: { combos: string[]; apple: boolean }) {
return (
<>
{combos.map((combo, comboIndex) => (
Expand All @@ -195,7 +215,7 @@ function ShortcutKeys({ combos }: { combos: string[] }) {
{comboKeys(combo).map((key, keyIndex) => (
<Fragment key={key}>
{keyIndex > 0 ? <span className="shortcuts-plus" aria-hidden="true">+</span> : null}
<kbd>{key === "Click" ? t("shortcuts.click") : key === "RightClick" ? t("shortcuts.rightClick") : key === "Drag" ? t("shortcuts.drag") : key === "Wheel" ? t("shortcuts.wheel") : key}</kbd>
<kbd>{keyLabel(key, apple)}</kbd>
</Fragment>
))}
</span>
Expand All @@ -207,6 +227,7 @@ function ShortcutKeys({ combos }: { combos: string[] }) {

/** The groups with their rows, the same markup in the window and on the printed sheet. */
function ShortcutGroups({ groups }: { groups: ShortcutGroup[] }) {
const apple = appleKeyboard();
return (
<div className="shortcuts-groups">
{groups.map((group) => (
Expand All @@ -217,7 +238,7 @@ function ShortcutGroups({ groups }: { groups: ShortcutGroup[] }) {
<div className="shortcuts-row" key={`${group.title}:${shortcut.label}`}>
<dt>{t(shortcut.label)}</dt>
<dd>
<ShortcutKeys combos={shortcut.combos} />
<ShortcutKeys combos={shortcut.combos} apple={apple} />
</dd>
</div>
))}
Expand Down Expand Up @@ -309,9 +330,6 @@ export function ShortcutsModal({ sketchMode, onClose }: { sketchMode: boolean; o
<p className="shortcuts-intro">{t("shortcuts.intro")}</p>
<ShortcutGroups groups={groups} />
</div>
<div className="workspace-modal-footer">
<span>{t("shortcuts.footer")}</span>
</div>
</div>
</div>
<button className="workspace-modal-backdrop" aria-label={t("shortcuts.close")} onClick={onClose} />
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ export const MESSAGES_AR: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "نقرة",
"shortcuts.rightClick": "نقرة بالزر الأيمن",
"shortcuts.drag": "سحب",
"shortcuts.footer": "على أجهزة Mac، استخدم Cmd أينما كُتب Ctrl.",
"shortcuts.group.selection": "التحديد",
"shortcuts.group.clipboard": "الحافظة",
"shortcuts.group.history": "السجل",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ export const MESSAGES_CS: Record<MessageKey, string> = {
"shortcuts.click": "Kliknutí",
"shortcuts.rightClick": "Pravé tlačítko",
"shortcuts.drag": "Tažení",
"shortcuts.footer": "Na Macu použijte Cmd místo uvedeného Ctrl.",
"shortcuts.group.selection": "Výběr",
"shortcuts.group.clipboard": "Schránka",
"shortcuts.group.history": "Historie",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ export const MESSAGES_DA: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Klik",
"shortcuts.rightClick": "Højreklik",
"shortcuts.drag": "Træk",
"shortcuts.footer": "På en Mac, brug Cmd hvor end der står Ctrl.",
"shortcuts.group.selection": "Markering",
"shortcuts.group.clipboard": "Udklipsholder",
"shortcuts.group.history": "Historik",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ export const MESSAGES_DE: Record<MessageKey, string> = {
"shortcuts.click": "Klick",
"shortcuts.rightClick": "Rechtsklick",
"shortcuts.drag": "Ziehen",
"shortcuts.footer": "Auf dem Mac gilt überall dort Cmd, wo Ctrl steht.",
"shortcuts.group.selection": "Auswahl",
"shortcuts.group.clipboard": "Zwischenablage",
"shortcuts.group.history": "Verlauf",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@ export const MESSAGES_EN = {
"shortcuts.click": "Click",
"shortcuts.rightClick": "Right click",
"shortcuts.drag": "Drag",
"shortcuts.footer": "On a Mac, use Cmd wherever Ctrl is listed.",
"shortcuts.group.selection": "Selection",
"shortcuts.group.clipboard": "Clipboard",
"shortcuts.group.history": "History",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ export const MESSAGES_FR: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Cliquez",
"shortcuts.rightClick": "Clic droit",
"shortcuts.drag": "Faites glisser",
"shortcuts.footer": "Sur un Mac, utilisez Cmd partout où Ctrl est répertorié.",
"shortcuts.group.selection": "Sélection",
"shortcuts.group.clipboard": "Presse-papiers",
"shortcuts.group.history": "Histoire",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ export const MESSAGES_HU: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Kattintás",
"shortcuts.rightClick": "Jobb kattintás",
"shortcuts.drag": "Húzás",
"shortcuts.footer": "Macen a Ctrl helyett mindenhol a Cmd-t használd.",
"shortcuts.group.selection": "Kijelölés",
"shortcuts.group.clipboard": "Vágólap",
"shortcuts.group.history": "Előzmények",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ export const MESSAGES_IT: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Clic",
"shortcuts.rightClick": "Clic destro",
"shortcuts.drag": "Trascina",
"shortcuts.footer": "Su Mac, usa Cmd al posto di Ctrl quando indicato.",
"shortcuts.group.selection": "Selezione",
"shortcuts.group.clipboard": "Appunti",
"shortcuts.group.history": "Cronologia",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ export const MESSAGES_JA: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "クリック",
"shortcuts.rightClick": "右クリック",
"shortcuts.drag": "ドラッグ",
"shortcuts.footer": "Macでは、Ctrlと書かれている箇所でCmdを使ってください。",
"shortcuts.group.selection": "選択",
"shortcuts.group.clipboard": "クリップボード",
"shortcuts.group.history": "履歴",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ export const MESSAGES_NL: Record<MessageKey, string> = {
"shortcuts.click": "Klik",
"shortcuts.rightClick": "Rechtsklik",
"shortcuts.drag": "Slepen",
"shortcuts.footer": "Gebruik op een Mac Cmd overal waar Ctrl staat.",
"shortcuts.group.selection": "Selectie",
"shortcuts.group.clipboard": "Klembord",
"shortcuts.group.history": "Geschiedenis",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ export const MESSAGES_PL: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Klik",
"shortcuts.rightClick": "Prawy klik",
"shortcuts.drag": "Przeciągnij",
"shortcuts.footer": "Na Macu używaj Cmd wszędzie tam, gdzie podano Ctrl.",
"shortcuts.group.selection": "Zaznaczanie",
"shortcuts.group.clipboard": "Schowek",
"shortcuts.group.history": "Historia",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,6 @@ export const MESSAGES_PT_BR: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Clique",
"shortcuts.rightClick": "Clique direito",
"shortcuts.drag": "Arraste",
"shortcuts.footer": "No Mac, use Cmd onde aparece Ctrl.",
"shortcuts.group.selection": "Seleção",
"shortcuts.group.clipboard": "Área de transferência",
"shortcuts.group.history": "Histórico",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ export const MESSAGES_RU: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Щелчок",
"shortcuts.rightClick": "Правый щелчок",
"shortcuts.drag": "Перетаскивание",
"shortcuts.footer": "На Mac используйте Cmd везде, где указан Ctrl.",
"shortcuts.group.selection": "Выделение",
"shortcuts.group.clipboard": "Буфер обмена",
"shortcuts.group.history": "История",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.sl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ export const MESSAGES_SL: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Klik",
"shortcuts.rightClick": "Desni klik",
"shortcuts.drag": "Vleci",
"shortcuts.footer": "Na Macu uporabi Cmd povsod, kjer je navedeno Ctrl.",
"shortcuts.group.selection": "Izbor",
"shortcuts.group.clipboard": "Odložišče",
"shortcuts.group.history": "Zgodovina",
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/lib/messages.tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ export const MESSAGES_TR: Partial<Record<MessageKey, string>> = {
"shortcuts.click": "Tık",
"shortcuts.rightClick": "Sağ tık",
"shortcuts.drag": "Sürükle",
"shortcuts.footer": "Mac'te Ctrl yazan her yerde Cmd kullan.",
"shortcuts.group.selection": "Seçim",
"shortcuts.group.clipboard": "Pano",
"shortcuts.group.history": "Geçmiş",
Expand Down
Loading