react-grab 0.1.15 → 0.1.17
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.
- package/README.md +64 -34
- package/dist/chunk-ILQ5JMGX.cjs +112 -0
- package/dist/chunk-WBYGVXEQ.js +112 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/{index-BR6gp9du.d.cts → index-BCkTVQa8.d.cts} +33 -8
- package/dist/{index-BR6gp9du.d.ts → index-BCkTVQa8.d.ts} +33 -8
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.global.js +41 -41
- package/dist/index.js +2 -2
- package/dist/react.cjs +10153 -8802
- package/dist/react.d.cts +17 -4
- package/dist/react.d.ts +17 -4
- package/dist/react.js +10153 -8802
- package/dist/styles.css +1 -1
- package/package.json +2 -1
- package/dist/chunk-CRY4UGGA.js +0 -112
- package/dist/chunk-EFUDUWZJ.cjs +0 -112
package/README.md
CHANGED
|
@@ -22,32 +22,12 @@ Run this command at your project root (where `next.config.ts` or `vite.config.ts
|
|
|
22
22
|
npx -y grab@latest init
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npx -y grab@latest init -y
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Connect to Your Agent
|
|
32
|
-
|
|
33
|
-
Connect React Grab directly to your coding agent (Cursor, Claude Code, Codex, Gemini, Amp, and more):
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npx -y grab@latest add [agent]
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Or connect via MCP:
|
|
25
|
+
## Connect to MCP
|
|
40
26
|
|
|
41
27
|
```bash
|
|
42
28
|
npx -y grab@latest add mcp
|
|
43
29
|
```
|
|
44
30
|
|
|
45
|
-
Disconnect an agent:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npx -y grab@latest remove [agent]
|
|
49
|
-
```
|
|
50
|
-
|
|
51
31
|
## Usage
|
|
52
32
|
|
|
53
33
|
Once installed, hover over any UI element in your browser and press:
|
|
@@ -158,28 +138,78 @@ if (process.env.NODE_ENV === "development") {
|
|
|
158
138
|
}
|
|
159
139
|
```
|
|
160
140
|
|
|
161
|
-
##
|
|
141
|
+
## Plugins
|
|
142
|
+
|
|
143
|
+
React Grab can be extended with plugins. A plugin can add context menu actions, toolbar menu items, lifecycle hooks, and theme overrides.
|
|
162
144
|
|
|
163
|
-
|
|
145
|
+
Register a plugin via `window.__REACT_GRAB__`:
|
|
164
146
|
|
|
165
|
-
|
|
147
|
+
```js
|
|
148
|
+
window.__REACT_GRAB__.registerPlugin({
|
|
149
|
+
name: "my-plugin",
|
|
150
|
+
hooks: {
|
|
151
|
+
onElementSelect: (element) => {
|
|
152
|
+
console.log("Selected:", element.tagName);
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
166
157
|
|
|
167
|
-
|
|
158
|
+
In React, register inside a `useEffect` after React Grab loads:
|
|
168
159
|
|
|
169
|
-
```
|
|
170
|
-
|
|
160
|
+
```jsx
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const api = window.__REACT_GRAB__;
|
|
163
|
+
if (!api) return;
|
|
164
|
+
|
|
165
|
+
api.registerPlugin({
|
|
166
|
+
name: "my-plugin",
|
|
167
|
+
actions: [
|
|
168
|
+
{
|
|
169
|
+
id: "my-action",
|
|
170
|
+
label: "My Action",
|
|
171
|
+
shortcut: "M",
|
|
172
|
+
onAction: (context) => {
|
|
173
|
+
console.log("Action on:", context.element);
|
|
174
|
+
context.hideContextMenu();
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return () => api.unregisterPlugin("my-plugin");
|
|
181
|
+
}, []);
|
|
182
|
+
```
|
|
171
183
|
|
|
172
|
-
|
|
184
|
+
Actions use a `target` field to control where they appear. Omit `target` (or set `"context-menu"`) for the right-click menu, or set `"toolbar"` for the toolbar dropdown:
|
|
173
185
|
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
```js
|
|
187
|
+
actions: [
|
|
188
|
+
{
|
|
189
|
+
id: "inspect",
|
|
190
|
+
label: "Inspect",
|
|
191
|
+
shortcut: "I",
|
|
192
|
+
onAction: (ctx) => console.dir(ctx.element),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: "toggle-freeze",
|
|
196
|
+
label: "Freeze",
|
|
197
|
+
target: "toolbar",
|
|
198
|
+
isActive: () => isFrozen,
|
|
199
|
+
onAction: () => toggleFreeze(),
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
```
|
|
176
203
|
|
|
177
|
-
|
|
204
|
+
A plugin can provide any combination of:
|
|
178
205
|
|
|
179
|
-
|
|
206
|
+
- **`actions`** — context menu and/or toolbar items in a single array (use `target: "toolbar"` for toolbar items)
|
|
207
|
+
- **`hooks`** — lifecycle callbacks like `onActivate`, `onElementSelect`, `onCopySuccess`, `transformCopyContent`, etc. (see `PluginHooks`)
|
|
208
|
+
- **`theme`** — partial theme overrides (see `Theme`)
|
|
209
|
+
- **`options`** — override default options like `activationMode` or `keyHoldDuration`
|
|
210
|
+
- **`setup(api)`** — a function that receives the full `ReactGrabAPI` and can return additional config or a `cleanup` function
|
|
180
211
|
|
|
181
|
-
|
|
182
|
-
```
|
|
212
|
+
See [`packages/react-grab/src/types.ts`](https://github.com/aidenybai/react-grab/blob/main/packages/react-grab/src/types.ts) for the full `Plugin`, `PluginHooks`, and `PluginConfig` interfaces.
|
|
183
213
|
|
|
184
214
|
## Resources & Contributing Back
|
|
185
215
|
|