@pixerate/editor 0.269.2 → 0.270.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/agent/index.cjs +30 -30
- package/dist/agent/index.js +3 -3
- package/dist/animation-editor/index.cjs +2 -2
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/editorDocument.d.cts +3 -1
- package/dist/canvas/editorDocument.d.ts +3 -1
- package/dist/canvas/index.cjs +51 -25
- package/dist/canvas/index.js +33 -7
- package/dist/chart/index.cjs +21 -21
- package/dist/chart/index.js +2 -2
- package/dist/{chunk-GBEF2D4P.js → chunk-23YL2EAB.js} +1 -1
- package/dist/{chunk-QGVTOCNB.js → chunk-6ZSFRRJI.js} +1 -1
- package/dist/{chunk-T4JPGBW3.cjs → chunk-DGITFN73.cjs} +8 -8
- package/dist/{chunk-NS62CQ2B.js → chunk-GAZPHCTV.js} +23 -2
- package/dist/{chunk-YYBW6DF2.cjs → chunk-GSLOH2IN.cjs} +2 -2
- package/dist/{chunk-MQ6MGIQM.js → chunk-NMZQMPFZ.js} +1 -1
- package/dist/{chunk-AI4F33IV.cjs → chunk-NQUKTRKN.cjs} +45 -45
- package/dist/{chunk-WKPXOGZZ.cjs → chunk-WPLGZBNE.cjs} +23 -2
- package/dist/{chunk-N3UMQVKX.js → chunk-X4FTNFIA.js} +1 -1
- package/dist/{chunk-2OQGPEHH.cjs → chunk-XUDMRMXQ.cjs} +2 -2
- package/dist/diagram/index.cjs +2 -2
- package/dist/diagram/index.js +1 -1
- package/dist/effects/index.cjs +4 -4
- package/dist/effects/index.js +2 -2
- package/dist/extensions/index.cjs +5 -5
- package/dist/extensions/index.js +4 -4
- package/dist/gradient/index.cjs +2 -2
- package/dist/gradient/index.js +1 -1
- package/dist/history/HistoryManager.d.cts +9 -0
- package/dist/history/HistoryManager.d.ts +9 -0
- package/dist/history/index.cjs +2 -2
- package/dist/history/index.js +1 -1
- package/dist/history/types.d.cts +5 -2
- package/dist/history/types.d.ts +5 -2
- package/dist/index.cjs +10 -10
- package/dist/index.js +4 -4
- package/dist/parameters/index.cjs +2 -2
- package/dist/parameters/index.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +4 -4
- package/dist/video-editor/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -573,9 +573,12 @@ const mark = history.mark();
|
|
|
573
573
|
history.revertTo(mark); // returns the number of steps reverted (0 if the mark is gone)
|
|
574
574
|
|
|
575
575
|
// History panel
|
|
576
|
-
history.getEntries(); // [{ id, label, index, current, undone }]
|
|
576
|
+
history.getEntries(); // [{ id, label, index, current, undone, origin, tag? }]
|
|
577
577
|
history.goTo(2); // undo / redo until entry 2 is current; goTo(-1) undoes everything
|
|
578
578
|
|
|
579
|
+
// Stale steps: when remote content replaces what some steps change, remove them unrun.
|
|
580
|
+
history.dropSteps((step) => step.tag === "paint"); // returns how many were removed
|
|
581
|
+
|
|
579
582
|
// Dirty vs saved: undoing back to the saved state is clean again.
|
|
580
583
|
const dirty = bindDirtyToHistory({
|
|
581
584
|
history,
|
|
@@ -587,7 +590,7 @@ dirty.markClean(); // after saving
|
|
|
587
590
|
dirty.dirty; // feed to useNavigationGuard / createNavigationGuard
|
|
588
591
|
```
|
|
589
592
|
|
|
590
|
-
Tag-only `executeMerged(cmd)` keeps its 300 ms time-window coalescing. React exposes the same API through `useHistory()` (`entries`, `goTo`, `mark`, `revertTo`, `beginGesture`, `endGesture`) and `useHistoryDirty()`; Svelte through `createHistory()` and `createHistoryDirty()`.
|
|
593
|
+
Tag-only `executeMerged(cmd)` keeps its 300 ms time-window coalescing. React exposes the same API through `useHistory()` (`entries`, `goTo`, `mark`, `revertTo`, `dropSteps`, `beginGesture`, `endGesture`) and `useHistoryDirty()`; Svelte through `createHistory()` and `createHistoryDirty()`.
|
|
591
594
|
|
|
592
595
|
## License
|
|
593
596
|
|
package/dist/agent/index.cjs
CHANGED
|
@@ -140,10 +140,10 @@ var _chunkN2FGYZ4Qcjs = require('../chunk-N2FGYZ4Q.cjs');
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
var
|
|
143
|
+
var _chunkDGITFN73cjs = require('../chunk-DGITFN73.cjs');
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
var
|
|
146
|
+
var _chunkGSLOH2INcjs = require('../chunk-GSLOH2IN.cjs');
|
|
147
147
|
require('../chunk-TTCJPX4U.cjs');
|
|
148
148
|
require('../chunk-MDLEGVEN.cjs');
|
|
149
149
|
require('../chunk-VU6WQSMB.cjs');
|
|
@@ -191,7 +191,7 @@ var _chunkWOFXZ3XUcjs = require('../chunk-WOFXZ3XU.cjs');
|
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
var _chunk2BSBFBOAcjs = require('../chunk-2BSBFBOA.cjs');
|
|
194
|
-
require('../chunk-
|
|
194
|
+
require('../chunk-WPLGZBNE.cjs');
|
|
195
195
|
require('../chunk-I3Y2Q3PM.cjs');
|
|
196
196
|
require('../chunk-MEGSQUQO.cjs');
|
|
197
197
|
require('../chunk-MLLTWAXH.cjs');
|
|
@@ -691,14 +691,14 @@ function describe(chart, includeSpec) {
|
|
|
691
691
|
series: spec.series.map((s) => ({ id: s.id, name: s.name })),
|
|
692
692
|
width: _nullishCoalesce(node.attrs.width, () => ( null)),
|
|
693
693
|
height: node.attrs.height,
|
|
694
|
-
description:
|
|
694
|
+
description: _chunkGSLOH2INcjs.describeChart.call(void 0, spec),
|
|
695
695
|
...includeSpec ? { spec } : {}
|
|
696
696
|
};
|
|
697
697
|
}
|
|
698
698
|
function sparklines(doc) {
|
|
699
699
|
const found = [];
|
|
700
700
|
doc.descendants((node, pos) => {
|
|
701
|
-
if (node.type.name === "sparkline") found.push({ pos, kind: node.attrs.kind, values: node.attrs.values, label:
|
|
701
|
+
if (node.type.name === "sparkline") found.push({ pos, kind: node.attrs.kind, values: node.attrs.values, label: _chunkDGITFN73cjs.sparklineLabel.call(void 0, node) });
|
|
702
702
|
});
|
|
703
703
|
return found;
|
|
704
704
|
}
|
|
@@ -709,7 +709,7 @@ function checkPosition(editor, at) {
|
|
|
709
709
|
function createDocumentChartTools(editor) {
|
|
710
710
|
const chartType = () => editor().schema.nodes.chart;
|
|
711
711
|
const findChart = (args) => {
|
|
712
|
-
const charts =
|
|
712
|
+
const charts = _chunkDGITFN73cjs.getDocumentCharts.call(void 0, editor().state.doc);
|
|
713
713
|
const list = charts.map((c) => `"${c.id}" at ${c.pos}`).join(", ") || "none; add one with insert_chart";
|
|
714
714
|
if (args.chartId !== void 0) {
|
|
715
715
|
const chart = charts.find((c) => c.id === args.chartId);
|
|
@@ -736,7 +736,7 @@ function createDocumentChartTools(editor) {
|
|
|
736
736
|
annotations: { title: "List charts in the document", ...READ },
|
|
737
737
|
handler: ({ includeSpec = false }) => {
|
|
738
738
|
const doc = editor().state.doc;
|
|
739
|
-
return { charts:
|
|
739
|
+
return { charts: _chunkDGITFN73cjs.getDocumentCharts.call(void 0, doc).map((c) => describe(c, includeSpec)), sparklines: editor().schema.nodes.sparkline ? sparklines(doc) : [] };
|
|
740
740
|
}
|
|
741
741
|
};
|
|
742
742
|
const insertChart = {
|
|
@@ -763,7 +763,7 @@ function createDocumentChartTools(editor) {
|
|
|
763
763
|
const node = { type: "chart", attrs: { id, spec, width, ...height !== void 0 ? { height } : {} } };
|
|
764
764
|
const chain = ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true));
|
|
765
765
|
const ok = (at !== void 0 ? chain.insertContentAt(at, node) : chain.insertContent(node)).run();
|
|
766
|
-
const chart =
|
|
766
|
+
const chart = _chunkDGITFN73cjs.getDocumentCharts.call(void 0, ed.state.doc).find((c) => c.id === id);
|
|
767
767
|
if (!ok || !chart) throw new Error(`A chart cannot go at ${_nullishCoalesce(at, () => ( ed.state.selection.from))}; pass a position between blocks or inside a paragraph.`);
|
|
768
768
|
return { id: chart.id, pos: chart.pos, spec: chart.spec, width: chart.node.attrs.width, height: chart.node.attrs.height };
|
|
769
769
|
}
|
|
@@ -810,8 +810,8 @@ function createDocumentChartTools(editor) {
|
|
|
810
810
|
inputSchema: {
|
|
811
811
|
type: "object",
|
|
812
812
|
properties: {
|
|
813
|
-
values: { type: "array", items: _chunkG23BTQA5cjs.VALUE, minItems: 1, maxItems:
|
|
814
|
-
kind: { type: "string", enum: [...
|
|
813
|
+
values: { type: "array", items: _chunkG23BTQA5cjs.VALUE, minItems: 1, maxItems: _chunkDGITFN73cjs.MAX_SPARKLINE_VALUES, description: "Values in order (null for a gap)." },
|
|
814
|
+
kind: { type: "string", enum: [..._chunkDGITFN73cjs.SPARKLINE_KINDS], description: "line (default), column, or win-loss (sign only)." },
|
|
815
815
|
at: { type: "integer", minimum: 0, description: "Document position inside a paragraph (default: the selection)." },
|
|
816
816
|
width: { type: "number", minimum: 4, maximum: 1e3, description: "Width in pixels (default 80)." },
|
|
817
817
|
height: { type: "number", minimum: 4, maximum: 200, description: "Height in pixels (default 18)." },
|
|
@@ -830,7 +830,7 @@ function createDocumentChartTools(editor) {
|
|
|
830
830
|
if (bad >= 0) throw new Error(`values[${bad}] ("${String(values[bad])}") is not a number; pass numbers, numeric text or null. Nothing was inserted.`);
|
|
831
831
|
const pos = _nullishCoalesce(at, () => ( ed.state.selection.from));
|
|
832
832
|
if (!ed.state.doc.resolve(pos).parent.inlineContent) throw new Error(`Position ${pos} is between blocks; a sparkline goes inside a paragraph (use a position from get_text {blocks: true}).`);
|
|
833
|
-
const stored =
|
|
833
|
+
const stored = _chunkDGITFN73cjs.normalizeSparklineValues.call(void 0, parsed);
|
|
834
834
|
ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true)).insertContentAt(pos, { type: "sparkline", attrs: { values: stored, kind, width, height, color, label } }).run();
|
|
835
835
|
return { pos, kind, values: stored };
|
|
836
836
|
}
|
|
@@ -1168,8 +1168,8 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1168
1168
|
const config = option === false ? null : option === true || option === void 0 ? {} : option;
|
|
1169
1169
|
const caret = {
|
|
1170
1170
|
id: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _43 => _43.id]), () => ( providerId)),
|
|
1171
|
-
name: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _44 => _44.name]), () => (
|
|
1172
|
-
color: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _45 => _45.color]), () => (
|
|
1171
|
+
name: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _44 => _44.name]), () => ( _chunkDGITFN73cjs.DEFAULT_AGENT_CARET_NAME)),
|
|
1172
|
+
color: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _45 => _45.color]), () => ( _chunkDGITFN73cjs.DEFAULT_AGENT_CARET_COLOR))
|
|
1173
1173
|
};
|
|
1174
1174
|
const typing = !_optionalChain([config, 'optionalAccess', _46 => _46.typing]) ? null : config.typing === true ? {} : config.typing;
|
|
1175
1175
|
const idleMs = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _47 => _47.idleMs]), () => ( 12e3));
|
|
@@ -1182,19 +1182,19 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1182
1182
|
};
|
|
1183
1183
|
const touch = () => {
|
|
1184
1184
|
clearTimeout(idleTimer);
|
|
1185
|
-
if (idleMs > 0) idleTimer = setTimeout(() => live() &&
|
|
1185
|
+
if (idleMs > 0) idleTimer = setTimeout(() => live() && _chunkDGITFN73cjs.clearAgentCaret.call(void 0, live(), caret.id), idleMs);
|
|
1186
1186
|
};
|
|
1187
1187
|
const tint = (ed, ranges) => {
|
|
1188
1188
|
clearTimeout(tintTimer);
|
|
1189
|
-
|
|
1190
|
-
if (changedMs > 0 && ranges.length) tintTimer = setTimeout(() => live() &&
|
|
1189
|
+
_chunkDGITFN73cjs.markAgentChanges.call(void 0, ed, caret.id, ranges);
|
|
1190
|
+
if (changedMs > 0 && ranges.length) tintTimer = setTimeout(() => live() && _chunkDGITFN73cjs.markAgentChanges.call(void 0, live(), caret.id, []), changedMs);
|
|
1191
1191
|
};
|
|
1192
1192
|
return {
|
|
1193
1193
|
/** Puts the caret at `head`, selecting from `anchor`. */
|
|
1194
1194
|
show(anchor, head = anchor) {
|
|
1195
1195
|
const ed = live();
|
|
1196
1196
|
if (!ed) return;
|
|
1197
|
-
|
|
1197
|
+
_chunkDGITFN73cjs.setAgentCaret.call(void 0, ed, { ...caret, from: anchor, to: head });
|
|
1198
1198
|
touch();
|
|
1199
1199
|
},
|
|
1200
1200
|
/** Shows the caret after ranges just changed by a tool, tinting them. */
|
|
@@ -1202,7 +1202,7 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1202
1202
|
const ed = live();
|
|
1203
1203
|
if (!ed || !ranges.length) return;
|
|
1204
1204
|
const last = ranges[ranges.length - 1];
|
|
1205
|
-
|
|
1205
|
+
_chunkDGITFN73cjs.setAgentCaret.call(void 0, ed, { ...caret, from: last.to });
|
|
1206
1206
|
tint(ed, ranges);
|
|
1207
1207
|
touch();
|
|
1208
1208
|
},
|
|
@@ -1210,12 +1210,12 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1210
1210
|
async write(ed, from, to, text, signal) {
|
|
1211
1211
|
if (live() && typing) {
|
|
1212
1212
|
clearTimeout(tintTimer);
|
|
1213
|
-
const range2 = await
|
|
1214
|
-
if (changedMs > 0) tintTimer = setTimeout(() => live() &&
|
|
1213
|
+
const range2 = await _chunkDGITFN73cjs.typeAgentText.call(void 0, ed, { ...typing, from, to, text, caret, signal });
|
|
1214
|
+
if (changedMs > 0) tintTimer = setTimeout(() => live() && _chunkDGITFN73cjs.markAgentChanges.call(void 0, live(), caret.id, []), changedMs);
|
|
1215
1215
|
touch();
|
|
1216
1216
|
return range2;
|
|
1217
1217
|
}
|
|
1218
|
-
const tr = _history.closeHistory.call(void 0,
|
|
1218
|
+
const tr = _history.closeHistory.call(void 0, _chunkDGITFN73cjs.replaceWithTextTransaction.call(void 0, ed.state, from, to, text));
|
|
1219
1219
|
const end = tr.mapping.map(to, 1);
|
|
1220
1220
|
const range = { from: Math.min(tr.mapping.map(from, -1), end), to: end };
|
|
1221
1221
|
ed.view.dispatch(tr.scrollIntoView());
|
|
@@ -1244,7 +1244,7 @@ function findMatches(editor, query, args, replacement) {
|
|
|
1244
1244
|
wholeWord: !!args.wholeWord,
|
|
1245
1245
|
...args.regex ? { regex: true } : { literal: true }
|
|
1246
1246
|
};
|
|
1247
|
-
const result =
|
|
1247
|
+
const result = _chunkDGITFN73cjs.searchDocument.call(void 0, editor.state.doc, query, options, replacement !== void 0 ? { replacement } : {});
|
|
1248
1248
|
if (result.error) throw new Error(`Invalid search pattern: ${result.error.message}`);
|
|
1249
1249
|
return { matches: result.matches, truncated: result.truncated };
|
|
1250
1250
|
}
|
|
@@ -1406,7 +1406,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
1406
1406
|
replacement: String(replace).replace(/\r\n?|\n/g, "\r")
|
|
1407
1407
|
}));
|
|
1408
1408
|
const tr = _history.closeHistory.call(void 0, ed.state.tr);
|
|
1409
|
-
const ends =
|
|
1409
|
+
const ends = _chunkDGITFN73cjs.applyReplacements.call(void 0, tr, chosen);
|
|
1410
1410
|
ed.view.dispatch(tr.scrollIntoView());
|
|
1411
1411
|
const ranges = chosen.map((m, i) => ({ from: tr.mapping.map(m.from, -1), to: ends[i] }));
|
|
1412
1412
|
presence.changed(ranges.filter((r) => r.from < r.to));
|
|
@@ -1507,7 +1507,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
1507
1507
|
inputSchema: {
|
|
1508
1508
|
type: "object",
|
|
1509
1509
|
properties: {
|
|
1510
|
-
operation: { type: "string", enum:
|
|
1510
|
+
operation: { type: "string", enum: _chunkDGITFN73cjs.TABLE_ACTIONS.map((a) => a.action), description: "Table operation." },
|
|
1511
1511
|
at: { type: "integer", minimum: 0, description: "Document position to place the cursor first (e.g. inside a cell)." },
|
|
1512
1512
|
rows: { type: "integer", minimum: 1, maximum: 100, description: "insertTable: rows (default 3)." },
|
|
1513
1513
|
cols: { type: "integer", minimum: 1, maximum: 50, description: "insertTable: columns (default 3)." },
|
|
@@ -1537,10 +1537,10 @@ function createRichTextToolProvider(target, options) {
|
|
|
1537
1537
|
ed.view.dispatch(ed.state.tr.setSelection(_state.TextSelection.near(ed.state.doc.resolve(at))));
|
|
1538
1538
|
}
|
|
1539
1539
|
const action = operation;
|
|
1540
|
-
const state =
|
|
1540
|
+
const state = _chunkDGITFN73cjs.getTableActionState.call(void 0, ed, action, params);
|
|
1541
1541
|
if (state !== true) throw new Error(state);
|
|
1542
|
-
|
|
1543
|
-
const table =
|
|
1542
|
+
_chunkDGITFN73cjs.runTableAction.call(void 0, ed, action, params);
|
|
1543
|
+
const table = _chunkDGITFN73cjs.getTableState.call(void 0, ed);
|
|
1544
1544
|
return {
|
|
1545
1545
|
operation,
|
|
1546
1546
|
table: table.inTable ? { rows: table.rows, columns: table.columns, row: table.row, column: table.column } : null,
|
|
@@ -1559,7 +1559,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
1559
1559
|
if (!ed || ed.isDestroyed) return [];
|
|
1560
1560
|
if (!ed.isEditable) return [getText, findText, ...charts.read()];
|
|
1561
1561
|
const tools = [getText, findText, insertText, replaceText, replaceRange, replaceSelection, setSelection, ...formatting.tools(ed)];
|
|
1562
|
-
return [...tools, ...
|
|
1562
|
+
return [...tools, ..._chunkDGITFN73cjs.isTableEnabled.call(void 0, ed) ? [editTable] : [], ...charts.read(), ...charts.write().map(withCaret)];
|
|
1563
1563
|
},
|
|
1564
1564
|
subscribe: (notify) => {
|
|
1565
1565
|
const ed = editor();
|
|
@@ -2235,7 +2235,7 @@ function createReviewToolProvider(target, options) {
|
|
|
2235
2235
|
const editor = () => toEditor2(target);
|
|
2236
2236
|
const author = _nullishCoalesce(options.author, () => ( { id: "agent", name: "Agent" }));
|
|
2237
2237
|
const store = () => {
|
|
2238
|
-
const s =
|
|
2238
|
+
const s = _chunkDGITFN73cjs.getCommentStore.call(void 0, editor());
|
|
2239
2239
|
if (!s) throw new Error("This editor has no Comments extension.");
|
|
2240
2240
|
return s;
|
|
2241
2241
|
};
|
|
@@ -2430,7 +2430,7 @@ function createReviewToolProvider(target, options) {
|
|
|
2430
2430
|
tools: () => {
|
|
2431
2431
|
const ed = editor();
|
|
2432
2432
|
if (!ed || ed.isDestroyed) return [];
|
|
2433
|
-
const comments = !!
|
|
2433
|
+
const comments = !!_chunkDGITFN73cjs.getCommentStore.call(void 0, ed);
|
|
2434
2434
|
const changes = !!_chunk34RQAGWIcjs.getTrackChangesStore.call(void 0, ed);
|
|
2435
2435
|
const tools = [...comments ? [listComments] : [], ...changes ? [listChanges] : []];
|
|
2436
2436
|
if (!ed.isEditable) return tools;
|
package/dist/agent/index.js
CHANGED
|
@@ -140,10 +140,10 @@ import {
|
|
|
140
140
|
setAgentCaret,
|
|
141
141
|
sparklineLabel,
|
|
142
142
|
typeAgentText
|
|
143
|
-
} from "../chunk-
|
|
143
|
+
} from "../chunk-X4FTNFIA.js";
|
|
144
144
|
import {
|
|
145
145
|
describeChart
|
|
146
|
-
} from "../chunk-
|
|
146
|
+
} from "../chunk-NMZQMPFZ.js";
|
|
147
147
|
import "../chunk-KGRZMHZB.js";
|
|
148
148
|
import "../chunk-C2WEIEUB.js";
|
|
149
149
|
import "../chunk-O6OGNDND.js";
|
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
isUnsafeJsonKey,
|
|
192
192
|
stripPrototypeKeys
|
|
193
193
|
} from "../chunk-HF5QZS7Z.js";
|
|
194
|
-
import "../chunk-
|
|
194
|
+
import "../chunk-GAZPHCTV.js";
|
|
195
195
|
import "../chunk-2EUW2XZX.js";
|
|
196
196
|
import "../chunk-E2V5DA3W.js";
|
|
197
197
|
import "../chunk-VR6OGHU5.js";
|
|
@@ -94,7 +94,7 @@ var _chunkSJ2CPTQCcjs = require('../chunk-SJ2CPTQC.cjs');
|
|
|
94
94
|
require('../chunk-2BSBFBOA.cjs');
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
var
|
|
97
|
+
var _chunkWPLGZBNEcjs = require('../chunk-WPLGZBNE.cjs');
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
|
|
@@ -4674,7 +4674,7 @@ var AnimationEditorController = (_class2 = class {
|
|
|
4674
4674
|
|
|
4675
4675
|
__init16() {this.recording = null}
|
|
4676
4676
|
constructor(options = {}) {;_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);_class2.prototype.__init18.call(this);
|
|
4677
|
-
this.history = _nullishCoalesce(options.history, () => ( new (0,
|
|
4677
|
+
this.history = _nullishCoalesce(options.history, () => ( new (0, _chunkWPLGZBNEcjs.HistoryManager)()));
|
|
4678
4678
|
this.scene = options.scene ? parseMotionScene(options.scene) : createMotionScene(BLANK);
|
|
4679
4679
|
this.issues = checkMotionScene(this.scene);
|
|
4680
4680
|
this.readOnly = _nullishCoalesce(options.readOnly, () => ( false));
|
|
@@ -91,7 +91,9 @@ export interface CanvasGestureRecorderOptions<TNode extends CanvasNode = CanvasN
|
|
|
91
91
|
/**
|
|
92
92
|
* Makes a gesture the flow library applies directly (a node drag, a resize) one undo step:
|
|
93
93
|
* call `begin()` when it starts (e.g. `onNodeDragStart`) and `end("Move")` when it stops. If
|
|
94
|
-
* the nodes or edges changed in between, the change is recorded; otherwise nothing is.
|
|
94
|
+
* the nodes or edges changed in between, the change is recorded; otherwise nothing is. Undo and
|
|
95
|
+
* redo put back only the nodes and edges the gesture changed, so work added since by a
|
|
96
|
+
* collaborator or an agent is kept.
|
|
95
97
|
*/
|
|
96
98
|
export declare function createCanvasGestureRecorder<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: CanvasGestureRecorderOptions<TNode, TEdge>): {
|
|
97
99
|
/** Remembers the canvas as it is before the gesture. */
|
|
@@ -91,7 +91,9 @@ export interface CanvasGestureRecorderOptions<TNode extends CanvasNode = CanvasN
|
|
|
91
91
|
/**
|
|
92
92
|
* Makes a gesture the flow library applies directly (a node drag, a resize) one undo step:
|
|
93
93
|
* call `begin()` when it starts (e.g. `onNodeDragStart`) and `end("Move")` when it stops. If
|
|
94
|
-
* the nodes or edges changed in between, the change is recorded; otherwise nothing is.
|
|
94
|
+
* the nodes or edges changed in between, the change is recorded; otherwise nothing is. Undo and
|
|
95
|
+
* redo put back only the nodes and edges the gesture changed, so work added since by a
|
|
96
|
+
* collaborator or an agent is kept.
|
|
95
97
|
*/
|
|
96
98
|
export declare function createCanvasGestureRecorder<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdgeLike = CanvasEdge>(options: CanvasGestureRecorderOptions<TNode, TEdge>): {
|
|
97
99
|
/** Remembers the canvas as it is before the gesture. */
|
package/dist/canvas/index.cjs
CHANGED
|
@@ -11974,14 +11974,32 @@ function createCanvasEditorDocument(options) {
|
|
|
11974
11974
|
readOnly: options.readOnly
|
|
11975
11975
|
});
|
|
11976
11976
|
}
|
|
11977
|
+
function gestureChanges(before, after, runtimeKeys) {
|
|
11978
|
+
const key = (item) => JSON.stringify(omit(item, runtimeKeys));
|
|
11979
|
+
const changes = /* @__PURE__ */ new Map();
|
|
11980
|
+
before.forEach((item, i) => changes.set(item.id, { before: item, beforeIndex: i, afterIndex: -1 }));
|
|
11981
|
+
after.forEach((item, i) => {
|
|
11982
|
+
const change = changes.get(item.id);
|
|
11983
|
+
if (!change) changes.set(item.id, { after: item, beforeIndex: -1, afterIndex: i });
|
|
11984
|
+
else if (key(change.before) === key(item)) changes.delete(item.id);
|
|
11985
|
+
else Object.assign(change, { after: item, afterIndex: i });
|
|
11986
|
+
});
|
|
11987
|
+
return changes;
|
|
11988
|
+
}
|
|
11989
|
+
function applyGestureSide(current, changes, side) {
|
|
11990
|
+
const next = current.filter((item) => {
|
|
11991
|
+
const change = changes.get(item.id);
|
|
11992
|
+
return !change || change[side] !== void 0;
|
|
11993
|
+
}).map((item) => _nullishCoalesce(_optionalChain([changes, 'access', _517 => _517.get, 'call', _518 => _518(item.id), 'optionalAccess', _519 => _519[side]]), () => ( item)));
|
|
11994
|
+
const present = new Set(next.map((item) => item.id));
|
|
11995
|
+
const index = side === "before" ? "beforeIndex" : "afterIndex";
|
|
11996
|
+
const missing = [...changes.values()].filter((c) => c[side] !== void 0 && !present.has(c[side].id) && (side === "before" ? !c.after : !c.before)).sort((a, b) => a[index] - b[index]);
|
|
11997
|
+
for (const change of missing) next.splice(Math.min(change[index], next.length), 0, change[side]);
|
|
11998
|
+
return next;
|
|
11999
|
+
}
|
|
11977
12000
|
function createCanvasGestureRecorder(options) {
|
|
11978
12001
|
let before = null;
|
|
11979
|
-
const take = () => ({ nodes: options.getNodes(), edges: _optionalChain([options, 'access',
|
|
11980
|
-
const key = (s) => canvasDocumentContentKey(s.nodes, _nullishCoalesce(s.edges, () => ( [])));
|
|
11981
|
-
const restore = (s) => {
|
|
11982
|
-
options.setNodes(s.nodes);
|
|
11983
|
-
if (s.edges && options.setEdges) options.setEdges(s.edges);
|
|
11984
|
-
};
|
|
12002
|
+
const take = () => ({ nodes: options.getNodes(), edges: _optionalChain([options, 'access', _520 => _520.getEdges, 'optionalCall', _521 => _521()]) });
|
|
11985
12003
|
return {
|
|
11986
12004
|
/** Remembers the canvas as it is before the gesture. */
|
|
11987
12005
|
begin() {
|
|
@@ -11993,8 +12011,16 @@ function createCanvasGestureRecorder(options) {
|
|
|
11993
12011
|
before = null;
|
|
11994
12012
|
if (!start) return false;
|
|
11995
12013
|
const after = take();
|
|
11996
|
-
|
|
11997
|
-
|
|
12014
|
+
const nodes = gestureChanges(start.nodes, after.nodes, RUNTIME_NODE_KEYS);
|
|
12015
|
+
const edges = start.edges && after.edges && options.setEdges ? gestureChanges(start.edges, after.edges, RUNTIME_EDGE_KEYS) : /* @__PURE__ */ new Map();
|
|
12016
|
+
if (nodes.size === 0 && edges.size === 0) return false;
|
|
12017
|
+
const apply = (side) => {
|
|
12018
|
+
if (nodes.size) options.setNodes(applyGestureSide(options.getNodes(), nodes, side));
|
|
12019
|
+
if (edges.size && options.getEdges && options.setEdges) {
|
|
12020
|
+
options.setEdges(applyGestureSide(options.getEdges(), edges, side));
|
|
12021
|
+
}
|
|
12022
|
+
};
|
|
12023
|
+
options.history.execute({ name, execute: () => apply("after"), undo: () => apply("before") });
|
|
11998
12024
|
return true;
|
|
11999
12025
|
},
|
|
12000
12026
|
/** Forgets a gesture without recording it. */
|
|
@@ -12109,8 +12135,8 @@ function createCanvasExplosionStateController(options = {}) {
|
|
|
12109
12135
|
clearTimer();
|
|
12110
12136
|
const previous = snapshot.activeId;
|
|
12111
12137
|
set({ activeId: nodeId, collapsingId: null });
|
|
12112
|
-
if (previous !== null) _optionalChain([options, 'access',
|
|
12113
|
-
_optionalChain([options, 'access',
|
|
12138
|
+
if (previous !== null) _optionalChain([options, 'access', _522 => _522.onCollapse, 'optionalCall', _523 => _523(previous)]);
|
|
12139
|
+
_optionalChain([options, 'access', _524 => _524.onExplode, 'optionalCall', _525 => _525(nodeId)]);
|
|
12114
12140
|
return true;
|
|
12115
12141
|
};
|
|
12116
12142
|
const collapse = (nodeId) => {
|
|
@@ -12119,7 +12145,7 @@ function createCanvasExplosionStateController(options = {}) {
|
|
|
12119
12145
|
if (active === null || nodeId !== void 0 && nodeId !== active) return false;
|
|
12120
12146
|
clearTimer();
|
|
12121
12147
|
set({ activeId: null, collapsingId: active });
|
|
12122
|
-
_optionalChain([options, 'access',
|
|
12148
|
+
_optionalChain([options, 'access', _526 => _526.onCollapse, 'optionalCall', _527 => _527(active)]);
|
|
12123
12149
|
if (duration === 0) finishCollapse();
|
|
12124
12150
|
else timer = setTimeout(() => {
|
|
12125
12151
|
timer = null;
|
|
@@ -12180,7 +12206,7 @@ function canvasExplosionToolTarget(state, options) {
|
|
|
12180
12206
|
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
12181
12207
|
var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
12182
12208
|
var labelOf = (node) => {
|
|
12183
|
-
const label = _nullishCoalesce(_optionalChain([node, 'access',
|
|
12209
|
+
const label = _nullishCoalesce(_optionalChain([node, 'access', _528 => _528.data, 'optionalAccess', _529 => _529.label]), () => ( _optionalChain([node, 'access', _530 => _530.data, 'optionalAccess', _531 => _531.name])));
|
|
12184
12210
|
return typeof label === "string" && label !== "" ? label : void 0;
|
|
12185
12211
|
};
|
|
12186
12212
|
function createCanvasExplosionToolProvider(target, options = {}) {
|
|
@@ -12193,7 +12219,7 @@ function createCanvasExplosionToolProvider(target, options = {}) {
|
|
|
12193
12219
|
if (ok === true) return null;
|
|
12194
12220
|
return typeof ok === "string" && ok ? ok : `Node "${node.id}" has nothing to explode into.`;
|
|
12195
12221
|
};
|
|
12196
|
-
const state = () => ({ exploded: [...target.exploded()], collapsing: [..._nullishCoalesce(_optionalChain([target, 'access',
|
|
12222
|
+
const state = () => ({ exploded: [...target.exploded()], collapsing: [..._nullishCoalesce(_optionalChain([target, 'access', _532 => _532.collapsing, 'optionalCall', _533 => _533()]), () => ( []))] });
|
|
12197
12223
|
const findNode = (id) => {
|
|
12198
12224
|
const node = target.getNodes().find((n3) => n3.id === id);
|
|
12199
12225
|
if (!node) throw new Error(`No node "${id}" on the canvas. Call list_explodable_nodes for node ids.`);
|
|
@@ -12312,8 +12338,8 @@ function createCanvasProposals(options) {
|
|
|
12312
12338
|
const rectOf = (node) => ({
|
|
12313
12339
|
x: node.position.x,
|
|
12314
12340
|
y: node.position.y,
|
|
12315
|
-
width: _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access',
|
|
12316
|
-
height: _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access',
|
|
12341
|
+
width: _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _534 => _534.measured, 'optionalAccess', _535 => _535.width]), () => ( node.width)), () => ( size2.width)),
|
|
12342
|
+
height: _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _536 => _536.measured, 'optionalAccess', _537 => _537.height]), () => ( node.height)), () => ( size2.height))
|
|
12317
12343
|
});
|
|
12318
12344
|
const missing = (proposal) => {
|
|
12319
12345
|
const present = new Set(options.getNodes().map((n3) => n3.id));
|
|
@@ -12363,7 +12389,7 @@ function createCanvasProposals(options) {
|
|
|
12363
12389
|
throw new Error(`nodes[${i}].position needs finite x and y.`);
|
|
12364
12390
|
}
|
|
12365
12391
|
if (!position) {
|
|
12366
|
-
const view = _optionalChain([options, 'access',
|
|
12392
|
+
const view = _optionalChain([options, 'access', _538 => _538.visibleRect, 'optionalCall', _539 => _539()]);
|
|
12367
12393
|
if (input2.nearNodeId) position = _chunkEL4PSKFTcjs.placeBeside.call(void 0, rects, nodeSize, toSide(input2.side), input2.nearNodeId);
|
|
12368
12394
|
else if (view) position = _chunkEL4PSKFTcjs.placeInView.call(void 0, rects, nodeSize, view);
|
|
12369
12395
|
else if (canvasNodes.length || nodes.length) {
|
|
@@ -12415,7 +12441,7 @@ function createCanvasProposals(options) {
|
|
|
12415
12441
|
};
|
|
12416
12442
|
const accept = (id) => {
|
|
12417
12443
|
const proposal = find(id);
|
|
12418
|
-
const reason = _optionalChain([options, 'access',
|
|
12444
|
+
const reason = _optionalChain([options, 'access', _540 => _540.readOnly, 'optionalCall', _541 => _541()]);
|
|
12419
12445
|
if (reason) throw new Error(reason);
|
|
12420
12446
|
const gone = missing(proposal);
|
|
12421
12447
|
if (gone.length) {
|
|
@@ -12567,7 +12593,7 @@ function createCanvasChangeFeed(options) {
|
|
|
12567
12593
|
if (edited) pending = void 0;
|
|
12568
12594
|
const change = {
|
|
12569
12595
|
seq: ++seq,
|
|
12570
|
-
origin: _optionalChain([commit, 'optionalAccess',
|
|
12596
|
+
origin: _optionalChain([commit, 'optionalAccess', _542 => _542.kind]) === "execute" || _optionalChain([commit, 'optionalAccess', _543 => _543.kind]) === "merge" ? commit.origin : "user",
|
|
12571
12597
|
...commit ? { commit } : {},
|
|
12572
12598
|
addedNodes,
|
|
12573
12599
|
removedNodes,
|
|
@@ -12586,8 +12612,8 @@ function createCanvasChangeFeed(options) {
|
|
|
12586
12612
|
const noteCommit = (event) => {
|
|
12587
12613
|
pending = event;
|
|
12588
12614
|
};
|
|
12589
|
-
const offHistory = _optionalChain([options, 'access',
|
|
12590
|
-
const offCanvas = _optionalChain([options, 'access',
|
|
12615
|
+
const offHistory = _optionalChain([options, 'access', _544 => _544.history, 'optionalAccess', _545 => _545.onCommit, 'call', _546 => _546(noteCommit)]);
|
|
12616
|
+
const offCanvas = _optionalChain([options, 'access', _547 => _547.subscribe, 'optionalCall', _548 => _548(() => {
|
|
12591
12617
|
check();
|
|
12592
12618
|
})]);
|
|
12593
12619
|
return {
|
|
@@ -12606,8 +12632,8 @@ function createCanvasChangeFeed(options) {
|
|
|
12606
12632
|
},
|
|
12607
12633
|
noteCommit,
|
|
12608
12634
|
dispose: () => {
|
|
12609
|
-
_optionalChain([offHistory, 'optionalCall',
|
|
12610
|
-
_optionalChain([offCanvas, 'optionalCall',
|
|
12635
|
+
_optionalChain([offHistory, 'optionalCall', _549 => _549()]);
|
|
12636
|
+
_optionalChain([offCanvas, 'optionalCall', _550 => _550()]);
|
|
12611
12637
|
listeners.clear();
|
|
12612
12638
|
}
|
|
12613
12639
|
};
|
|
@@ -12617,7 +12643,7 @@ function createCanvasChangeFeed(options) {
|
|
|
12617
12643
|
var READ2 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
12618
12644
|
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
12619
12645
|
var labelOf2 = (node) => {
|
|
12620
|
-
const label = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access',
|
|
12646
|
+
const label = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _551 => _551.data, 'optionalAccess', _552 => _552.label]), () => ( _optionalChain([node, 'access', _553 => _553.data, 'optionalAccess', _554 => _554.name]))), () => ( _optionalChain([node, 'access', _555 => _555.data, 'optionalAccess', _556 => _556.title])));
|
|
12621
12647
|
return typeof label === "string" && label !== "" ? label : void 0;
|
|
12622
12648
|
};
|
|
12623
12649
|
var proposalIdArg = {
|
|
@@ -12698,7 +12724,7 @@ function createCanvasProposalToolProvider(proposals, options = {}) {
|
|
|
12698
12724
|
},
|
|
12699
12725
|
annotations: { title: "Propose nodes", ...WRITE },
|
|
12700
12726
|
handler: (args, context) => {
|
|
12701
|
-
const origin = _optionalChain([context, 'access',
|
|
12727
|
+
const origin = _optionalChain([context, 'access', _557 => _557.actor, 'optionalAccess', _558 => _558.id]) ? `agent:${context.actor.id}` : options.fallbackOrigin;
|
|
12702
12728
|
const proposal = proposals.propose({ title: args.title, rationale: args.rationale, nodes: args.nodes, edges: args.edges, ...origin ? { origin } : {} });
|
|
12703
12729
|
const { id: _id, missing: _missing, createdAt: _createdAt, ...rest } = describe(proposal);
|
|
12704
12730
|
return { proposalId: proposal.id, ...rest };
|
|
@@ -12750,7 +12776,7 @@ function stickerCanvasNode(placement, id) {
|
|
|
12750
12776
|
const { description, asset } = placement;
|
|
12751
12777
|
const silhouette = _nullishCoalesce((asset.kind === "svg" ? asset.silhouette : void 0), () => ( description.silhouette));
|
|
12752
12778
|
if (!silhouette) throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_format", `"${placement.ref}" has no outline (silhouette); the canvas places stickers by their outline. Pick one whose describe_sticker lists a silhouette.`);
|
|
12753
|
-
const fill = _nullishCoalesce(_nullishCoalesce(placement.colour, () => ( _optionalChain([description, 'access',
|
|
12779
|
+
const fill = _nullishCoalesce(_nullishCoalesce(placement.colour, () => ( _optionalChain([description, 'access', _559 => _559.colours, 'optionalAccess', _560 => _560[0]]))), () => ( "#1f2937"));
|
|
12754
12780
|
const shape = { kind: "path", d: silhouette, viewBox: [0, 0, description.width, description.height], fillRule: "evenodd", fill };
|
|
12755
12781
|
const sticker = { ref: placement.ref, licence: description.licence, ...placement.variant === "dark" ? { variant: "dark" } : {} };
|
|
12756
12782
|
return {
|
package/dist/canvas/index.js
CHANGED
|
@@ -11974,14 +11974,32 @@ function createCanvasEditorDocument(options) {
|
|
|
11974
11974
|
readOnly: options.readOnly
|
|
11975
11975
|
});
|
|
11976
11976
|
}
|
|
11977
|
+
function gestureChanges(before, after, runtimeKeys) {
|
|
11978
|
+
const key = (item) => JSON.stringify(omit(item, runtimeKeys));
|
|
11979
|
+
const changes = /* @__PURE__ */ new Map();
|
|
11980
|
+
before.forEach((item, i) => changes.set(item.id, { before: item, beforeIndex: i, afterIndex: -1 }));
|
|
11981
|
+
after.forEach((item, i) => {
|
|
11982
|
+
const change = changes.get(item.id);
|
|
11983
|
+
if (!change) changes.set(item.id, { after: item, beforeIndex: -1, afterIndex: i });
|
|
11984
|
+
else if (key(change.before) === key(item)) changes.delete(item.id);
|
|
11985
|
+
else Object.assign(change, { after: item, afterIndex: i });
|
|
11986
|
+
});
|
|
11987
|
+
return changes;
|
|
11988
|
+
}
|
|
11989
|
+
function applyGestureSide(current, changes, side) {
|
|
11990
|
+
const next = current.filter((item) => {
|
|
11991
|
+
const change = changes.get(item.id);
|
|
11992
|
+
return !change || change[side] !== void 0;
|
|
11993
|
+
}).map((item) => changes.get(item.id)?.[side] ?? item);
|
|
11994
|
+
const present = new Set(next.map((item) => item.id));
|
|
11995
|
+
const index = side === "before" ? "beforeIndex" : "afterIndex";
|
|
11996
|
+
const missing = [...changes.values()].filter((c) => c[side] !== void 0 && !present.has(c[side].id) && (side === "before" ? !c.after : !c.before)).sort((a, b) => a[index] - b[index]);
|
|
11997
|
+
for (const change of missing) next.splice(Math.min(change[index], next.length), 0, change[side]);
|
|
11998
|
+
return next;
|
|
11999
|
+
}
|
|
11977
12000
|
function createCanvasGestureRecorder(options) {
|
|
11978
12001
|
let before = null;
|
|
11979
12002
|
const take = () => ({ nodes: options.getNodes(), edges: options.getEdges?.() });
|
|
11980
|
-
const key = (s) => canvasDocumentContentKey(s.nodes, s.edges ?? []);
|
|
11981
|
-
const restore = (s) => {
|
|
11982
|
-
options.setNodes(s.nodes);
|
|
11983
|
-
if (s.edges && options.setEdges) options.setEdges(s.edges);
|
|
11984
|
-
};
|
|
11985
12003
|
return {
|
|
11986
12004
|
/** Remembers the canvas as it is before the gesture. */
|
|
11987
12005
|
begin() {
|
|
@@ -11993,8 +12011,16 @@ function createCanvasGestureRecorder(options) {
|
|
|
11993
12011
|
before = null;
|
|
11994
12012
|
if (!start) return false;
|
|
11995
12013
|
const after = take();
|
|
11996
|
-
|
|
11997
|
-
|
|
12014
|
+
const nodes = gestureChanges(start.nodes, after.nodes, RUNTIME_NODE_KEYS);
|
|
12015
|
+
const edges = start.edges && after.edges && options.setEdges ? gestureChanges(start.edges, after.edges, RUNTIME_EDGE_KEYS) : /* @__PURE__ */ new Map();
|
|
12016
|
+
if (nodes.size === 0 && edges.size === 0) return false;
|
|
12017
|
+
const apply = (side) => {
|
|
12018
|
+
if (nodes.size) options.setNodes(applyGestureSide(options.getNodes(), nodes, side));
|
|
12019
|
+
if (edges.size && options.getEdges && options.setEdges) {
|
|
12020
|
+
options.setEdges(applyGestureSide(options.getEdges(), edges, side));
|
|
12021
|
+
}
|
|
12022
|
+
};
|
|
12023
|
+
options.history.execute({ name, execute: () => apply("after"), undo: () => apply("before") });
|
|
11998
12024
|
return true;
|
|
11999
12025
|
},
|
|
12000
12026
|
/** Forgets a gesture without recording it. */
|