Skip to content

Commit 457b7b2

Browse files
committed
docs: add cheatsheet JSON schema for KoalaKeys to define and validate cheatsheet structure
1 parent 7c20525 commit 457b7b2

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

docs/schema/cheatsheet.schema.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://rtuszik.github.io/KoalaKeys/schema/cheatsheet.schema.json",
4+
"title": "KoalaKeys Cheatsheet",
5+
"description": "Schema for KoalaKeys YAML cheatsheets.",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"required": ["title", "layout", "shortcuts"],
9+
"properties": {
10+
"title": {
11+
"type": "string",
12+
"minLength": 1,
13+
"description": "Title of the cheatsheet."
14+
},
15+
"RenderKeys": {
16+
"type": "boolean",
17+
"default": true,
18+
"description": "When true (default), render keyboard layout with highlighted keys."
19+
},
20+
"AllowText": {
21+
"type": "boolean",
22+
"default": false,
23+
"description": "When true, free-form shortcut text is allowed; requires RenderKeys=false."
24+
},
25+
"layout": {
26+
"type": "object",
27+
"additionalProperties": false,
28+
"required": ["keyboard", "system"],
29+
"properties": {
30+
"keyboard": {
31+
"type": "string",
32+
"enum": ["US", "UK", "DE", "FR", "ES"],
33+
"description": "Keyboard layout."
34+
},
35+
"system": {
36+
"type": "string",
37+
"enum": ["Darwin", "Windows", "Linux"],
38+
"description": "Operating system."
39+
}
40+
}
41+
},
42+
"shortcuts": {
43+
"type": "object",
44+
"minProperties": 1,
45+
"description": "Categories mapped to shortcut definitions.",
46+
"additionalProperties": {
47+
"type": "object",
48+
"minProperties": 1
49+
}
50+
}
51+
},
52+
"allOf": [
53+
{
54+
"description": "AllowText=true requires RenderKeys=false.",
55+
"if": {
56+
"properties": { "AllowText": { "const": true } },
57+
"required": ["AllowText"]
58+
},
59+
"then": {
60+
"properties": {
61+
"RenderKeys": { "const": false },
62+
"shortcuts": {
63+
"additionalProperties": {
64+
"additionalProperties": { "$ref": "#/$defs/shortcutEntry" }
65+
}
66+
}
67+
}
68+
}
69+
},
70+
{
71+
"description": "When AllowText is not true, restrict shortcut key syntax.",
72+
"if": {
73+
"not": {
74+
"properties": { "AllowText": { "const": true } },
75+
"required": ["AllowText"]
76+
}
77+
},
78+
"then": {
79+
"properties": {
80+
"shortcuts": {
81+
"additionalProperties": {
82+
"type": "object",
83+
"minProperties": 1,
84+
"patternProperties": {
85+
"^[A-Za-z0-9+⌘⌥⌃⇧←→↑↓\\s\\-\\|\\[\\],.:/`\"?<>=\\\\⌃]+$": {
86+
"$ref": "#/$defs/shortcutEntry"
87+
}
88+
},
89+
"additionalProperties": false
90+
}
91+
}
92+
}
93+
}
94+
}
95+
],
96+
"$defs": {
97+
"shortcutEntry": {
98+
"type": "object",
99+
"additionalProperties": false,
100+
"required": ["description"],
101+
"properties": {
102+
"description": {
103+
"type": "string",
104+
"minLength": 1,
105+
"description": "Human-readable description of the shortcut."
106+
}
107+
},
108+
"examples": [
109+
{ "description": "Copy selected item" }
110+
]
111+
}
112+
},
113+
"examples": [
114+
{
115+
"title": "KoalaKeys",
116+
"RenderKeys": true,
117+
"AllowText": false,
118+
"layout": { "keyboard": "US", "system": "Darwin" },
119+
"shortcuts": {
120+
"General": {
121+
"CMD+C": { "description": "Copy selected item" },
122+
"CMD+Right": { "description": "Move cursor to end of line" }
123+
}
124+
}
125+
}
126+
]
127+
}
128+

0 commit comments

Comments
 (0)