@penguinharness/use-bento-slides 0.2.17 → 0.2.19
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 +37 -0
- package/README.zh.md +37 -0
- package/THIRD-PARTY-NOTICES.md +30 -0
- package/ifaces.json +63 -0
- package/package.json +19 -21
- package/skills/bento-slides/SKILL.md +89 -29
- package/skills/bento-slides/references/bento-agents.md +511 -0
- package/workbenches/slides/index.ts +677 -0
- package/workbenches/slides/package.json +43 -0
- package/workbenches/slides/ui/app.js +1101 -0
- package/workbenches/slides/ui/bridge.js +190 -0
- package/workbenches/slides/ui/conversation-view.js +206 -0
- package/workbenches/slides/ui/conversation.css +95 -0
- package/workbenches/slides/ui/conversation.js +115 -0
- package/workbenches/slides/ui/deck-files.css +279 -0
- package/workbenches/slides/ui/deck-files.js +189 -0
- package/workbenches/slides/ui/file-menu.js +72 -0
- package/workbenches/slides/ui/icon.svg +9 -0
- package/workbenches/slides/ui/index.html +252 -0
- package/workbenches/slides/ui/model-choice.js +298 -0
- package/workbenches/slides/ui/model-control.tsx +90 -0
- package/workbenches/slides/ui/powerpoint.js +196 -0
- package/workbenches/slides/ui/sample.bento.json +33 -0
- package/workbenches/slides/ui/strings.js +184 -0
- package/workbenches/slides/ui/style.css +505 -0
- package/workbenches/slides/ui/sync.js +268 -0
- package/workbenches/slides/ui/template-picker.js +128 -0
- package/workbenches/slides/ui/templates.js +256 -0
- package/workbenches/slides/ui/vendor/LICENSE-bento.txt +21 -0
- package/workbenches/slides/ui/vendor/LICENSE-jszip.txt +25 -0
- package/workbenches/slides/ui/vendor/LICENSE-pptxgen.txt +21 -0
- package/workbenches/slides/ui/vendor/bento-slides-1.2.13.runtime.txt +310 -0
- package/workbenches/slides/ui/vendor/pptxgen-4.0.1.bundle.js +96 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
# bento/slides — for AI agents
|
|
2
|
+
|
|
3
|
+
**Guide version `1.2.13`** · document format `bento/slides` (v1). This
|
|
4
|
+
guide matches the bento/slides shell of the same version. A deck's `#bento-doc`
|
|
5
|
+
JSON is always the source of truth — if it was written by a newer shell it may
|
|
6
|
+
carry features beyond this guide; unknown keys are ignored, never fatal.
|
|
7
|
+
|
|
8
|
+
> **Bento is a suite.** Slides is the first app; **Spaces**
|
|
9
|
+
> (`bento/spaces`, notes and wiki) ships alongside it. **Dash** (`bento/dash`,
|
|
10
|
+
> data and sheets) is in development, and a word processor is planned. Each ships
|
|
11
|
+
> as its own self-contained distributable — `Bento_Slides.bento.html`,
|
|
12
|
+
> `Bento_Spaces.bento.html`, and so on — with its own agent guide at
|
|
13
|
+
> `bento.page/<app>/agents.md`. **This guide covers Slides only.** Before you
|
|
14
|
+
> edit a file, check its `"format"` field and use the matching guide; if the
|
|
15
|
+
> format is one you have no guide for, don't guess at its shape.
|
|
16
|
+
|
|
17
|
+
*Drop this file into your context (or point your harness at it) and you can
|
|
18
|
+
author and edit Bento presentations directly. Also published at
|
|
19
|
+
[bento.page/agents.md](https://bento.page/agents.md). For **Claude Code**,
|
|
20
|
+
install the packaged **bento-slides** skill once and it triggers automatically
|
|
21
|
+
(or via `/bento-slides`) — it can even download the latest Bento app itself,
|
|
22
|
+
so a deck can be authored from an empty folder:*
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
/plugin marketplace add nyblnet/bento
|
|
26
|
+
/plugin install bento-slides@bento
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
*…or as a plain personal skill:*
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
mkdir -p ~/.claude/skills/bento-slides && curl -fsSL https://bento.page/skills/bento-slides/SKILL.md -o ~/.claude/skills/bento-slides/SKILL.md
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
*(claude.ai / Claude Desktop: upload
|
|
36
|
+
[bento.page/skills/bento-slides.zip](https://bento.page/skills/bento-slides.zip)
|
|
37
|
+
under Settings → Skills.)*
|
|
38
|
+
|
|
39
|
+
**Working without the skill, from an empty folder?** Download the app itself —
|
|
40
|
+
this is the file you write your document into:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
curl -fsSL https://bento.page/releases/slides/Bento_Slides.bento.html -o "<Topic>.bento.html"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The downloaded file's `#bento-doc` block is **empty**. That is expected: opened
|
|
47
|
+
in a browser it mints a fresh showcase deck to get a new user started, but on
|
|
48
|
+
disk there is nothing to discard and nothing to copy from. Write your document
|
|
49
|
+
into the empty block.
|
|
50
|
+
|
|
51
|
+
A Bento deck (`*.bento.html`) is a self-contained HTML file. The document
|
|
52
|
+
lives in ONE plaintext block near the top:
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<script type="application/bento+json" id="bento-doc">
|
|
56
|
+
{ "format": "bento/slides", ... }
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> ### Before you read a deck: it may carry its own keys
|
|
61
|
+
>
|
|
62
|
+
> If a deck has live collaboration switched on, its `#bento-doc` block contains
|
|
63
|
+
> a `collab` object with the credentials to that session. That is deliberate and
|
|
64
|
+
> it is what makes sharing work without accounts: **the file is the
|
|
65
|
+
> invitation**, so opening a copy joins the room.
|
|
66
|
+
>
|
|
67
|
+
> The consequence is easy to miss, because nothing about a document looks like a
|
|
68
|
+
> credential. Anything that receives the file receives the room: a chat, a
|
|
69
|
+
> ticket, a harness, a model provider's logs. Nothing about the authoring work
|
|
70
|
+
> needs the keys, so copies for agents leave them out:
|
|
71
|
+
>
|
|
72
|
+
> - **Any key in `collab` is access.** The room key alone reads the room live,
|
|
73
|
+
> including everything the relay has stored, and on older (unsigned) rooms it
|
|
74
|
+
> writes too. Private keys (`ownerPriv`, `writerPriv`, `invite`, `audience`)
|
|
75
|
+
> add writing, inviting and removing members on top.
|
|
76
|
+
> - **A read-only copy is not key-free.** *Save read-only copy…* keeps the room
|
|
77
|
+
> key, so it still opens the live room for whoever holds it.
|
|
78
|
+
> - **In the browser, read with `window.bento.read()`** (or
|
|
79
|
+
> `window.bento.compact()`): the document with the sharing keys left out. In
|
|
80
|
+
> the app, *Save ▾ → Copy document JSON* gives the same copy.
|
|
81
|
+
> `window.bento.doc` and `serialize()` are the raw file and carry the keys.
|
|
82
|
+
> `window.bento.validate()` reports any key as `collab-secrets-present`.
|
|
83
|
+
> - **Editing a file on disk:** check which `collab` fields exist by NAME without
|
|
84
|
+
> printing their values (for example, a script that prints
|
|
85
|
+
> `Object.keys(doc.collab ?? {})` only), read the document with `collab`
|
|
86
|
+
> removed, and when you write back, restore the original `collab` object
|
|
87
|
+
> exactly as it was. A file written back without it drops out of its room.
|
|
88
|
+
>
|
|
89
|
+
> If a deck with keys has already gone somewhere, the remedy is
|
|
90
|
+
> *Share → Reset access…*, which revokes the old room. Removing the keys after
|
|
91
|
+
> the fact does not retract them.
|
|
92
|
+
|
|
93
|
+
Two ways to work with it:
|
|
94
|
+
|
|
95
|
+
1. **File harness** (Claude Code, agent sandboxes): edit the JSON inside the
|
|
96
|
+
`#bento-doc` block in place. Escape every `<` in the JSON as `\u003c`
|
|
97
|
+
so the block can never contain a literal `</script>`. Leave everything else in the
|
|
98
|
+
file untouched, and handle `collab` as the box above says: read without it,
|
|
99
|
+
write it back exactly as it was.
|
|
100
|
+
2. **Chat round-trip** (any chatbot): the user copies the JSON out via
|
|
101
|
+
*Save → Copy document JSON*, you return a full replacement document,
|
|
102
|
+
they paste it back via *Save → Replace from JSON…* (undoable).
|
|
103
|
+
In the browser console: `window.bento.read()` (read, sharing keys left
|
|
104
|
+
out) / `window.bento.loadDoc(json)` (write, undoable; the open deck keeps
|
|
105
|
+
its own session).
|
|
106
|
+
|
|
107
|
+
**Reading a deck without its pictures.** A deck saved by a current version
|
|
108
|
+
of Slides keeps its picture data in the top-level `assets` map (elements say
|
|
109
|
+
`"src": "asset:<key>"`) and writes that map LAST, on its OWN line. Inside the
|
|
110
|
+
`#bento-doc` block:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
{"$schema":…,"format":"bento/slides",…,"slides":[…],
|
|
114
|
+
"assets":{"a-3f2a":"data:image/jpeg;base64,/9j/4AAQ…"}}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
One photo makes that second line megabytes long — far more than you can read
|
|
118
|
+
— so never read it: stop at the line that starts `"assets":`, or load the JSON
|
|
119
|
+
with a tool and drop the key (`jq 'del(.assets)'`; in Python
|
|
120
|
+
`doc.pop('assets', None)`), then put it back unchanged when you write. The
|
|
121
|
+
first line still holds `collab` if the deck has one, so handle it as the box
|
|
122
|
+
above says. To add a picture, add one entry to `assets` and reference it as
|
|
123
|
+
`asset:<key>`.
|
|
124
|
+
|
|
125
|
+
Don't count on that layout in every file, though. It is how a deck is written
|
|
126
|
+
from this version on; a deck last saved by an older version, produced by the
|
|
127
|
+
PowerPoint converter, or edited by hand may be a single line with `assets`
|
|
128
|
+
wherever the key fell, and older decks can carry a picture inline as a `data:`
|
|
129
|
+
`src`. Other Bento apps differ too: Type keeps a picture inline in its
|
|
130
|
+
document. If the block is not laid out as above, load the JSON with a tool and
|
|
131
|
+
set the picture data aside (`assets`, and any long `data:` string) rather than
|
|
132
|
+
reading the block as text.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Make a GREAT deck, not just a correct one
|
|
137
|
+
|
|
138
|
+
**Read this section first — it is the difference between a wall of text and a
|
|
139
|
+
Bento deck.** The format's whole value is motion, morph, charts and
|
|
140
|
+
interactivity. A correct-but-static result (bullets on slides) wastes it and
|
|
141
|
+
is the #1 failure mode. The move is to look at the *source material* and map
|
|
142
|
+
each kind of content to the feature built for it:
|
|
143
|
+
|
|
144
|
+
| When the material is… | Reach for | Why |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| numbers to **compare visually** (trend, magnitude, share) | a **chart** element | bars/lines read instantly |
|
|
147
|
+
| a **comparison / spec / pricing / feature grid** (rows × columns of labels + values) | a **table** element | structured cells beat 20 hand-placed text boxes; it styles cohesively |
|
|
148
|
+
| consecutive slides about the **same thing changing** (before/after, process steps, a metric across stages) | **morph**: same element `id` on both slides + `transition:"morph"` on the later one | the shared elements glide; this is Bento's signature and is *almost always missed* |
|
|
149
|
+
| a point to **drill into** (a definition, "click to see how", a sub-topic) | a **state slide** (`stateOf` + element `link`) | keeps the linear story clean; the detail is one click away |
|
|
150
|
+
| a **hero / full-slide image** | full-bleed image + scrim rect + text, with **ken-burns** | static photos feel dead; a slow drift feels intentional |
|
|
151
|
+
| a **sequence / flow / timeline / connection** | a line or `path` with a **`dash-march` loop**, or morph a highlight through the steps | motion carries the eye along the sequence |
|
|
152
|
+
| a **headline number** | big text + `fx:{countUp:true}` | the count-up earns attention |
|
|
153
|
+
| **every cover / section divider** | at least **one ambient motion** (ken-burns, an orbiting accent) | a still cover is a missed first impression |
|
|
154
|
+
| **repeated chrome / a logo** | keep its `id` stable across slides | it morphs in place instead of popping on every slide |
|
|
155
|
+
| a **demo clip / recording / soundbite** | a **media** element (embed short, link long) | a live video/audio beats a screenshot of one |
|
|
156
|
+
|
|
157
|
+
### Copy-paste recipes
|
|
158
|
+
|
|
159
|
+
**Morph a title + accent bar between two slides** — identical ids, `transition:"morph"`:
|
|
160
|
+
```json
|
|
161
|
+
// slide 1
|
|
162
|
+
{ "id":"s1","transition":"none","elements":[
|
|
163
|
+
{ "id":"headline","type":"text","x":96,"y":140,"w":900,"h":200,"html":"Big claim.","fontSize":120,"fontWeight":900,"color":"#111","align":"left","valign":"top","lineHeight":1,"rotation":0,"opacity":1 },
|
|
164
|
+
{ "id":"bar","type":"shape","shape":"rect","x":96,"y":380,"w":320,"h":16,"fill":"#E8442E","stroke":"none","strokeWidth":0,"radius":0,"rotation":0,"opacity":1 } ] }
|
|
165
|
+
// slide 2 — same ids, new frames → they animate
|
|
166
|
+
{ "id":"s2","transition":"morph","elements":[
|
|
167
|
+
{ "id":"headline","type":"text","x":96,"y":84,"w":500,"h":80,"html":"Big claim.","fontSize":40,"fontWeight":900,"color":"#888","align":"left","valign":"top","lineHeight":1,"rotation":0,"opacity":1 },
|
|
168
|
+
{ "id":"bar","type":"shape","shape":"rect","x":96,"y":170,"w":16,"h":450,"fill":"#E8442E","stroke":"none","strokeWidth":0,"radius":0,"rotation":0,"opacity":1 } ] }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**A bar chart from a table** — bar/line data is PLAIN NUMBERS (see chart rules below):
|
|
172
|
+
```json
|
|
173
|
+
{ "id":"c1","type":"chart","x":96,"y":260,"w":1088,"h":380,"rotation":0,"opacity":1,"preset":"bar","option":{
|
|
174
|
+
"xAxis":{"type":"category","data":["2022","2023","2024","2025"]},
|
|
175
|
+
"yAxis":{"type":"value"},
|
|
176
|
+
"series":[{"type":"bar","data":[420,780,1300,2450],"itemStyle":{"color":"#141310"},"barWidth":90}],
|
|
177
|
+
"tooltip":{"trigger":"item","formatter":"{b}: {c}"} },
|
|
178
|
+
"fx":{"enter":"fade-up"} }
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**A comparison table** — a real HTML table; cells are the same inline-html subset as text:
|
|
182
|
+
```json
|
|
183
|
+
{ "id":"tbl1","type":"table","x":240,"y":220,"w":800,"h":260,"rotation":0,"opacity":1,
|
|
184
|
+
"header":true,
|
|
185
|
+
"columns":[{"w":1.4},{"w":1},{"w":1}],
|
|
186
|
+
"rows":[
|
|
187
|
+
{ "cells":[{"html":"Plan"},{"html":"Price","align":"right"},{"html":"Seats","align":"right"}] },
|
|
188
|
+
{ "cells":[{"html":"Team"},{"html":"$29"},{"html":"5"}] },
|
|
189
|
+
{ "cells":[{"html":"Business"},{"html":"$79"},{"html":"25"}] } ],
|
|
190
|
+
"style":{"headerBg":"#1E2A3A","headerColor":"#fff","zebra":"rgba(30,42,58,0.05)",
|
|
191
|
+
"borderColor":"rgba(30,42,58,0.14)","borderWidth":1,"cellPadX":16,"cellPadY":11,
|
|
192
|
+
"fontSize":18,"color":"#1E2A3A","radius":10} }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**A state slide reached by clicking a node** — parent slide has the clickable element, the state lives adjacent:
|
|
196
|
+
```json
|
|
197
|
+
// on the parent slide, an element the viewer clicks:
|
|
198
|
+
{ "id":"node-ingest","type":"shape","shape":"ellipse","x":330,"y":180,"w":74,"h":74,"fill":"#0B0E1E","stroke":"#7A5CFF","strokeWidth":2,"radius":0,"rotation":0,"opacity":1,"link":"state-ingest" }
|
|
199
|
+
// a hidden state slide (arrow keys skip it; ← returns to parent):
|
|
200
|
+
{ "id":"state-ingest","stateOf":"parent-slide-id","transition":"morph","name":"INGEST","elements":[ /* … */
|
|
201
|
+
{ "id":"dismiss","type":"shape","shape":"rect","x":0,"y":0,"w":1280,"h":720,"fill":"rgba(0,0,0,0)","stroke":"none","strokeWidth":0,"radius":0,"rotation":0,"opacity":1,"link":"parent-slide-id" } ] }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Full-bleed hero image with ken-burns + scrim + text:**
|
|
205
|
+
```json
|
|
206
|
+
{ "id":"photo","type":"image","x":0,"y":0,"w":1280,"h":720,"src":"asset:hero","fit":"cover","radius":0,"rotation":0,"opacity":1,"fx":{"ambient":"kenburns","ken":{"dir":"drift","scale":1.09,"duration":22}} },
|
|
207
|
+
{ "id":"scrim","type":"shape","shape":"rect","x":0,"y":0,"w":1280,"h":720,"fill":"rgba(10,14,26,0.55)","stroke":"none","strokeWidth":0,"radius":0,"rotation":0,"opacity":1 },
|
|
208
|
+
{ "id":"htitle","type":"text","x":96,"y":460,"w":1000,"h":180,"html":"On top of the photo.","fontSize":76,"fontWeight":800,"color":"#fff","align":"left","valign":"top","lineHeight":1.05,"rotation":0,"opacity":1,"fx":{"enter":"fade-up"} }
|
|
209
|
+
```
|
|
210
|
+
(Embed the image as a data URI in `doc.assets` under key `hero`, then reference `"asset:hero"` — the file must stay self-contained.)
|
|
211
|
+
|
|
212
|
+
**Video — embed a short clip, or link a big one** (autoplay is present-only; `muted` required to autoplay):
|
|
213
|
+
```json
|
|
214
|
+
// embedded — self-contained, keep it small (a few MB at most):
|
|
215
|
+
{ "id":"clip","type":"media","kind":"video","src":"data:video/mp4;base64,AAAA…","x":220,"y":120,"w":840,"h":472,"rotation":0,"opacity":1,"controls":true,"muted":true,"autoplay":true,"loop":true,"fit":"cover","radius":8 }
|
|
216
|
+
// linked — deck stays tiny; needs the URL at play time (give it a poster):
|
|
217
|
+
{ "id":"clip","type":"media","kind":"video","src":"https://cdn.example.com/demo.mp4","poster":"asset:demo-poster","x":220,"y":120,"w":840,"h":472,"rotation":0,"opacity":1,"controls":true }
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Before you finish — self-audit
|
|
221
|
+
|
|
222
|
+
- [ ] Any numbers rendered as text that should be a **chart**?
|
|
223
|
+
- [ ] Do consecutive slides on one subject share element **ids + `transition:"morph"`**?
|
|
224
|
+
- [ ] At least one **motion moment** (ken-burns / loop / count-up), especially the cover?
|
|
225
|
+
- [ ] A drill-down that would work better as a **state slide**?
|
|
226
|
+
- [ ] One accent colour, at most two typefaces, **96px** side margins (right-most x ≤ 1184)?
|
|
227
|
+
- [ ] **Speaker notes** written on each slide (they travel in the file and double as the talk track)?
|
|
228
|
+
- [ ] **Have you actually looked at it?** Open the deck and page through every
|
|
229
|
+
slide. Text overflowing its box, two elements crowding each other, a
|
|
230
|
+
heading that wrapped to three lines, a chart key that was silently
|
|
231
|
+
dropped — none of these are visible in the JSON, and all of them are
|
|
232
|
+
obvious on screen. This is the only check that catches what the others
|
|
233
|
+
cannot; a deck nobody rendered is not finished.
|
|
234
|
+
|
|
235
|
+
### `window.bento.measure()` — size text before you place it
|
|
236
|
+
|
|
237
|
+
The format is absolute pixels, which is what lets morph, the drag handles and
|
|
238
|
+
the renderer work from one representation. The cost falls on you: the height of
|
|
239
|
+
a string at a given width and font is not knowable from the JSON. Stop guessing
|
|
240
|
+
and ask:
|
|
241
|
+
|
|
242
|
+
```js
|
|
243
|
+
window.bento.measure({ html: 'Long paragraph…', w: 600, fontSize: 28, lineHeight: 1.4 })
|
|
244
|
+
// → { height: 236, width: 600, lines: 6 }
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Pass a spec to size text **before** the element exists — which is the point, as
|
|
248
|
+
it lets you lay a slide out correctly the first time. Pass an element id to
|
|
249
|
+
measure one already in the deck, and include `h` in a spec to get `fits` and
|
|
250
|
+
`overflow` back too. It renders through the real renderer, so the answer is
|
|
251
|
+
what the slide will actually do, not an estimate.
|
|
252
|
+
|
|
253
|
+
Use it for the arithmetic that used to be guesswork: stacking cards in a
|
|
254
|
+
column, deciding whether a heading needs two lines or three, sizing a caption
|
|
255
|
+
under a photo. In the editor, the same thing is a **Fit height to text** button
|
|
256
|
+
in the Typography panel.
|
|
257
|
+
|
|
258
|
+
### `window.bento.validate()`
|
|
259
|
+
|
|
260
|
+
Open the deck and run it in the browser console. It reports, in one pass, the
|
|
261
|
+
things the runtime otherwise swallows in silence:
|
|
262
|
+
|
|
263
|
+
```js
|
|
264
|
+
const { ok, counts, findings } = window.bento.validate()
|
|
265
|
+
findings.filter(f => f.severity !== 'info')
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Each finding is `{code, severity, message, slide?, element?, path?}`. It checks
|
|
269
|
+
unknown property names (a typo is ignored, so the styling just never applies),
|
|
270
|
+
text that overflows its box (measured against the real renderer), elements off
|
|
271
|
+
the canvas, entrances that can never run, `dash-march` without a dashed stroke,
|
|
272
|
+
broken `link` and `asset:` references, duplicate ids and morph-key collisions,
|
|
273
|
+
and chart options charts-lite does not implement.
|
|
274
|
+
|
|
275
|
+
It only reads — it never changes the document, and a finding is advice, not a
|
|
276
|
+
refusal. `severity: "info"` is deliberately quiet (a photo bleeding off the
|
|
277
|
+
canvas is a design move, not a defect); `error` means something is broken, like
|
|
278
|
+
a link to a slide that does not exist.
|
|
279
|
+
|
|
280
|
+
This does not replace looking at the deck. It catches what is checkable; the
|
|
281
|
+
rest — whether a slide is any good — still needs eyes.
|
|
282
|
+
|
|
283
|
+
## Minimal valid document
|
|
284
|
+
|
|
285
|
+
Start from this skeleton when creating a deck from scratch. `size` and
|
|
286
|
+
`theme` (including `fontFamily`) are **required** — the app will not boot
|
|
287
|
+
without them — and elements should carry the full field set shown.
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"format": "bento/slides", "version": 1, "title": "My deck",
|
|
292
|
+
"size": { "width": 1280, "height": 720 },
|
|
293
|
+
"theme": { "background": "#101418", "color": "#F2F0EA",
|
|
294
|
+
"accent": "#FF9E8A", "fontFamily": "system-ui, sans-serif" },
|
|
295
|
+
"slides": [
|
|
296
|
+
{ "id": "s1", "background": "#101418", "transition": "none",
|
|
297
|
+
"notes": "speaker notes here",
|
|
298
|
+
"elements": [
|
|
299
|
+
{ "id": "t1", "type": "text", "x": 96, "y": 260, "w": 1088, "h": 160,
|
|
300
|
+
"rotation": 0, "opacity": 1,
|
|
301
|
+
"html": "Hello from an agent.",
|
|
302
|
+
"fontSize": 88, "fontFamily": "system-ui, sans-serif",
|
|
303
|
+
"fontWeight": 800, "color": "#F2F0EA",
|
|
304
|
+
"align": "left", "valign": "top", "lineHeight": 1.1 }
|
|
305
|
+
] }
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Element types (all share `id,x,y,w,h,rotation,opacity`)
|
|
311
|
+
|
|
312
|
+
- **text**: `html` (inline `<b> <i> <br>` ok), `fontSize`, `fontFamily`,
|
|
313
|
+
`fontWeight`, `color`, `align` (`left|center|right`), `valign`,
|
|
314
|
+
`lineHeight`, optional `letterSpacing`.
|
|
315
|
+
- **shape**: `shape` = `rect|ellipse|triangle|arrow|line|path`, `fill`, `stroke`,
|
|
316
|
+
`strokeWidth`, `radius` (rect corner). Optional `fillGradient`
|
|
317
|
+
`{angle, stops:[{at:0..1, color}]}` (CSS-convention angle). Lines take
|
|
318
|
+
their color from `fill` and draw horizontally across the box (rotate for
|
|
319
|
+
vertical); `strokeStyle: solid|dashed|dotted`; tips `lineStart`/`lineEnd`
|
|
320
|
+
= `arrow|dot|bar`. A `path` is a free vector: `d` (SVG path data) +
|
|
321
|
+
`pathBox` `[x,y,w,h]` authoring viewBox, stretched into the element box;
|
|
322
|
+
for a **curved line** set `fill:"transparent"` + a `stroke` + `strokeWidth`.
|
|
323
|
+
A **connector** is a `line` (or `path`) with `from`/`to: {el, side}` — its ends
|
|
324
|
+
follow those elements and re-route when they move (side `"auto"` picks the
|
|
325
|
+
nearest border). Make sure a shape's colour contrasts with its slide background.
|
|
326
|
+
- **image**: `src` = data URI or `"asset:<key>"` into `doc.assets`,
|
|
327
|
+
`fit: cover|contain|fill`, `radius`. Embed images as data URIs in
|
|
328
|
+
`doc.assets` and reference them — the file must stay self-contained.
|
|
329
|
+
- **chart**: `preset: bar|line|pie|scatter`, `option` = ECharts-SHAPED pure
|
|
330
|
+
JSON. **Bar/line series data must be plain numbers** (`{value,itemStyle}`
|
|
331
|
+
objects coerce to 0 — only pie takes `{name,value}`); per-item bar colors
|
|
332
|
+
are unsupported, color by series; template formatters only (`{b}`, `{c}`,
|
|
333
|
+
`{d}`), never functions. **Dual axis**: for two series on very different
|
|
334
|
+
scales (e.g. volume + a %), make `yAxis` an ARRAY of two `{type:"value"}`
|
|
335
|
+
axes (give the 2nd `axisLabel:{formatter:"{value}%"}`) and point the odd
|
|
336
|
+
series at it with `"yAxisIndex":1` — render it as a `line` over the bars.
|
|
337
|
+
**The engine is charts-lite, not ECharts** — it reads the option SHAPE and
|
|
338
|
+
ignores every key it does not implement, silently. What it honours:
|
|
339
|
+
- top level — `color`, `series`, `xAxis`, `yAxis`, `legend`, `grid`,
|
|
340
|
+
`tooltip`, `textStyle`, `dataZoom`
|
|
341
|
+
- any series — `type`, `name`, `data`, `yAxisIndex`, `itemStyle.color`
|
|
342
|
+
- bar — `itemStyle.borderRadius`
|
|
343
|
+
- line — `smooth`, `symbol`, `symbolSize`, `lineStyle.color`,
|
|
344
|
+
`lineStyle.width`, `areaStyle.color`
|
|
345
|
+
- pie — `radius`, `label.formatter` (or `label:false`),
|
|
346
|
+
`itemStyle.borderColor`, `itemStyle.borderWidth`
|
|
347
|
+
- axes — `type`, `data`, `min`, `max`, `axisLabel` (`fontSize`,
|
|
348
|
+
`fontWeight`, `color`, `formatter`), `axisLine`, `splitLine`
|
|
349
|
+
- legend — `show`, `top`, `bottom`, `textStyle.fontSize`,
|
|
350
|
+
`textStyle.fontWeight`
|
|
351
|
+
|
|
352
|
+
**`label` on a bar or line series does nothing** — value labels above bars
|
|
353
|
+
are pie-only. If you need the numbers visible on a cartesian chart, put them
|
|
354
|
+
in a table beside it, or use text elements.
|
|
355
|
+
- **table**: `columns` (array of `{w}` fractional weights), `rows` (array of
|
|
356
|
+
`{cells:[{html, align?, color?, bg?, bold?}]}`), `header` (bool — row 0 is
|
|
357
|
+
the header), and a `style` object (`headerBg`, `headerColor`, `zebra?`,
|
|
358
|
+
`borderColor`, `borderWidth`, `cellPadX`, `cellPadY`, `fontSize`, `color`,
|
|
359
|
+
`radius`). Renders as a real HTML table. Use for comparison/spec/pricing
|
|
360
|
+
grids — NOT for numeric trends (use a chart).
|
|
361
|
+
- **svg**: `asset` or `markup` for static artwork. Prefer composing rects/
|
|
362
|
+
texts/paths — those stay editable and can morph.
|
|
363
|
+
- **media**: `kind: video|audio`, `src` = data URI (embedded — travels in the
|
|
364
|
+
file), an external URL / relative path (referenced — keeps the file small,
|
|
365
|
+
needs the network at play time), or `"asset:<key>"`. Video also takes
|
|
366
|
+
`poster`, `fit: cover|contain|fill`, `radius`. Playback flags: `controls`,
|
|
367
|
+
`autoplay`, `loop`, `muted`. **Autoplay fires only in present mode**, and
|
|
368
|
+
browsers require `muted:true` for a video to autoplay. **Embed only SHORT
|
|
369
|
+
clips** — a big data URI bloats the file and makes it slow to open/save;
|
|
370
|
+
host large media and reference its URL instead.
|
|
371
|
+
|
|
372
|
+
## The rules that make decks feel designed
|
|
373
|
+
|
|
374
|
+
- **Morph = shared ids.** Slides with `"transition": "morph"` tween any
|
|
375
|
+
elements whose `id` matches the previous slide — position, size, color,
|
|
376
|
+
gradients. This is THE signature move: carry 2–4 ids through the deck and
|
|
377
|
+
rearrange them per slide. Generators must emit deterministic ids.
|
|
378
|
+
- **`morphId` decouples morph identity from `id`.** The real pairing key is
|
|
379
|
+
`morphId || id`, so an element can keep whatever `id` it likes and set
|
|
380
|
+
`"morphId": "running-head"` to morph against a differently-named element on
|
|
381
|
+
the next slide. For a generator this beats threading one id by hand through
|
|
382
|
+
every slide, and it lets two independently-created elements pair up. The key
|
|
383
|
+
must be unique **within** a slide. Plain shared `id` still works and is still
|
|
384
|
+
the simplest thing when you control both slides.
|
|
385
|
+
- **Entrances**: `fx: { enter: "fade-up", order: 0 }` — equal `order` =
|
|
386
|
+
simultaneous. On a **morph arrival** the rule is per element, and it turns on
|
|
387
|
+
whether that element has a morph partner on the previous slide:
|
|
388
|
+
- **has a partner** → it morphs, and `fx.enter` and `fx.countUp` are both
|
|
389
|
+
skipped. It is already in motion and already showing its number; an
|
|
390
|
+
entrance would fight the tween and a count-up would restart from zero.
|
|
391
|
+
- **no partner** → it is new to the slide, so both run normally. Without an
|
|
392
|
+
`fx.enter` it gets an automatic fade-and-rise so nothing ever just pops in.
|
|
393
|
+
|
|
394
|
+
So a headline number, or a panel that sweeps in from the right, is fine on a
|
|
395
|
+
morph slide — just make sure it is new to that slide.
|
|
396
|
+
- **Ken-burns**: `fx: { ambient: "kenburns", ken: { dir: "drift|out|in",
|
|
397
|
+
scale: 1.08, duration: 20 } }` — `drift` loops, `out`/`in` settle once on
|
|
398
|
+
slide entry. For full-bleed photos: image at 0,0,1280,720 + a scrim rect
|
|
399
|
+
+ text on top. Never combine entrance tweens with motion-path loops.
|
|
400
|
+
- **Loops**: two shapes, both under `fx.loop`.
|
|
401
|
+
- `{ type: "dash-march", distance: 18, duration: 1.4 }` — marches the stroke
|
|
402
|
+
dashes along a shape. It animates `strokeDashoffset`, so it needs a
|
|
403
|
+
`stroke` **and** a dash pattern: set `strokeStyle: "dashed"` or `"dotted"`.
|
|
404
|
+
On a solid stroke the tween still runs and there is nothing to see.
|
|
405
|
+
- `{ type: "motion-path", path: "M0,0 C60,-40 140,40 200,0", duration: 6,
|
|
406
|
+
delay: 0, ease: "none", speeds: [1, 1] }` — drifts the element along a
|
|
407
|
+
path given RELATIVE to its resting position (the first anchor is where it
|
|
408
|
+
sits). `speeds` is optional, one multiplier per on-curve point, and lets
|
|
409
|
+
the element dwell in places and rush others; omit it for constant pace.
|
|
410
|
+
Never put an entrance tween on a motion-path element — they fight over the
|
|
411
|
+
same transform.
|
|
412
|
+
- **Interactivity**: element `link: "<slide-id>"` jumps on click; a slide
|
|
413
|
+
with `stateOf: "<parent-id>"` is a hidden variant reached only by links
|
|
414
|
+
(arrow keys skip it, ← returns to parent). Give clickable things a padded
|
|
415
|
+
transparent rect as the hit target, not the text itself.
|
|
416
|
+
- **Hidden slides**: `"hidden": true` keeps a slide in the deck and out of the
|
|
417
|
+
show — arrow keys skip it, PDF export leaves it out, and it is never the
|
|
418
|
+
file's thumbnail — but an element `link` still reaches it. That is what it is
|
|
419
|
+
for: backup and appendix material you jump to only if asked. By default a
|
|
420
|
+
hidden slide does not consume a page number either, so `{{page}}`/`{{pages}}`
|
|
421
|
+
stay contiguous for the audience; set `present.numberHidden: true` for the
|
|
422
|
+
office-suite behaviour where it keeps its number.
|
|
423
|
+
|
|
424
|
+
Not the same as `stateOf`. A state is a variant OF another slide (← returns
|
|
425
|
+
to its parent, and it morphs with it); hidden carries no such relationship.
|
|
426
|
+
Use a state for "click to drill into this", hidden for "only if they ask".
|
|
427
|
+
- **Numbers count up** with `fx: { countUp: true }`.
|
|
428
|
+
- **Speaker notes** (`notes`) are part of the document — write them; they
|
|
429
|
+
make a template teach itself.
|
|
430
|
+
|
|
431
|
+
## Layout guardrails
|
|
432
|
+
|
|
433
|
+
- Canonical canvas 1280×720 (`doc.size` can differ — read it first).
|
|
434
|
+
- Keep 96 px side margins (right-most content x ≤ 1184).
|
|
435
|
+
- **Column arithmetic, already done.** On 1280×720 inside 96 px margins the
|
|
436
|
+
content band is 1088 px wide. Use these rather than computing your own:
|
|
437
|
+
|
|
438
|
+
| Split | Width | `x` positions | Gutter |
|
|
439
|
+
|---|---|---|---|
|
|
440
|
+
| 2 columns | 528 | 96, 656 | 32 |
|
|
441
|
+
| 3 columns | 340 | 96, 470, 844 | 34 |
|
|
442
|
+
| 4 columns | 254 | 96, 374, 652, 930 | 24 |
|
|
443
|
+
| 60 / 40 (text + image) | 624 / 432 | 96, 752 | 32 |
|
|
444
|
+
|
|
445
|
+
Every row ends flush at x = 1184. Vertically, a title band of `y:72 h:84`
|
|
446
|
+
over content starting at `y:208` leaves 416 px of content height above a
|
|
447
|
+
96 px bottom margin.
|
|
448
|
+
- One accent color; 2 typefaces max. `theme` sets deck defaults.
|
|
449
|
+
- Fonts: `doc.fonts` (`{family, asset, weight}`) + woff2 data URIs in
|
|
450
|
+
`doc.assets` if you need embedded faces; otherwise stick to system stacks.
|
|
451
|
+
**A `fontFamily` naming a face the document does not carry falls back
|
|
452
|
+
silently** to the next entry in the stack — there is no warning, and worse,
|
|
453
|
+
it will usually look right to *you*, because you are the one with the
|
|
454
|
+
typeface installed. Everyone else gets the fallback. `validate()` reports
|
|
455
|
+
this (`font-not-embedded`) precisely because you cannot see it locally.
|
|
456
|
+
Fonts belong to the DOCUMENT, not the app:
|
|
457
|
+
Instrument Sans and Fraunces appear in the starter deck and in several
|
|
458
|
+
templates because those files embed them in their own `doc.assets`, not
|
|
459
|
+
because the app provides them. So either embed the woff2 yourself, start from
|
|
460
|
+
a template that already carries the face, or name a system stack and mean it.
|
|
461
|
+
Always write a full stack (`"'Fraunces', Georgia, serif"`), never a bare
|
|
462
|
+
family name.
|
|
463
|
+
|
|
464
|
+
## Layouts and `role`
|
|
465
|
+
|
|
466
|
+
`doc.layouts` is a supported top-level key: an array of Slide-shaped templates
|
|
467
|
+
the editor offers under *Apply layout*. Every deck also gets five built-ins
|
|
468
|
+
(`layout-title`, `layout-title-content`, `layout-two-col`, `layout-section`,
|
|
469
|
+
`layout-blank`), which are scaled to the deck's `doc.size` when applied.
|
|
470
|
+
|
|
471
|
+
The part that matters when you are generating a deck is **`role`**. Any text
|
|
472
|
+
element can carry `"role": "title" | "subtitle" | "body" | "kicker"`. Applying a
|
|
473
|
+
layout matches donor to target by `id` first and then by `role` + `type`, so
|
|
474
|
+
roles are what let someone restyle your deck later without re-typing it —
|
|
475
|
+
content rides across, the layout supplies frame and typography. Setting them
|
|
476
|
+
costs one key per element and makes a generated deck feel native to the editor.
|
|
477
|
+
|
|
478
|
+
Two smaller things: a layout's text elements use `placeholder` (a dimmed prompt
|
|
479
|
+
shown in the editor, hidden in present and print) rather than `html`, and
|
|
480
|
+
slides instantiated from the same layout keep their element ids — which is
|
|
481
|
+
exactly why their furniture morphs across a transition.
|
|
482
|
+
|
|
483
|
+
## Dynamic fields (tokens in text `html`)
|
|
484
|
+
|
|
485
|
+
Put these tokens in any text element's `html`; they resolve at render time (the
|
|
486
|
+
model keeps the raw token, so numbering/props update automatically):
|
|
487
|
+
`{{page}}`, `{{pages}}` (position among non-state slides; zero-pad with
|
|
488
|
+
`{{page:2}}`→"06"), `{{title}}`, `{{date}}`, `{{time}}`, and the document
|
|
489
|
+
properties `{{author}}`, `{{company}}`, `{{subject}}`, `{{event}}`. Set the
|
|
490
|
+
props in an optional top-level `"meta": {author, company, subject, event,
|
|
491
|
+
keywords}` object — great for title slides and footers that fill from one place.
|
|
492
|
+
|
|
493
|
+
## Gotchas
|
|
494
|
+
|
|
495
|
+
- Escape `<` as `\u003c` anywhere in the JSON when writing the file block.
|
|
496
|
+
- Don't invent property names — unknown keys are ignored, so a typo means
|
|
497
|
+
your styling silently doesn't apply.
|
|
498
|
+
- `docId` is the document's identity — never regenerate it when editing.
|
|
499
|
+
- `readonly: true` makes a PLAYER file — it boots straight into the
|
|
500
|
+
presentation with no editor. Set it only on hand-out copies.
|
|
501
|
+
- If `template: true` is set, every open mints a fresh document (that's for
|
|
502
|
+
distributable templates; remove it for a personal deck).
|
|
503
|
+
- Charts degrade gracefully but anything outside the list in the **chart**
|
|
504
|
+
element type above is ignored, with no warning — keep options minimal and
|
|
505
|
+
check the rendered slide rather than trusting the JSON.
|
|
506
|
+
- **Media size**: embedding a large video as a data URI can push the file into
|
|
507
|
+
the tens of MB and make it slow to open and save. Embed only short clips;
|
|
508
|
+
otherwise host the file and put its URL in `media.src`.
|
|
509
|
+
|
|
510
|
+
Working examples of everything above: the template decks at
|
|
511
|
+
[bento.page](https://bento.page) — open one and read its JSON block.
|