blockout-editor 0.0.0-stage → 0.2.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.
- package/LICENSE +20 -0
- package/NOTICE.md +26 -0
- package/README.md +133 -2
- package/blockout-editor.js +3469 -0
- package/engine.js +2839 -0
- package/index.d.ts +13 -0
- package/index.js +606 -0
- package/package.json +63 -4
- package/react.d.ts +4 -0
- package/react.js +21 -0
- package/server/claude.js +334 -0
- package/server/cli.js +15 -0
- package/server/mcp.js +97 -0
- package/server/next.d.ts +5 -0
- package/server/next.js +32 -0
- package/server/store.js +135 -0
- package/server/vite.d.ts +3 -0
- package/server/vite.js +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Blockout editor
|
|
2
|
+
Copyright (c) 2026 Yash Gidwani (github.com/ux-yash). All rights reserved.
|
|
3
|
+
|
|
4
|
+
You may install this package and use it, as it is, in your own projects. That is the
|
|
5
|
+
only permission given.
|
|
6
|
+
|
|
7
|
+
You may not copy it (beyond installing it), change it, make works based on it, publish
|
|
8
|
+
it, share it, sublicense it or sell it, in whole or in part, without the copyright
|
|
9
|
+
holder's written permission.
|
|
10
|
+
|
|
11
|
+
Parts of engine.js are adapted from Scootch (https://github.com/saniaio/scootch),
|
|
12
|
+
copyright (c) 2026 Sania Saleh, under the MIT License; that notice is in NOTICE.md and
|
|
13
|
+
at the top of engine.js, and those parts stay under it.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
16
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
17
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
|
19
|
+
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
20
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The editor's engine (`engine.js`) adapts the token reading and the cascade logic of Scootch
|
|
4
|
+
(https://github.com/saniaio/scootch), under this licence:
|
|
5
|
+
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Sania Saleh
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,134 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Blockout editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blockout's editor in your app's dev page. Pick anything on the page and change it live: its spacing, size, layout,
|
|
4
|
+
type, fill and border, each checked against your own design tokens (written with one, matching one, or rogue). Drag a
|
|
5
|
+
margin, padding or gap on the page to change it; it snaps to your spacing tokens (hold ⌘ to go between them). Then send
|
|
6
|
+
what you changed, with a note, to Claude Code, which writes it into your code.
|
|
7
|
+
|
|
8
|
+
It is the same editor as Blockout's file view, laid out as Figma: the page's layers docked on the left, the design panel (position, auto layout, appearance, typography, fill, stroke, effects) on the right. Drag a field's label to scrub it, type arithmetic (`16 + 8`, `*2`), and undo with ⌘Z. It runs in development
|
|
9
|
+
only.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -D blockout-editor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Next.js (App Router)
|
|
19
|
+
|
|
20
|
+
In the root layout, inside `<body>`:
|
|
21
|
+
|
|
22
|
+
```jsx
|
|
23
|
+
import { BlockoutEditor } from "blockout-editor/react";
|
|
24
|
+
|
|
25
|
+
<BlockoutEditor />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then `app/api/blockout-notes/route.js`, so notes save into your project:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
export { GET, POST, PATCH, DELETE } from "blockout-editor/next";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Vite (React, Vue, Svelte, Astro)
|
|
35
|
+
|
|
36
|
+
In a React app, render `<BlockoutEditor />` from `blockout-editor/react` next to `<App />`. Anywhere else, start it from
|
|
37
|
+
your entry file in development:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
if (import.meta.env.DEV) import("blockout-editor").then((m) => m.startEditor());
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
And the notes route, in `vite.config.js`:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import blockoutNotes from "blockout-editor/vite";
|
|
47
|
+
|
|
48
|
+
export default { plugins: [blockoutNotes()] };
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Add `.notes/` to `.gitignore`.
|
|
52
|
+
|
|
53
|
+
### A plain HTML page (no bundler)
|
|
54
|
+
|
|
55
|
+
Copy `blockout-editor.js` (in the package) next to the page and add one line:
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<script src="blockout-editor.js" defer></script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`data-blockout`, `data-notes` and `data-open` on that tag set the options. A static file server has no notes route,
|
|
62
|
+
so Send to Claude Code puts the change request on your clipboard instead, to paste into Claude Code.
|
|
63
|
+
|
|
64
|
+
## Using it
|
|
65
|
+
|
|
66
|
+
The **Edit** button sits in the page's bottom right corner. It opens the panel: click anything to pick it.
|
|
67
|
+
|
|
68
|
+
- **V** starts and stops editing, **Esc** lets go of what is picked, then puts the editor away.
|
|
69
|
+
- **Enter** goes into what is picked, **⇧Enter** out of it.
|
|
70
|
+
- **⇧R** shows rulers; drag a guide out of one, and back onto it to remove it.
|
|
71
|
+
- As in Figma: a click picks, a double-click goes in, and on text, types in it (Esc when done); ⌘-click picks the deepest; Tab moves between siblings; ⌥ shows distances; drag the handles to resize; drag or use the arrows to move a layer in its layout; Delete deletes.
|
|
72
|
+
- Zoom out (pinch, ⌘-scroll, ⌘−) for the canvas: your page as a frame, with Tablet and Phone frames beside it (each your dev page at that width). Edit in any frame and the others follow; ⌘0 goes back to the page, with the edits.
|
|
73
|
+
- Hold **Space** to use the page as usual for a moment. Links, buttons and hover looks hold still while editing (the
|
|
74
|
+
settings change that).
|
|
75
|
+
|
|
76
|
+
**Comment mode** (the speech bubble in the panel's header): click anything on the page and a box opens beside it; type
|
|
77
|
+
what should change and press Enter. Each comment gets a numbered pin on its element and waits in the panel.
|
|
78
|
+
|
|
79
|
+
**Send to Claude** sends your message, the comments and every style you changed on the page (from → to, against your
|
|
80
|
+
tokens) to the panel's **Claude** tab. Your dev server runs your own Claude Code in the project's folder
|
|
81
|
+
(`claude -p`, with your login, settings, CLAUDE.md and skills), so it makes the changes in your code and the page
|
|
82
|
+
reloads with them; the tab shows each step as Claude takes it (read, search, edit, run), then its answer. A chat is one
|
|
83
|
+
Claude Code session: reply to carry on, and Claude remembers the thread and its own edits ("undo that" works). Chats
|
|
84
|
+
are kept in `.notes/blockout-chats.json`; New chat starts a fresh one.
|
|
85
|
+
|
|
86
|
+
Claude may read, search and edit your files, run commands (Bash) and use your skills, without asking (there is no one
|
|
87
|
+
to ask in `-p`). It starts only on the dev server, and only from your app's own page on this computer's own address
|
|
88
|
+
(`localhost`, `127.0.0.1`, `*.localhost`): another site can't start it, by a rebound DNS name either. `claude` must be
|
|
89
|
+
on the PATH of the terminal the dev server runs in (or set `BLOCKOUT_CLAUDE` to its path).
|
|
90
|
+
|
|
91
|
+
## Without the chat: `sc`
|
|
92
|
+
|
|
93
|
+
The notes route also keeps notes in `.notes/blockout-notes.json` for Claude Code to work through itself. Put this line in your project's instructions (CLAUDE.md, AGENTS.md or the like):
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
When I say "sc": read .notes/blockout-notes.json, make each open note's changes in the code (with the project's own tokens and
|
|
97
|
+
classes, not inline styles; keep the app consistent: when the element shares a component, class or pattern with others, decide whether the change is meant for all of them or this one only, and say which), then mark each one resolved with a one-line reply saying what changed.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Or give Claude Code the notes as tools, from the app's folder:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
claude mcp add blockout-editor -- npx blockout-editor mcp
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Its tools are `list_notes`, `reply_to_note` and `resolve_note`.
|
|
107
|
+
|
|
108
|
+
## Your tokens
|
|
109
|
+
|
|
110
|
+
The editor reads every custom property in your stylesheets and sorts them by name: spacing (`--space-*`, `--spacing-*`,
|
|
111
|
+
`--gap-*`, `--size-*`), font sizes (`--font-size-*`, `--text-*`), line heights, weights, tracking, radii, border widths,
|
|
112
|
+
colours (any token whose value is a colour) and type styles (classes like `.text-body` that set the font).
|
|
113
|
+
|
|
114
|
+
## What leaves your computer
|
|
115
|
+
|
|
116
|
+
Nothing of your page. The panel loads from Blockout (`startEditor({ blockout })` points it elsewhere), and your page
|
|
117
|
+
tells it what to draw in the browser: values, token names and element labels. Comments, messages and notes go to your
|
|
118
|
+
own dev server, and Claude runs there with your own Claude Code. Only a
|
|
119
|
+
page on your own computer (localhost) can show Blockout's panel.
|
|
120
|
+
|
|
121
|
+
## Options
|
|
122
|
+
|
|
123
|
+
`startEditor({ blockout, notesApi, open, button })` and `<BlockoutEditor blockout notesApi open button />`:
|
|
124
|
+
|
|
125
|
+
- `blockout`: where Blockout is. Default `https://blockout-cyan.vercel.app`.
|
|
126
|
+
- `notesApi`: the notes route. Default `/api/blockout-notes`.
|
|
127
|
+
- `open`: start with the panel open.
|
|
128
|
+
- `button`: `{ right, bottom }`, the Edit button's distance from the bottom right corner in px (default 16 each), to keep it clear of your app's own corner buttons.
|
|
129
|
+
|
|
130
|
+
See `NOTICE.md` for the open-source work the editor builds on.
|
|
131
|
+
|
|
132
|
+
## Licence
|
|
133
|
+
|
|
134
|
+
Copyright (c) 2026 Yash Gidwani. All rights reserved: you may install and use it as it is; you may not copy, change or redistribute it. See `LICENSE`; parts adapted from Scootch stay under their MIT licence (`NOTICE.md`).
|