@particle-academy/fancy-code 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,7 +42,7 @@ All three sub-components are optional — omit any to render a minimal editor.
42
42
  | readOnly | `boolean` | `false` | Disable editing |
43
43
  | lineNumbers | `boolean` | `true` | Show the gutter with line numbers |
44
44
  | wordWrap | `boolean` | `false` | Wrap long lines instead of horizontal scroll |
45
- | tabSize | `number` | `2` | Number of spaces per tab |
45
+ | tabSize | `number` | `2` | Number of spaces per tab (see [Keyboard](#keyboard)) |
46
46
  | placeholder | `string` | - | Shown when the document is empty |
47
47
  | minHeight | `number` | - | Minimum height in px |
48
48
  | maxHeight | `number` | - | Maximum height in px (scrolls beyond) |
@@ -127,6 +127,21 @@ const [code, setCode] = useState("");
127
127
  </CodeEditor>
128
128
  ```
129
129
 
130
+ ## Keyboard
131
+
132
+ The editor never traps keyboard focus (WCAG 2.1.2):
133
+
134
+ - **Tab is armed by an edit.** Tabbing into the editor and pressing Tab again
135
+ moves focus on, like any other control. Once you edit (type, paste, cut,
136
+ Enter) in that focus session, Tab inserts `tabSize` spaces (or indents the
137
+ selected lines) and Shift+Tab dedents.
138
+ - **Escape disarms.** After Escape, the next Tab leaves the editor. Blurring
139
+ the editor disarms too, so every new visit starts unarmed.
140
+ - **Read-only editors** (`readOnly`, and `FileViewer`) never intercept keys:
141
+ arrows, Home/End, Page Up/Down, copy and Tab / Shift+Tab all behave natively.
142
+ - The editing textarea shows the kit focus ring (`--fancy-focus` /
143
+ `--fancy-focus-dark`) when focused from the keyboard.
144
+
130
145
  ## Read-Only Display
131
146
 
132
147
  ```tsx
package/docs/languages.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Languages
2
2
 
3
- The editor ships with six built-in language tokenizers. Registering new languages is a single function call.
3
+ The editor ships with nine built-in languages. Their tokenizers live in `@particle-academy/fancy-file-commons`, the same grammars react-fancy's `CodeBlock` and `CodeView` use, so a snippet highlights the same way everywhere. Registering new languages is a single function call.
4
4
 
5
5
  ## Built-in Languages
6
6
 
@@ -12,6 +12,9 @@ The editor ships with six built-in language tokenizers. Registering new language
12
12
  | PHP | `"php"` | — |
13
13
  | Python | `"python"` | `"py"` |
14
14
  | Go | `"go"` | `"golang"` |
15
+ | Markdown | `"markdown"` | `"md"`, `"mkd"` |
16
+ | Shell | `"shell"` | `"sh"`, `"bash"`, `"zsh"` |
17
+ | Dotenv | `"dotenv"` | `"env"` |
15
18
 
16
19
  All built-in languages are auto-registered on import of `@particle-academy/fancy-code`. Use them by passing the name to the `language` prop:
17
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-academy/fancy-code",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "description": "Lightweight embedded code editor with syntax highlighting and extensible language/theme registries",
5
5
  "repository": {
6
6
  "type": "git",
@@ -72,7 +72,7 @@
72
72
  "src/themes/index.ts"
73
73
  ],
74
74
  "dependencies": {
75
- "@particle-academy/fancy-file-commons": ">=0.2 <2.0"
75
+ "@particle-academy/fancy-file-commons": ">=0.4 <2.0"
76
76
  },
77
77
  "overrides": {
78
78
  "esbuild": "^0.28.1",