@particle-academy/react-fancy 4.14.1 → 4.15.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.
@@ -0,0 +1,64 @@
1
+ # CodeView
2
+
3
+ A lightweight, syntax-highlighted source view — a highlight overlay with a
4
+ transparent, auto-growing `<textarea>` on top. Built on the pure highlight
5
+ primitives in [`@particle-academy/fancy-file-commons`](https://www.npmjs.com/package/@particle-academy/fancy-file-commons)
6
+ (no CodeMirror, no heavy dependency). Powers the [`Editor`](./Editor.md)'s Source
7
+ view, and is usable standalone.
8
+
9
+ Only **HTML** is highlighted (the one grammar commons ships — it's what the
10
+ Editor's source view needs). Everything else — including Markdown — renders as
11
+ plain text. For a full multi-language IDE (JS/TS/PHP/Python/Go/Markdown, line
12
+ numbers, diff gutter), use [`@particle-academy/fancy-code`](https://www.npmjs.com/package/@particle-academy/fancy-code)'s
13
+ `CodeEditor`.
14
+
15
+ ## Import
16
+
17
+ ```tsx
18
+ import { CodeView } from "@particle-academy/react-fancy";
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```tsx
24
+ const [src, setSrc] = useState("<p>Edit me</p>");
25
+
26
+ // In a sized box, `h-full` makes it fill the height.
27
+ <div className="h-80">
28
+ <CodeView value={src} onChange={setSrc} language="html" className="h-full" />
29
+ </div>
30
+ ```
31
+
32
+ Read-only (omit `onChange` or pass `readOnly`):
33
+
34
+ ```tsx
35
+ <CodeView value={htmlString} language="html" readOnly />
36
+ ```
37
+
38
+ ## Filling height
39
+
40
+ `CodeView` has no baked-in height — pick the fill mechanism for your layout:
41
+
42
+ - **`h-full`** when the parent has a definite height (e.g. a sized box).
43
+ - **`flex-auto` + `min-h-0`** when it's a child of a flex column — it fills the
44
+ free space when constrained and grows with content otherwise. (This is how the
45
+ Editor's source view is wired.)
46
+
47
+ ## Props
48
+
49
+ | Prop | Type | Default | Description |
50
+ |------|------|---------|-------------|
51
+ | value | `string` | — | Source text (controlled). |
52
+ | onChange | `(value: string) => void` | — | Called on edit. Omit for a read-only view. |
53
+ | language | `"html" \| "markdown" \| "plaintext" \| string` | `"plaintext"` | Only `"html"` is highlighted; everything else renders plain. |
54
+ | readOnly | `boolean` | `false` | Read-only even if `onChange` is passed. |
55
+ | placeholder | `string` | — | Shown when empty. |
56
+ | minHeight | `number` | `120` | Min height (px) before growing with content. |
57
+ | maxHeight | `number` | — | Max height (px) before scrolling internally. |
58
+ | className | `string` | — | Classes on the scroll container (e.g. `h-full`, `flex-auto`). |
59
+
60
+ ## Theme
61
+
62
+ The view resolves light/dark itself (the highlight colors are inlined). It
63
+ follows both the `.dark` class and the `prefers-color-scheme` media query, so it
64
+ matches whatever drives your Tailwind `dark:` variants.
package/docs/Editor.md CHANGED
@@ -90,11 +90,13 @@ A toolbar button that reveals the raw HTML/Markdown behind the editor. It is app
90
90
  ## Source View
91
91
 
92
92
  The default toolbar includes a **Source** toggle (`</>`) on the right. Clicking it
93
- swaps the rich-text surface for a `<textarea>` showing the raw markup — HTML when
94
- `outputFormat="html"`, Markdown when `outputFormat="markdown"`. Edits made in the
95
- textarea flow straight to `value`; toggling back re-renders the rich-text surface
96
- from the edited source. Formatting buttons in the default toolbar are disabled
97
- while source view is open.
93
+ swaps the rich-text surface for a syntax-highlighted [`CodeView`](./CodeView.md)
94
+ showing the raw markup — HTML (highlighted) when `outputFormat="html"`, Markdown
95
+ (plain) when `outputFormat="markdown"`. The source view **fills the editor's
96
+ height** (give the `Editor` a height, e.g. `className="h-full"` inside a sized
97
+ box), and grows with content otherwise. Edits flow straight to `value`; toggling
98
+ back re-renders the rich-text surface from the edited source. Formatting buttons
99
+ in the default toolbar are disabled while source view is open.
98
100
 
99
101
  ```tsx
100
102
  // Source toggle is on by default — nothing to wire up.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-academy/react-fancy",
3
- "version": "4.14.1",
3
+ "version": "4.15.0",
4
4
  "description": "React UI component library for Human+ UX — controlled, agent-bridgeable primitives",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,6 +60,7 @@
60
60
  "tailwindcss": "^4.0.0"
61
61
  },
62
62
  "dependencies": {
63
+ "@particle-academy/fancy-file-commons": "^0.2.0",
63
64
  "clsx": "^2.1.0",
64
65
  "lucide-react": "^0.511.0",
65
66
  "marked": "^15.0.0",