Apply palette
apply_paletteApply multiple color replacements in one reversible operation. Re-theme or rebrand a document's colors by mapping source colors to replacements, all under a single snapshot for easy undo.
Instructions
Apply many from -> to colour replacements in a single reversible operation.
When to use: re-theming / rebranding a document's colours in one shot. For a single colour swap
use replace_color; to recolour specific objects use set_fill / set_stroke.
Key params: mapping maps each source colour to its replacement; every key AND value is
strictly colour-validated UP FRONT — a typo'd or non-colour entry (e.g. notacolor) is rejected
with a ToolError BEFORE any mutation, op record, or snapshot is created. Each reuses
the replace_color matching logic. scope_ids, if given, confines all replacements to those
elements' subtrees.
Return shape: EditResult — operation_id, snapshot_id, changed (a real before/after
content diff), before/after preview; the whole palette is applied under one snapshot
(reversible).
Example: apply_palette(doc_id, {"#ff0000": "#3366cc", "#00ff00": "#66cc33"})
Render and look before you trust this edit: render with render_preview (or live_render_view)
and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.
Risk class: medium.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| mapping | Yes | ||
| scope_ids | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| changed | Yes | ||
| summary | No | ||
| snapshot_id | Yes | ||
| operation_id | Yes | ||
| preview_after | No | ||
| preview_before | No |