mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-05 17:25:53 +02:00
Display some shortcut keywords as unicode characters in the documentation (#2136)
This commit is contained in:
committed by
GitHub
parent
e99d77cb04
commit
dec919bcfb
@@ -30,9 +30,10 @@ const WINDOWS_USER_AGENT =
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36";
|
||||
const LINUX_USER_AGENT =
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36";
|
||||
const NO_USER_AGENT = "";
|
||||
|
||||
describe("splitKeyCombination", () => {
|
||||
it("should split and replace correctly", () => {
|
||||
it("should split and replace correctly based on user agent", () => {
|
||||
expect(splitKeyCombination("alt+a meta+b meta+c", WINDOWS_USER_AGENT)).toEqual([
|
||||
"alt",
|
||||
"a",
|
||||
@@ -51,6 +52,10 @@ describe("splitKeyCombination", () => {
|
||||
"ctrl",
|
||||
"d",
|
||||
]);
|
||||
expect(splitKeyCombination("alt+a meta+b mod+c", MAC_USER_AGENT)).toEqual(["option", "a", "⌘", "b", "⌘", "c"]);
|
||||
expect(splitKeyCombination("alt+a meta+b mod+c", MAC_USER_AGENT)).toEqual(["⌥", "a", "⌘", "b", "⌘", "c"]);
|
||||
});
|
||||
|
||||
it("should replace arrow key keywords with unicode characters", () => {
|
||||
expect(splitKeyCombination("up down left right", NO_USER_AGENT)).toEqual(["↑", "↓", "←", "→"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,8 +30,13 @@ export default function splitKeyCombination(key: string, userAgent = window.navi
|
||||
} = parser(userAgent);
|
||||
const isMacOS = osName === "Mac OS";
|
||||
return key
|
||||
.replace(/(option|alt)/g, isMacOS ? "option" : "alt")
|
||||
.replace(/(option|alt)/g, isMacOS ? "⌥" : "alt")
|
||||
.replace(/(command|meta)/g, isMacOS ? "⌘" : "meta")
|
||||
.replace("mod", isMacOS ? "⌘" : "ctrl")
|
||||
.replace(/shift/g, "⇧")
|
||||
.replace(/up/g, "↑")
|
||||
.replace(/down/g, "↓")
|
||||
.replace(/left/g, "←")
|
||||
.replace(/right/g, "→")
|
||||
.split(/[+ ]/);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user