Edit with Caboodle
Put an Edit with Caboodle button by a file on your website. The file opens in the right Caboodle program in a new window; when the person presses Save to your site, the edited file comes back to your page, and you store it where you store your files.
One script, no API key, no Caboodle account, no server work on either side: the file is handed over inside the browser with postMessage and never goes through Caboodle’s servers. This page is written so that a developer – or a coding agent – can build the integration from it alone.
Before you start
- Any https site can use it – no sign-up, no key. Plain
httpworks only onlocalhostand127.0.0.1(any port), for building and testing. Caboodle always shows your real address beside the name you give (“Editing robot.glb for GamerFuel (gamerfuel.com)”). Sites that misuse it can be blocked. - Load the script from Caboodle:
<script src="https://caboodle.tools/edit.js"></script>. If your site has a Content-Security-Policy, addhttps://caboodle.toolstoscript-src. - Don’t send
Cross-Origin-Opener-Policy: same-originon the page with the button: it cuts the link to the window it opens, so the file can’t be handed over or come back. No COOP header,unsafe-noneorsame-origin-allow-popupsare fine. - Call
Caboodle.edit()straight from the click, before anyawait– browsers block windows opened later. Don’t fetch the file first: pass its URL (or a promise) and the window opens at once while the file follows. - The page that opened Caboodle has to stay open until the person saves: that’s where the file comes back. Don’t navigate away from it in the meantime (open it in a modal or keep the person on the page).
Quick start
<button id="edit-robot">Edit with Caboodle</button>
<script src="https://caboodle.tools/edit.js"></script>
<script>
document.getElementById('edit-robot').addEventListener('click', () => {
Caboodle.edit({
file: '/assets/robot.glb', // its URL on your site (or a Blob, or a promise of one)
name: 'robot.glb', // the extension picks the program
site: 'GamerFuel', // the button in Caboodle says “Save to GamerFuel”
onSave: async (blob, name) => { // the edited file
const r = await fetch('/api/assets/robot.glb', { method: 'PUT', body: blob });
if (!r.ok) throw new Error('Upload failed (' + r.status + ')'); // shown in Caboodle
},
});
});
</script>
That’s all. The person edits, presses Save to GamerFuel (or Ctrl+S / ⌘S), your onSave runs, and Caboodle shows “Saved to GamerFuel” – or your error, if onSave throws. They can save as many times as they like; each save calls onSave again.
Reference: Caboodle.edit(options)
| Option | Type | What it is |
|---|---|---|
file | Blob · File · string · Promise<Blob> · () => Promise<Blob> | Required. The file. A string is fetched from your page with fetch(url) (same-origin cookies are sent; for another origin it needs CORS). A promise or function lets you fetch it your own way (e.g. with an auth header) – the window opens first and waits. |
name | string | The file’s name with its extension, e.g. robot.glb. Required unless file is a File or a URL ending in the name. The extension picks the program (see file types); the name is shown to the person and comes back with the edited file. |
site | string | Your site’s name, on the Save button and in messages (“Save to GamerFuel”). Default: your hostname without www. |
format | string | What should come back, as an extension, e.g. 'glb'. Default: the same kind as went in (a .glb comes back a .glb). If the program can’t write it, it uses its first format and says so. |
program | string | Overrides the program the extension picks: sprite (a .png sprite sheet in the Sprite editor – see sprite sheets), graphics, image, spreadsheet, document, pdf, slides, wireframe, mindmap, midi, video, audio, text. |
data | Blob · string · Promise<Blob> · () => Promise<Blob> · object | Optional, with program: 'sprite': the sheet’s frames and animations as an Aseprite JSON. Taken like file (a string is its URL); a plain object is sent as JSON. Its frames and animations are what the sheet opens with. Without it, the frames are found as for any PNG (the grid Caboodle keeps inside its PNGs, else from the picture). |
style | object | Optional, with program: 'sprite': the game’s art style – { unit, view, palette, description }, every field optional. |
references | array | Optional, with program: 'sprite': up to 5 sheets of the game to look at – [{ name, file, data }], file and data taken like the options of those names. Read-only in Caboodle and never sent back. One that can’t be fetched is left out (a warning in the console); the rest still open. |
sheets | array | Optional, with program: 'sprite': up to 100 more sheets to edit in the same window – [{ name, file, data }], file and data taken like the options of those names, each name a file name used once (e.g. goblin.png; a name used twice: only its first). Each opens as a sheet of its own beside the one in file and comes back on every save in extra.sheets with that name and opened: true. One that can’t be fetched stops the whole open, like file (onError). |
title | string | Optional: the file’s title in Caboodle, shown to the person (“Editing title for GamerFuel”). Default: name without its extension. |
reskin | string | Optional, with program: 'sprite': a suggested prompt for Reskin with AI. The window opens with it as soon as the sheets are in, every sheet sent ticked and your references as its style pictures (Style from, so the reskin matches them), for the person to change or run – nothing is made until they press Reskin. Up to 4000 characters. %asset_name% in it becomes each sheet’s name when it’s made: its asset, else its file name without the ending, dashes as spaces – so one prompt works for several sheets. |
asset | string | Optional, with reskin: the file’s name for %asset_name% ('Enemy robot'); each of sheets may have its own asset too. Up to 100 characters. |
onSave | async (blob, name, extra) => void | The edited file and its name (the original name with the format’s extension, e.g. robot.glb). From the Sprite editor, extra.data is the sheet’s Aseprite JSON (a Blob, application/json) and extra.sheets the other sheets – those you sent in sheets (opened: true) and those made in the window – [{ name, blob, data, opened? }] (see below). From the MIDI editor with format mp3 or wav, extra.data is the song’s notes as a .mid (a Blob, audio/midi): keep it to open the song in the MIDI editor again later, while you play the sound. For other programs extra is {}. Store it. Resolve when it’s stored; throw (or reject) to tell the person it wasn’t – the error’s message is shown in Caboodle. Caboodle waits up to 10 minutes for it. |
onClose | () => void | Optional. The Caboodle window was closed (checked about once a second). |
onError | (error) => void | Optional. The file couldn’t be fetched or awaited; the Caboodle window is closed again. Default: logged to the console. |
Returns { window, close() }: the Caboodle window, and a function that closes it.
Throws right away when an option is wrong, the file type isn’t one Caboodle opens, or the browser blocked the window (“call it from a click”).
Caboodle.origin is 'https://caboodle.tools'; set it to point at another copy of Caboodle (for Caboodle’s own testing).
File types
| Your file | Opens in | Can come back as (format) |
|---|---|---|
.glb .gltf .obj .stl .ply .fbx | 3D Graphics | glb gltf obj stl ply |
.png .jpg .jpeg .webp .gif .bmp .psd | Image editor | png jpg webp psd (a GIF or BMP comes back as PNG) |
.png with program: 'sprite' (and its .json as data) | Sprite editor | png – with its frames and animations as Aseprite JSON in extra.data |
.xlsx .xlsm .xltx .xls .csv .tsv | Spreadsheet | xlsx csv tsv |
.docx .doc .md .html .htm | Word processor | docx html txt (a .md comes back as .docx) |
.pdf | PDF editor | pdf txt |
.pptx .ppt | Slide show | pptx pdf |
.excalidraw .drawio .bmml | Wireframe | excalidraw drawio bmml svg pdf png |
.xmind .mm .opml | Mind Map | xmind mm opml md txt svg pdf png |
.mid .midi .kar | MIDI editor | mid mp3 wav – an MP3 or WAV with the song’s .mid in extra.data |
.mp4 .mov .m4v .webm .mkv | Video editor | mp4 webm |
.mp3 .wav .m4a .aac .ogg .oga .opus .flac | Audio editor | mp3 m4a wav webm |
.txt .json .js .ts .css .xml .yml .md … and other text | Text editor (program: 'text' for .md/.html) | the file as it came, in its encoding and line endings |
Sprite sheets
A .png opens in the Image editor and comes back as a flat picture. With program: 'sprite' it opens in the Sprite editor, cut into its frames, and comes back with them:
Caboodle.edit({
program: 'sprite',
file: '/assets/hero.png',
data: '/assets/hero.json', // its Aseprite JSON (optional)
name: 'hero.png',
site: 'GamerFuel',
onSave: async (png, name, extra) => { // name: 'hero.png'
await upload(name, png);
await upload('hero.json', extra.data); // the frames and animations, as Aseprite JSON
},
});
- The JSON is the one the Sprite editor writes (Download → PNG and JSON in Aseprite’s form), which Phaser loads with
this.load.aseprite(key, png, json)and Godot and Unity importers read:frames(an array, each with itsframerectangle,durationandpivot– where the sprite stands, 0–1 of the frame),meta.size,meta.image(the PNG’s name) andmeta.frameTags– each animation as{ name, from, to, direction }(forwardorpingpong; with rows as directions, one tag per direction, e.g.Walk_down).meta.caboodleholds the editor’s own settings (the grid, the animations’ speeds); keep it as it is. A sheet with a hit area – the solid part a game collides with, the same in every frame (made with Game units in Make a sheet with AI, or set in Properties › Sheet) – has it as a slice:meta.slices: [{ name: 'hit', keys: [{ frame: 0, bounds: { x, y, w, h } }] }], in each frame’s own pixels; send one back the same way (a slice namedhit,hitbox,collision,colliderorsolid) and the sheet opens with it. - What you send: Aseprite’s array or hash form, or TexturePacker’s. Its frames have to make an even grid (all the same size); a packed atlas of trimmed frames doesn’t open as frames.
- The PNG that comes back keeps the grid inside it too, so it opens the same even without its JSON.
- A new sheet: send a blank, transparent PNG (e.g. 4 frames of 32×32 in a row, 128×32) and a JSON with those 4 frames. The person can change the grid (Grid on the right) and add frames as with any sheet.
- Sheets made in the window – added, duplicated, made with Reskin or Make a sheet with AI – come back on every save in
extra.sheets;blobandextra.dataare always the sheet that was opened.
The game’s style, references, and new sheets
Caboodle.edit({
program: 'sprite', file: '/assets/hero.png', data: '/assets/hero.json', name: 'hero.png', site: 'GamerFuel',
style: {
unit: 32, // the game’s tile, in px
view: 'side', // 'side' (a platformer) · 'top' (top-down) · 'iso' (isometric)
palette: ['#1a1c2c', '#5d275d', '#b13e53'], // up to 64 colours, '#rrggbb'
description: '16-colour pixel art, dark 1 px outlines, light from the top left', // up to 1000 characters
},
references: [ // up to 5, to look at
{ name: 'tiles.png', file: '/assets/tiles.png', data: '/assets/tiles.json' },
],
onSave: async (png, name, extra) => {
await upload(name, png, extra.data); // the sheet that was opened
for (const s of extra.sheets) await upload(s.name, s.blob, s.data); // e.g. 'slime.png' and its JSON
},
});
unitandviewset the sprite file’s game camera –sideis Caboodle’s Side view (platformer) (2 directions, no ground shadow),toptop-down (1 direction),isoisometric 2:1 – so the game grid drawn behind the frames is the game’s tiles. With neither, the camera is as before (none, or the one the PNG was rendered with).paletteshows as The game’s colours beside the painting tools and under Game style on the right.descriptionshows under Game style, where the person can change it. The AI tools that draw – Make a sheet with AI and Reskin – are told the description and to keep to the palette. (Recolour isn’t AI; Animate with AI makes a video from a frame and keeps its colours.)referencesare sheets of their own, marked Reference (“Reference from GamerFuel”). They can be looked at, put on the test stage, and used as style pictures: Make a sheet with AI starts with them as its Style from pictures, and Reskin can take one as a look’s picture. They can’t be changed – painting on one, or changing its grid, animations or name, is undone with a note – and they’re never sent back. Duplicating one makes an ordinary sheet that comes back inextra.sheets.extra.sheetsis every sheet in the window other than the one opened and the references, in their order, on every save –[]when there are none. Each hasname(the sheet’s name and.png, never the same as another in the list, the opened sheet’s or a reference’s – a second “slime” comes asslime 2.png),blob(its PNG, the grid inside it) anddata(its Aseprite JSON,meta.imageits name). Renaming a sheet changes its name next time, so store them by name and replace.
Several sheets in one window
Caboodle.edit({
program: 'sprite', site: 'GamerFuel',
file: '/assets/hero.png', data: '/assets/hero.json', name: 'hero.png', // the first
sheets: [ // up to 100 more, each its own sheet in the same window
{ name: 'goblin.png', file: '/assets/goblin.png', data: '/assets/goblin.json' },
{ name: 'troll.png', file: '/assets/troll.png', data: '/assets/troll.json' },
],
title: 'Winter · 3 sheets', // the file's title in Caboodle
onSave: async (png, name, extra) => {
await upload('hero.png', png, extra.data);
for (const s of extra.sheets) {
if (s.opened) await upload(s.name, s.blob, s.data); // 'goblin.png', 'troll.png': the names you gave
else await uploadNew(s.name, s.blob, s.data); // a sheet made in the window
}
},
});
- Each sheet keeps its own size, frames and animations, so the person can redraw them one by one or all at once – Reskin can take several sheets in one go, in the same look.
- On every save, each sheet you sent comes back by the
nameyou gave it, whatever the person renames it to, withopened: true. One they deleted doesn’t come back. A copy of one is a sheet made in the window (noopened, its own name). - Reskins. Reskin and Recolour make a new sheet beside the one they start from (“goblin · Winter”), which comes back as a sheet made in the window with
from: the name of the sheet you sent that it was made from ('goblin.png'– or the opened sheet’s,namewith.png; also through a reskin of a reskin). To store the redrawn picture in place of the one you sent, take the last sheet inextra.sheetswith thatfrom, else the sheet itself.
Importing sheets from Caboodle: Caboodle.pick(options)
The other way round: the person’s own sprite sheets, already in Caboodle, brought to your site. A Caboodle window lists their sprite files (those in this browser, and – signed in – those in their cloud), newest first, with a search box; a file opens to its sheets (a picture, frames, frame size, hit area); they tick any number, from any files (a file’s own tick takes all its sheets), and press Send to GamerFuel. They can send more than once from the same window.
button.onclick = () => Caboodle.pick({ // from the click itself
site: 'GamerFuel',
program: 'sprite',
title: 'Import into Tiles', // optional: shown at the top of the window
onPick: async (sheets) => { // [{ name: 'slime.png', blob, data, file: { id, title }, sheet: { id, name } }]
for (const s of sheets) await upload(s.name, s.blob, s.data);
}, // throw to say they weren't taken – the message is shown in Caboodle
onClose: () => {},
});
Each sheet comes as on a save: blob its PNG (the grid inside it), data its Aseprite JSON (frames, frameTags, the hit slice when it has a hit area), name the sheet’s name with .png – never the same as another in the same batch (a second “slime” is slime 2.png) – and where it came from. Messages: caboodle:ready → you: { t: 'caboodle:pick-open', session, site, title, format?, v: 2 } → Caboodle, on Send: { t: 'caboodle:picked', session, sheets } → you: caboodle:saving at once and caboodle:saved when stored, as for a save (the page is sprite.html?pick=<session>&from=<your origin>).
Whole files from other programs
Any other program that can save back to your site (see file types) can be picked from too: the window lists the person’s files of that program, they tick any number and press Send. Each is opened in that window and written as a save writes it, in the format you ask for. From the MIDI editor with format: 'mp3' (or 'wav'), data is the song’s notes as a .mid.
button.onclick = () => Caboodle.pick({
site: 'GamerFuel',
program: 'midi', // or 'audio' – the person's songs, or sound projects
format: 'mp3',
onPick: async (files) => { // [{ name: 'Theme.mp3', blob, data (the .mid), file: { id, title } }]
for (const f of files) await upload(f.name, f.blob, f.data);
},
});
What the person sees
- A new window (or tab) with the program and the file, and a strip: “Editing robot.glb for GamerFuel (gamerfuel.com) – Save to GamerFuel (Ctrl+S) sends it back”. The address in brackets is always your page’s real one.
- A Save to GamerFuel button on the top bar. Ctrl+S / ⌘S does the same. Download still works too.
- Saving shows “Sending…”, then “Saved to GamerFuel”, or “Not saved to GamerFuel: your error”.
- If your page was closed, the strip says so and Save offers to download the file instead.
The file becomes a file of the person’s in Caboodle: kept in that browser (so a reload doesn’t lose the work) and, if they’re signed in to Caboodle, in their Caboodle cloud once they change it – so they can share it, work on it with others or have Claude change it (those changes come into the open window, and Save sends them to you). For a site Caboodle trusts it goes to their cloud at once. No sign-in is needed to edit and save back. Sounds and videos are copied into the editor first, and the person picks a quality for that copy (original quality needs a paid Caboodle account).
Fuller examples
Plain JavaScript, with your own auth and a busy state
function editWithCaboodle(asset, button) {
// asset: { id, name, url } from your own data
const handle = Caboodle.edit({
// fetched your way (here with a token); the window opens first and waits for it
file: () => fetch(asset.url, { headers: { Authorization: 'Bearer ' + token } })
.then((r) => { if (!r.ok) throw new Error('Couldn’t load ' + asset.name); return r.blob(); }),
name: asset.name,
site: 'GamerFuel',
onSave: async (blob, name) => {
const form = new FormData();
form.append('file', blob, name);
const r = await fetch('/api/assets/' + asset.id + '/versions', { method: 'POST', body: form, headers: { Authorization: 'Bearer ' + token } });
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'Upload failed');
refreshAsset(asset.id); // show the new version on your page
},
onClose: () => { button.disabled = false; button.textContent = 'Edit with Caboodle'; },
onError: (err) => { button.disabled = false; alert(err.message); },
});
button.disabled = true;
button.textContent = 'Editing in Caboodle…';
return handle;
}
React
// once, e.g. in your root layout: <script src="https://caboodle.tools/edit.js" async />
// (with Next.js: <Script src="https://caboodle.tools/edit.js" strategy="afterInteractive" />)
export function EditWithCaboodle({ asset, onSaved }) {
const [editing, setEditing] = useState(false);
const open = () => {
// no await before this line: the window must open in the click
window.Caboodle.edit({
file: asset.url,
name: asset.name,
site: 'GamerFuel',
onSave: async (blob, name) => {
await uploadAssetVersion(asset.id, blob, name); // your API; throw on failure
onSaved?.();
},
onClose: () => setEditing(false),
onError: (e) => { setEditing(false); console.error(e); },
});
setEditing(true);
};
return <button onClick={open} disabled={editing || !window.Caboodle}>
{editing ? 'Editing in Caboodle…' : 'Edit with Caboodle'}
</button>;
}
TypeScript
declare global {
interface Window {
Caboodle: {
origin: string;
edit(o: {
file: Blob | string | Promise<Blob> | (() => Promise<Blob>);
name?: string;
site?: string;
format?: string;
program?: 'sprite' | 'graphics' | 'image' | 'spreadsheet' | 'document' | 'pdf' | 'slides' | 'wireframe' | 'mindmap' | 'midi' | 'video' | 'audio' | 'text';
data?: Blob | string | Promise<Blob> | (() => Blob | Promise<Blob>) | object; // with program: 'sprite'
style?: { unit?: number; view?: 'side' | 'top' | 'iso'; palette?: string[]; description?: string }; // with program: 'sprite'
references?: { name: string; file: Blob | string | Promise<Blob> | (() => Blob | Promise<Blob>); data?: Blob | string | Promise<Blob> | (() => Blob | Promise<Blob>) | object }[]; // at most 5
sheets?: { name: string; file: Blob | string | Promise<Blob> | (() => Blob | Promise<Blob>); data?: Blob | string | Promise<Blob> | (() => Blob | Promise<Blob>) | object }[]; // at most 100, to edit
title?: string;
onSave?: (blob: Blob, name: string, extra?: { data?: Blob; sheets?: { name: string; blob: Blob; data: Blob; opened?: true; from?: string }[] }) => void | Promise<void>; // data: a sheet’s JSON, or a song’s .mid
onClose?: () => void;
onError?: (error: Error) => void;
}): { window: Window; close(): void };
};
}
}
export {};
Good to know
- It comes back through the file format. What the format can’t hold doesn’t come back. For 3D: the model, materials, textures (at most 4096 px), animation and lights in glTF come back; Draco- or meshopt-compressed models come back uncompressed (bigger) – compress again on your side if you need to. The camera Caboodle adds to look at a model isn’t sent back.
- Your server decides. Caboodle only hands the file to the page that opened it. Check permissions in your upload endpoint as you would for any upload, and validate the file.
- Size: files are passed in memory; tens of MB are fine, hundreds work but use that much memory. Sounds and videos have their own limits in the editors.
- Phones: it works, but Caboodle’s programs are made for bigger screens.
- Several at once: each
Caboodle.edit()opens its own window with its own session; they don’t mix.
Testing
- Run your site on
http://localhost:<any port>– it’s allowed against caboodle.tools, so you can build before going live. - Click the button: Caboodle opens with the file and the “Editing … for site” strip.
- Change something, press Save to site:
onSavegets a Blob of the right type, and Caboodle says “Saved to site”. - Make
onSavethrow: Caboodle shows your message. - Close your page, then Save in Caboodle: it offers Download. Close Caboodle:
onCloseruns. - Automated tests: open your page in a real browser (Playwright, Puppeteer); the click has to be a real one (
page.click) for the window to open, and the new window is a new page/target.
A working stand-in site: examples/edit-with-caboodle.html (pick any file) – its source is examples/edit-with-caboodle.js, and the script itself is edit.js (about 130 lines, readable).
If something doesn’t work
| You see | Why, and what to do |
|---|---|
| “the browser blocked the window – call it from a click” | Caboodle.edit ran after an await or a timer. Call it first thing in the click handler; pass the file as a URL, promise or function. |
| “site can’t open files in Caboodle – only https sites can” | Your page is on plain http somewhere other than localhost. Serve it over https. |
| “…but that page isn’t there – open it again from the site” | Caboodle has no link back to your page: the page sent Cross-Origin-Opener-Policy: same-origin, the window was opened with noopener, or the link was copied into a new tab. Use Caboodle.edit and drop that COOP value. |
| Caboodle stays on “Opening a file from …” | The file hasn’t arrived: your file promise is still pending, or the fetch failed (then onError runs). Check the URL and CORS. |
| “Caboodle.edit: Caboodle doesn’t open …” | The extension isn’t in the table. Give name the right extension, or pass program. |
| “Not saved to site: …” | Your onSave threw; the rest is your message. |
| The script doesn’t load | Your Content-Security-Policy: add https://caboodle.tools to script-src. |
The messages (without edit.js)
edit.js is the supported way. If you’d rather speak to Caboodle yourself:
- Open
https://caboodle.tools/<page>?edit=<session>&from=<your origin, URL-encoded>withwindow.open(notnoopener).<page>issprite.html,graphics.html,image.html,spreadsheet.html,document.html,pdf.html,slides.html,wireframe.html,mindmap.html,midi.html,video.html,audio.htmlortext.html;<session>is 8–40 characters ofa–z 0–9, new each time. - Caboodle → you:
{ t: 'caboodle:ready', session }when it’s ready. - You → Caboodle:
{ t: 'caboodle:open', session, file: Blob, name, format, site, data?: Blob, style?, references?, sheets?, title?, v?: 2 }, withtargetOrigin'https://caboodle.tools'. Forsprite.html:datathe sheet’s Aseprite JSON,style{ unit, view, palette, description },references[{ name, file: Blob, data?: Blob }](at most 5),sheets[{ name, file: Blob, data?: Blob }](at most 100, to edit). - Caboodle → you, on each save:
{ t: 'caboodle:save', session, blob, name, data?: Blob, sheets? }– fromsprite.html:datathe sheet’s Aseprite JSON,sheets[{ name, blob: Blob, data: Blob, opened?: true, from?: string }], the sheets you sent (opened, by their names) and those made in the window (from: the sheet sent that a reskin or recolour was made from); frommidi.htmlwith formatmp3orwav:datathe song’s.mid. - You → Caboodle, at once:
{ t: 'caboodle:saving', session }(if yourcaboodle:opensaidv: 2– then, without it within a few seconds, Caboodle tells the person your page was reloaded or left and offers the file as a download), and when it’s stored:{ t: 'caboodle:saved', session, ok: true }or{ …, ok: false, error: 'message' }.
Accept messages only where event.origin === 'https://caboodle.tools', event.source is the window you opened and session is yours. Caboodle does the same the other way round.
Questions, or a site to add: hello@caboodle.tools · About Caboodle