@pixerate/editor 0.152.0 → 0.154.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.
Files changed (46) hide show
  1. package/dist/animation-editor/index.cjs +4 -4
  2. package/dist/animation-editor/index.js +4 -4
  3. package/dist/canvas/editorDocument.d.cts +59 -0
  4. package/dist/canvas/editorDocument.d.ts +59 -0
  5. package/dist/canvas/index.cjs +127 -14
  6. package/dist/canvas/index.d.cts +1 -0
  7. package/dist/canvas/index.d.ts +1 -0
  8. package/dist/canvas/index.js +114 -1
  9. package/dist/chart/index.cjs +3 -3
  10. package/dist/chart/index.js +3 -3
  11. package/dist/{chunk-VGJTUCWM.js → chunk-4J4MC3F5.js} +72 -5
  12. package/dist/{chunk-LFKLA7RC.js → chunk-BCY22GBH.js} +39 -1
  13. package/dist/{chunk-2ZO4RSDS.cjs → chunk-HVX35M2I.cjs} +39 -1
  14. package/dist/{chunk-QSM3MDDJ.cjs → chunk-XFDQEAOS.cjs} +92 -25
  15. package/dist/image-editor/index.cjs +3 -3
  16. package/dist/image-editor/index.js +3 -3
  17. package/dist/index.cjs +41 -2
  18. package/dist/index.d.cts +1 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +40 -1
  21. package/dist/richTextDocument.d.cts +10 -0
  22. package/dist/richTextDocument.d.ts +10 -0
  23. package/dist/spreadsheet/controller.d.cts +17 -4
  24. package/dist/spreadsheet/controller.d.ts +17 -4
  25. package/dist/spreadsheet/editorDocument.d.cts +9 -0
  26. package/dist/spreadsheet/editorDocument.d.ts +9 -0
  27. package/dist/spreadsheet/index.cjs +7 -2
  28. package/dist/spreadsheet/index.d.cts +1 -0
  29. package/dist/spreadsheet/index.d.ts +1 -0
  30. package/dist/spreadsheet/index.js +6 -1
  31. package/dist/tokens/editorDocument.d.cts +10 -0
  32. package/dist/tokens/editorDocument.d.ts +10 -0
  33. package/dist/tokens/index.cjs +7 -2
  34. package/dist/tokens/index.d.cts +1 -0
  35. package/dist/tokens/index.d.ts +1 -0
  36. package/dist/tokens/index.js +6 -1
  37. package/dist/vector/index.cjs +4 -4
  38. package/dist/vector/index.js +4 -4
  39. package/dist/video-editor/index.cjs +4 -4
  40. package/dist/video-editor/index.js +4 -4
  41. package/package.json +1 -1
  42. package/skills/README.md +1 -0
  43. package/skills/pixerate-canvas/SKILL.md +14 -0
  44. package/skills/pixerate-rich-text/SKILL.md +14 -0
  45. package/skills/pixerate-spreadsheet/SKILL.md +14 -0
  46. package/skills/pixerate-tokens/SKILL.md +56 -0
@@ -46,6 +46,7 @@ import {
46
46
  copySheetName,
47
47
  createConditionalFormatRule,
48
48
  createSpreadsheetClipboardData,
49
+ createSpreadsheetEditorDocument,
49
50
  csvImportAdapter,
50
51
  defaultIconThresholds,
51
52
  deleteSheetInFormula,
@@ -125,7 +126,7 @@ import {
125
126
  validateCellInput,
126
127
  validateDefinedName,
127
128
  validateSheetName
128
- } from "../chunk-VGJTUCWM.js";
129
+ } from "../chunk-4J4MC3F5.js";
129
130
  import {
130
131
  FormulaEvaluator,
131
132
  FormulaLambda,
@@ -197,6 +198,9 @@ import {
197
198
  serializeCsv,
198
199
  serializeTsv
199
200
  } from "../chunk-WJSD3MAZ.js";
201
+ import "../chunk-GNV54DLO.js";
202
+ import "../chunk-WHKNYFM2.js";
203
+ import "../chunk-HF5QZS7Z.js";
200
204
  export {
201
205
  CONDITIONAL_FORMAT_ICON_SETS,
202
206
  CONDITIONAL_FORMAT_PRESETS,
@@ -264,6 +268,7 @@ export {
264
268
  copySheetName,
265
269
  createConditionalFormatRule,
266
270
  createSpreadsheetClipboardData,
271
+ createSpreadsheetEditorDocument,
267
272
  csvImportAdapter,
268
273
  dateValueToSerial,
269
274
  defaultIconThresholds,
@@ -0,0 +1,10 @@
1
+ import { type EditorDocument } from '../persistence/editorDocument.cjs';
2
+ import type { TokenState } from './types.cjs';
3
+ import type { TokenStore } from './store.cjs';
4
+ /**
5
+ * The save / load / undo contract for a `TokenStore` (kind `tokens`, document: the
6
+ * `TokenState` of collections, modes and variables). A recorded load (agents) is one undo step
7
+ * and refuses a state with any problem; opening a file (`history: "reset"`) keeps what
8
+ * `parseTokenState` can read and reports the rest in the `LoadReport`.
9
+ */
10
+ export declare function createTokensEditorDocument(store: TokenStore): EditorDocument<TokenState>;
@@ -0,0 +1,10 @@
1
+ import { type EditorDocument } from '../persistence/editorDocument.js';
2
+ import type { TokenState } from './types.js';
3
+ import type { TokenStore } from './store.js';
4
+ /**
5
+ * The save / load / undo contract for a `TokenStore` (kind `tokens`, document: the
6
+ * `TokenState` of collections, modes and variables). A recorded load (agents) is one undo step
7
+ * and refuses a state with any problem; opening a file (`history: "reset"`) keeps what
8
+ * `parseTokenState` can read and reports the rest in the `LoadReport`.
9
+ */
10
+ export declare function createTokensEditorDocument(store: TokenStore): EditorDocument<TokenState>;
@@ -51,7 +51,11 @@
51
51
 
52
52
 
53
53
 
54
- var _chunk2ZO4RSDScjs = require('../chunk-2ZO4RSDS.cjs');
54
+
55
+ var _chunkHVX35M2Icjs = require('../chunk-HVX35M2I.cjs');
56
+ require('../chunk-5H2C3QSF.cjs');
57
+ require('../chunk-L5OWG2NA.cjs');
58
+ require('../chunk-2BSBFBOA.cjs');
55
59
 
56
60
 
57
61
 
@@ -113,4 +117,5 @@ var _chunkA6QWKBJPcjs = require('../chunk-A6QWKBJP.cjs');
113
117
 
114
118
 
115
119
 
116
- exports.EMPTY_TOKEN_STATE = _chunk2ZO4RSDScjs.EMPTY_TOKEN_STATE; exports.TOKEN_SCOPES_BY_TYPE = _chunk2ZO4RSDScjs.TOKEN_SCOPES_BY_TYPE; exports.TOKEN_TYPES = _chunk2ZO4RSDScjs.TOKEN_TYPES; exports.TokenError = _chunk2ZO4RSDScjs.TokenError; exports.TokenStore = _chunk2ZO4RSDScjs.TokenStore; exports.W3C_TOKENS_EXTENSION = _chunk2ZO4RSDScjs.W3C_TOKENS_EXTENSION; exports.addTokenMode = _chunk2ZO4RSDScjs.addTokenMode; exports.checkTokenAlias = _chunk2ZO4RSDScjs.checkTokenAlias; exports.coerceTokenLiteral = _chunk2ZO4RSDScjs.coerceTokenLiteral; exports.createTokenCollection = _chunk2ZO4RSDScjs.createTokenCollection; exports.createTokenStore = _chunk2ZO4RSDScjs.createTokenStore; exports.createTokenVariable = _chunk2ZO4RSDScjs.createTokenVariable; exports.cssString = _chunk2ZO4RSDScjs.cssString; exports.defaultTokenId = _chunk2ZO4RSDScjs.defaultTokenId; exports.defaultTokenValue = _chunk2ZO4RSDScjs.defaultTokenValue; exports.deleteTokenCollection = _chunk2ZO4RSDScjs.deleteTokenCollection; exports.deleteTokenVariables = _chunk2ZO4RSDScjs.deleteTokenVariables; exports.exportTokensCss = _chunk2ZO4RSDScjs.exportTokensCss; exports.exportW3CTokens = _chunk2ZO4RSDScjs.exportW3CTokens; exports.exportW3CTokensJson = _chunk2ZO4RSDScjs.exportW3CTokensJson; exports.findTokenCollection = _chunk2ZO4RSDScjs.findTokenCollection; exports.findTokenMode = _chunk2ZO4RSDScjs.findTokenMode; exports.findTokenVariable = _chunk2ZO4RSDScjs.findTokenVariable; exports.formatTokenCssValue = _chunk2ZO4RSDScjs.formatTokenCssValue; exports.formatTokenValue = _chunk2ZO4RSDScjs.formatTokenValue; exports.getCollectionVariables = _chunk2ZO4RSDScjs.getCollectionVariables; exports.getCurrentMode = _chunk2ZO4RSDScjs.getCurrentMode; exports.getDefaultMode = _chunk2ZO4RSDScjs.getDefaultMode; exports.getTokenCollection = _chunk2ZO4RSDScjs.getTokenCollection; exports.getTokenCssName = _chunk2ZO4RSDScjs.getTokenCssName; exports.getTokenCssVariables = _chunk2ZO4RSDScjs.getTokenCssVariables; exports.getTokenVariable = _chunk2ZO4RSDScjs.getTokenVariable; exports.hexToRgba = _chunkA6QWKBJPcjs.hexToRgba; exports.importW3CTokens = _chunk2ZO4RSDScjs.importW3CTokens; exports.isTokenAlias = _chunk2ZO4RSDScjs.isTokenAlias; exports.isTokenInScope = _chunk2ZO4RSDScjs.isTokenInScope; exports.isTokenScopeKnown = _chunk2ZO4RSDScjs.isTokenScopeKnown; exports.literalTokenType = _chunk2ZO4RSDScjs.literalTokenType; exports.moveTokenMode = _chunk2ZO4RSDScjs.moveTokenMode; exports.normalizeTokenColor = _chunkA6QWKBJPcjs.normalizeTokenColor; exports.normalizeTokenName = _chunk2ZO4RSDScjs.normalizeTokenName; exports.normalizeTokenScopes = _chunk2ZO4RSDScjs.normalizeTokenScopes; exports.parseTokenState = _chunk2ZO4RSDScjs.parseTokenState; exports.prepareTokenValue = _chunk2ZO4RSDScjs.prepareTokenValue; exports.removeTokenMode = _chunk2ZO4RSDScjs.removeTokenMode; exports.renameTokenCollection = _chunk2ZO4RSDScjs.renameTokenCollection; exports.renameTokenMode = _chunk2ZO4RSDScjs.renameTokenMode; exports.renameTokenVariable = _chunk2ZO4RSDScjs.renameTokenVariable; exports.resolveToken = _chunk2ZO4RSDScjs.resolveToken; exports.resolveTokenInMode = _chunk2ZO4RSDScjs.resolveTokenInMode; exports.resolveTokenValue = _chunk2ZO4RSDScjs.resolveTokenValue; exports.rgbaToHex = _chunkA6QWKBJPcjs.rgbaToHex; exports.setTokenValue = _chunk2ZO4RSDScjs.setTokenValue; exports.tokenSlug = _chunk2ZO4RSDScjs.tokenSlug; exports.updateTokenVariable = _chunk2ZO4RSDScjs.updateTokenVariable;
120
+
121
+ exports.EMPTY_TOKEN_STATE = _chunkHVX35M2Icjs.EMPTY_TOKEN_STATE; exports.TOKEN_SCOPES_BY_TYPE = _chunkHVX35M2Icjs.TOKEN_SCOPES_BY_TYPE; exports.TOKEN_TYPES = _chunkHVX35M2Icjs.TOKEN_TYPES; exports.TokenError = _chunkHVX35M2Icjs.TokenError; exports.TokenStore = _chunkHVX35M2Icjs.TokenStore; exports.W3C_TOKENS_EXTENSION = _chunkHVX35M2Icjs.W3C_TOKENS_EXTENSION; exports.addTokenMode = _chunkHVX35M2Icjs.addTokenMode; exports.checkTokenAlias = _chunkHVX35M2Icjs.checkTokenAlias; exports.coerceTokenLiteral = _chunkHVX35M2Icjs.coerceTokenLiteral; exports.createTokenCollection = _chunkHVX35M2Icjs.createTokenCollection; exports.createTokenStore = _chunkHVX35M2Icjs.createTokenStore; exports.createTokenVariable = _chunkHVX35M2Icjs.createTokenVariable; exports.createTokensEditorDocument = _chunkHVX35M2Icjs.createTokensEditorDocument; exports.cssString = _chunkHVX35M2Icjs.cssString; exports.defaultTokenId = _chunkHVX35M2Icjs.defaultTokenId; exports.defaultTokenValue = _chunkHVX35M2Icjs.defaultTokenValue; exports.deleteTokenCollection = _chunkHVX35M2Icjs.deleteTokenCollection; exports.deleteTokenVariables = _chunkHVX35M2Icjs.deleteTokenVariables; exports.exportTokensCss = _chunkHVX35M2Icjs.exportTokensCss; exports.exportW3CTokens = _chunkHVX35M2Icjs.exportW3CTokens; exports.exportW3CTokensJson = _chunkHVX35M2Icjs.exportW3CTokensJson; exports.findTokenCollection = _chunkHVX35M2Icjs.findTokenCollection; exports.findTokenMode = _chunkHVX35M2Icjs.findTokenMode; exports.findTokenVariable = _chunkHVX35M2Icjs.findTokenVariable; exports.formatTokenCssValue = _chunkHVX35M2Icjs.formatTokenCssValue; exports.formatTokenValue = _chunkHVX35M2Icjs.formatTokenValue; exports.getCollectionVariables = _chunkHVX35M2Icjs.getCollectionVariables; exports.getCurrentMode = _chunkHVX35M2Icjs.getCurrentMode; exports.getDefaultMode = _chunkHVX35M2Icjs.getDefaultMode; exports.getTokenCollection = _chunkHVX35M2Icjs.getTokenCollection; exports.getTokenCssName = _chunkHVX35M2Icjs.getTokenCssName; exports.getTokenCssVariables = _chunkHVX35M2Icjs.getTokenCssVariables; exports.getTokenVariable = _chunkHVX35M2Icjs.getTokenVariable; exports.hexToRgba = _chunkA6QWKBJPcjs.hexToRgba; exports.importW3CTokens = _chunkHVX35M2Icjs.importW3CTokens; exports.isTokenAlias = _chunkHVX35M2Icjs.isTokenAlias; exports.isTokenInScope = _chunkHVX35M2Icjs.isTokenInScope; exports.isTokenScopeKnown = _chunkHVX35M2Icjs.isTokenScopeKnown; exports.literalTokenType = _chunkHVX35M2Icjs.literalTokenType; exports.moveTokenMode = _chunkHVX35M2Icjs.moveTokenMode; exports.normalizeTokenColor = _chunkA6QWKBJPcjs.normalizeTokenColor; exports.normalizeTokenName = _chunkHVX35M2Icjs.normalizeTokenName; exports.normalizeTokenScopes = _chunkHVX35M2Icjs.normalizeTokenScopes; exports.parseTokenState = _chunkHVX35M2Icjs.parseTokenState; exports.prepareTokenValue = _chunkHVX35M2Icjs.prepareTokenValue; exports.removeTokenMode = _chunkHVX35M2Icjs.removeTokenMode; exports.renameTokenCollection = _chunkHVX35M2Icjs.renameTokenCollection; exports.renameTokenMode = _chunkHVX35M2Icjs.renameTokenMode; exports.renameTokenVariable = _chunkHVX35M2Icjs.renameTokenVariable; exports.resolveToken = _chunkHVX35M2Icjs.resolveToken; exports.resolveTokenInMode = _chunkHVX35M2Icjs.resolveTokenInMode; exports.resolveTokenValue = _chunkHVX35M2Icjs.resolveTokenValue; exports.rgbaToHex = _chunkA6QWKBJPcjs.rgbaToHex; exports.setTokenValue = _chunkHVX35M2Icjs.setTokenValue; exports.tokenSlug = _chunkHVX35M2Icjs.tokenSlug; exports.updateTokenVariable = _chunkHVX35M2Icjs.updateTokenVariable;
@@ -9,3 +9,4 @@ export * from './model.cjs';
9
9
  export * from './store.cjs';
10
10
  export * from './css.cjs';
11
11
  export * from './w3c.cjs';
12
+ export * from './editorDocument.cjs';
@@ -9,3 +9,4 @@ export * from './model.js';
9
9
  export * from './store.js';
10
10
  export * from './css.js';
11
11
  export * from './w3c.js';
12
+ export * from './editorDocument.js';
@@ -11,6 +11,7 @@ import {
11
11
  createTokenCollection,
12
12
  createTokenStore,
13
13
  createTokenVariable,
14
+ createTokensEditorDocument,
14
15
  cssString,
15
16
  defaultTokenId,
16
17
  defaultTokenValue,
@@ -51,7 +52,10 @@ import {
51
52
  setTokenValue,
52
53
  tokenSlug,
53
54
  updateTokenVariable
54
- } from "../chunk-LFKLA7RC.js";
55
+ } from "../chunk-BCY22GBH.js";
56
+ import "../chunk-GNV54DLO.js";
57
+ import "../chunk-WHKNYFM2.js";
58
+ import "../chunk-HF5QZS7Z.js";
55
59
  import {
56
60
  hexToRgba,
57
61
  normalizeTokenColor,
@@ -70,6 +74,7 @@ export {
70
74
  createTokenCollection,
71
75
  createTokenStore,
72
76
  createTokenVariable,
77
+ createTokensEditorDocument,
73
78
  cssString,
74
79
  defaultTokenId,
75
80
  defaultTokenValue,
@@ -41,9 +41,6 @@ var _chunkQT26RHKKcjs = require('../chunk-QT26RHKK.cjs');
41
41
  var _chunkLIXLD433cjs = require('../chunk-LIXLD433.cjs');
42
42
 
43
43
 
44
- var _chunk5H2C3QSFcjs = require('../chunk-5H2C3QSF.cjs');
45
-
46
-
47
44
 
48
45
 
49
46
 
@@ -515,7 +512,6 @@ require('../chunk-BXMIBMVG.cjs');
515
512
 
516
513
 
517
514
  var _chunkCVFAAZXEcjs = require('../chunk-CVFAAZXE.cjs');
518
- require('../chunk-L5OWG2NA.cjs');
519
515
 
520
516
 
521
517
 
@@ -562,6 +558,10 @@ var _chunkCWM3CUUXcjs = require('../chunk-CWM3CUUX.cjs');
562
558
  var _chunkXFM3OCHUcjs = require('../chunk-XFM3OCHU.cjs');
563
559
  require('../chunk-NIBFDFYW.cjs');
564
560
  require('../chunk-UWEQ55MY.cjs');
561
+
562
+
563
+ var _chunk5H2C3QSFcjs = require('../chunk-5H2C3QSF.cjs');
564
+ require('../chunk-L5OWG2NA.cjs');
565
565
  require('../chunk-2BSBFBOA.cjs');
566
566
 
567
567
 
@@ -39,9 +39,6 @@ import {
39
39
  subpathToMorphContour,
40
40
  turnMorphContour
41
41
  } from "../chunk-UILRJQFD.js";
42
- import {
43
- defineEditorDocument
44
- } from "../chunk-GNV54DLO.js";
45
42
  import {
46
43
  DEFAULT_VECTOR_FONT,
47
44
  IDENTITY_MATRIX,
@@ -515,7 +512,6 @@ import "../chunk-ORDXMBD4.js";
515
512
  import {
516
513
  createProvenance
517
514
  } from "../chunk-M6DNZNVY.js";
518
- import "../chunk-WHKNYFM2.js";
519
515
  import {
520
516
  bezierPathBounds,
521
517
  bezierPathToSvg,
@@ -562,6 +558,10 @@ import {
562
558
  } from "../chunk-QGHEDC7B.js";
563
559
  import "../chunk-SIFAIGB3.js";
564
560
  import "../chunk-VDGBHYC7.js";
561
+ import {
562
+ defineEditorDocument
563
+ } from "../chunk-GNV54DLO.js";
564
+ import "../chunk-WHKNYFM2.js";
565
565
  import "../chunk-HF5QZS7Z.js";
566
566
  import {
567
567
  HistoryManager
@@ -141,14 +141,14 @@ require('../chunk-PY4GWSE2.cjs');
141
141
  var _chunkEBDZWIOPcjs = require('../chunk-EBDZWIOP.cjs');
142
142
 
143
143
 
144
- var _chunk5H2C3QSFcjs = require('../chunk-5H2C3QSF.cjs');
145
- require('../chunk-L5OWG2NA.cjs');
146
-
147
-
148
144
 
149
145
 
150
146
  var _chunkRUZQMYXHcjs = require('../chunk-RUZQMYXH.cjs');
151
147
  require('../chunk-WOFXZ3XU.cjs');
148
+
149
+
150
+ var _chunk5H2C3QSFcjs = require('../chunk-5H2C3QSF.cjs');
151
+ require('../chunk-L5OWG2NA.cjs');
152
152
  require('../chunk-2BSBFBOA.cjs');
153
153
 
154
154
 
@@ -139,16 +139,16 @@ import "../chunk-EHLOCVWB.js";
139
139
  import {
140
140
  namedWithSuggestion
141
141
  } from "../chunk-W4KFNAWC.js";
142
- import {
143
- defineEditorDocument
144
- } from "../chunk-GNV54DLO.js";
145
- import "../chunk-WHKNYFM2.js";
146
142
  import {
147
143
  EffectsSlot,
148
144
  createEffectToolProvider,
149
145
  isEffectError
150
146
  } from "../chunk-7KWJEYIK.js";
151
147
  import "../chunk-V2ZCJRDM.js";
148
+ import {
149
+ defineEditorDocument
150
+ } from "../chunk-GNV54DLO.js";
151
+ import "../chunk-WHKNYFM2.js";
152
152
  import "../chunk-HF5QZS7Z.js";
153
153
  import {
154
154
  HistoryManager
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.152.0",
3
+ "version": "0.154.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
package/skills/README.md CHANGED
@@ -20,6 +20,7 @@ that uses the tools can load the matching skill.
20
20
  | [`pixerate-video-editor`](pixerate-video-editor/SKILL.md) | Non-linear video editing: tracks, clips, transitions, export. |
21
21
  | [`pixerate-generation`](pixerate-generation/SKILL.md) | Planning, estimating and running paid media generation. |
22
22
  | [`pixerate-parameters`](pixerate-parameters/SKILL.md) | Effect parameters, presets and keyframes. |
23
+ | [`pixerate-tokens`](pixerate-tokens/SKILL.md) | Design tokens: collections, modes, variables and aliases, through the whole-set document tools. |
23
24
  | [`pixerate-effect-authoring`](pixerate-effect-authoring/SKILL.md) | Authoring shaders and procedural effects: inspecting parameters and source code, setting values and presets, keyframing animation tracks, playback timing, and previewing. |
24
25
  | [`pixerate-color`](pixerate-color/SKILL.md) | Colour inspection, WCAG accessibility and contrast optimization, CVD simulation, palette audits, harmonies, and OKLab/OKLCH blends. |
25
26
 
@@ -130,6 +130,20 @@ the reason (for example a variant combination that already exists, or a cycle).
130
130
  | `rename_variant_property` | Rename property `name` to `newName` across a set; instances keep their variant. |
131
131
  | `rename_variant_value` | Rename `value` of `property` to `newValue` across a set; instances keep their variant. |
132
132
 
133
+ ### Save and open
134
+
135
+ The host may add the shared document tools (see `pixerate-agent-tools`). A canvas document is `{ nodes, edges, scenes }`: every node (`id`, `position`, `data`, `type`, `parentId`...) and edge without selection or measurement, plus the saved scenes.
136
+
137
+ | Tool | Use |
138
+ | --- | --- |
139
+ | `get_canvas_document` | Take a copy of the whole canvas as `{ kind, formatVersion, revision, document }` before a risky rewrite, or to hand it on. To read the canvas, use `get_editor_state`: it is smaller and says more. Refuses very large canvases. |
140
+ | `load_canvas_document` | Put back a copy from `get_canvas_document` (its `document`, or the whole result). Checked first: duplicate ids, edges to missing nodes and parents that do not exist are refused and nothing changes. One undo step (`undo_canvas` brings the previous canvas back). To add or change a few nodes use `canvas_add_node` / `canvas_update_node`. |
141
+ | `undo_canvas` | Undo the last canvas change (one tool call, command or user gesture such as a drag). Returns `undone` (the step's name) and whether more can be undone. Fails with "Nothing to undo." when there is nothing. |
142
+ | `redo_canvas` | Redo the last undone canvas change. |
143
+ | `save_canvas_document` | Save the canvas under a `name` in the host's storage (the same name replaces that copy). Returns the `key`. Only listed when the host has storage. Save when the user asks, not after every edit. |
144
+ | `list_saved_canvas_documents` | List saved canvases (`key`, `name`, `savedAt`), newest first. |
145
+ | `open_saved_canvas_document` | Replace the canvas with a saved one by `key`. One undo step. Ask before opening over changes the user has not saved. |
146
+
133
147
  ## Commands
134
148
 
135
149
  Run these through `run_command` / `run_commands`. Each takes `ids` (default: the selection) unless
@@ -106,6 +106,20 @@ Errors, namespacing (`doc-1__find_text`) and `run_commands` batching are covered
106
106
  | `prompt_set_variable` | Set the value of a template variable (`name` without braces, `value` any JSON value). Prefer this over editing the prompt text when only a slot's value changes. |
107
107
  | `prompt_select` | Select prompt text between two positions (`from === to` places the cursor), e.g. to show the user what you changed. |
108
108
 
109
+ ### Save and open
110
+
111
+ The host may add the shared document tools (see `pixerate-agent-tools`). A rich text document is the editor's ProseMirror JSON (`{ "type": "doc", "content": [...] }`), with marks such as tracked changes and comment anchors; comment threads stay in their own store.
112
+
113
+ | Tool | Use |
114
+ | --- | --- |
115
+ | `get_rich_text_document` | Take a copy of the whole document as `{ kind, formatVersion, revision, document }` before a risky rewrite, or to hand it on. To read the document, use `get_text`: it is smaller and says more. Refuses very large documents. |
116
+ | `load_rich_text_document` | Put back a copy from `get_rich_text_document` (its `document`, or the whole result). Checked first: when anything is wrong nothing changes and the error says what. One undo step (`undo_rich_text` brings the previous document back). Refused while the document is read-only. To change text use `replace_range`, `replace_text` or `insert_text`: they keep formatting and comments. |
117
+ | `undo_rich_text` | Undo the last document edit (one tool call or one user gesture). Returns `undone` (the step's name, when it has one) and whether more can be undone. Fails with "Nothing to undo." when there is nothing. |
118
+ | `redo_rich_text` | Redo the last undone document edit. |
119
+ | `save_rich_text_document` | Save the document under a `name` in the host's storage (the same name replaces that copy). Returns the `key`. Only listed when the host has storage. Save when the user asks, not after every edit. |
120
+ | `list_saved_rich_text_documents` | List saved documents (`key`, `name`, `savedAt`), newest first. |
121
+ | `open_saved_rich_text_document` | Replace the document with a saved one by `key`. One undo step. Ask before opening over changes the user has not saved. |
122
+
109
123
  ## Commands
110
124
 
111
125
  Run with `run_command` / `run_commands` when the host registers them. Check
@@ -107,6 +107,20 @@ cell was deleted), `#NAME?`, `#N/A` (lookup miss), `#NUM!`, `#CYCLE!` (circular
107
107
  | `unmerge_cells` | Split every merge touching a `range` (a single cell is enough) back into cells; the value stays top-left. Returns the ranges unmerged; fails when there are none (`get_range` lists them). Unmerge before sorting, filtering or transposing a region. |
108
108
  | `transpose_range` | Swap rows and columns of a `range` in place, anchored at its top-left (`A1:C2` becomes `A1:B3`), moving values, formulas and formats; formulas that pointed into the range follow their cells. Cells the new shape covers outside the old range are overwritten, so check that area is empty first. Refused across merges (unmerge first), read-only cells or spills. Returns the new range. |
109
109
 
110
+ ### Save and open
111
+
112
+ The host may add the shared document tools (see `pixerate-agent-tools`). A spreadsheet document is the whole workbook: `{ sheets: [{ columns, rows, cells, ... }], activeSheetId, names }`; selection and editing state are not part of it.
113
+
114
+ | Tool | Use |
115
+ | --- | --- |
116
+ | `get_spreadsheet_document` | Take a copy of the whole workbook as `{ kind, formatVersion, revision, document }` before a risky rewrite, or to hand it on. To read the workbook, use `get_range`: it is smaller and says more. Refuses very large documents. |
117
+ | `load_spreadsheet_document` | Put back a copy from `get_spreadsheet_document` (its `document`, or the whole result). Checked first: when anything is wrong nothing changes and the error says what. One undo step (`undo_spreadsheet` brings the previous workbook back). To change cells use `set_range` or `set_cell`. |
118
+ | `undo_spreadsheet` | Undo the last workbook edit (one tool call or one user gesture). Returns `undone` (the step's name, when it has one) and whether more can be undone. Fails with "Nothing to undo." when there is nothing. |
119
+ | `redo_spreadsheet` | Redo the last undone workbook edit. |
120
+ | `save_spreadsheet_document` | Save the workbook under a `name` in the host's storage (the same name replaces that copy). Returns the `key`. Only listed when the host has storage. Save when the user asks, not after every edit. |
121
+ | `list_saved_spreadsheet_documents` | List saved workbooks (`key`, `name`, `savedAt`), newest first. |
122
+ | `open_saved_spreadsheet_document` | Replace the workbook with a saved one by `key`. One undo step. Ask before opening over changes the user has not saved. |
123
+
110
124
  ## Commands
111
125
 
112
126
  Run with `run_command` when the host registers them. Merge, unmerge and transpose act on the
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: pixerate-tokens
3
+ description: How to read and change Pixerate design tokens (collections of variables with a value per mode, such as Light and Dark, and aliases between variables) through the shared document tools - getting the whole token set, editing collections, modes, variables and aliases, loading it back as one undo step, undo and redo, and saving or opening named token sets. Use when token tools (get_tokens_document, load_tokens_document...) are available or the user asks to change design tokens, theme colours, spacing scales or light / dark modes.
4
+ ---
5
+
6
+ # Design tokens
7
+
8
+ A token set holds **collections** (for example "Colours" or "Spacing"), each with one or more
9
+ **modes** ("Light" and "Dark", or "Mobile" and "Desktop"), and **variables** (`color`,
10
+ `number`, `string` or `boolean`) with a value for each mode of their collection. A value can be
11
+ an alias to another variable, so `button/background` can point at `brand/primary` and follow it.
12
+ Hosts turn the set into CSS variables per mode (`exportTokensCss`) and W3C design-token JSON.
13
+
14
+ There are no per-variable tools yet: read the whole set with `get_tokens_document`, change the
15
+ JSON, and write it back with `load_tokens_document`. Read `pixerate-agent-tools` first for tool
16
+ naming and errors.
17
+
18
+ ## Working method
19
+
20
+ 1. **Read.** `get_tokens_document`. Note collection, mode and variable ids: values are keyed by
21
+ mode id, and aliases name variable ids.
22
+ 2. **Change the copy.** Keep every id you are not deliberately removing. New ids must be unique
23
+ strings. Give every variable a value for every mode of its collection.
24
+ 3. **Write once.** `load_tokens_document` with the whole edited document. It is checked first: a
25
+ variable in a missing collection, a value for a missing mode or a broken alias is refused and
26
+ nothing changes. One load is one undo step.
27
+ 4. **Check.** Read the result's `revision`; if it did not change, nothing was different.
28
+
29
+ ## Best practices
30
+
31
+ - Name variables by role, not value: `text/primary`, not `grey-900`. Use `/` for groups.
32
+ - Put raw values in one primitives collection and point role variables at them with aliases,
33
+ so a theme change touches one place.
34
+ - Keep modes for real alternatives (Light / Dark). Do not make a mode per brand colour.
35
+ - Do not alias a variable to itself or in a cycle.
36
+
37
+ ## Save and open
38
+
39
+ The host may add the shared document tools (see `pixerate-agent-tools`). A tokens document is the whole `TokenState`: `{ collections: [{ id, name, modes: [{ id, name }] }], variables: [{ id, collectionId, name, type, valuesByMode }] }`. A value is a literal for its type (`"#rrggbb"` colours, numbers, strings, booleans) or an alias `{ "alias": "<variable id>" }`.
40
+
41
+ | Tool | Use |
42
+ | --- | --- |
43
+ | `get_tokens_document` | Take a copy of the whole token set as `{ kind, formatVersion, revision, document }` before a risky rewrite, or to hand it on. To read the token set, use `get_tokens_document`: it is smaller and says more. Refuses very large documents. |
44
+ | `load_tokens_document` | Put back a copy from `get_tokens_document` (its `document`, or the whole result). Checked first: when anything is wrong nothing changes and the error says what. One undo step (`undo_tokens` brings the previous token set back). Use it for every change: read the document, edit the JSON, load it back. |
45
+ | `undo_tokens` | Undo the last token set edit (one tool call or one user gesture). Returns `undone` (the step's name, when it has one) and whether more can be undone. Fails with "Nothing to undo." when there is nothing. |
46
+ | `redo_tokens` | Redo the last undone token set edit. |
47
+ | `save_tokens_document` | Save the token set under a `name` in the host's storage (the same name replaces that copy). Returns the `key`. Only listed when the host has storage. Save when the user asks, not after every edit. |
48
+ | `list_saved_tokens_documents` | List saved token sets (`key`, `name`, `savedAt`), newest first. |
49
+ | `open_saved_tokens_document` | Replace the token set with a saved one by `key`. One undo step. Ask before opening over changes the user has not saved. |
50
+
51
+ ## Pitfalls
52
+
53
+ - Removing a variable that others alias leaves broken aliases: point them elsewhere in the same
54
+ load.
55
+ - `load_tokens_document` replaces everything. Do not send a partial document: missing
56
+ collections and variables are deleted.