@pixerate/editor 0.171.0 → 0.172.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 +4 -0
- package/dist/agent/index.cjs +28 -28
- package/dist/agent/index.js +3 -3
- package/dist/canvas/index.cjs +3 -3
- package/dist/canvas/index.js +1 -1
- package/dist/chart/index.cjs +156 -68
- package/dist/chart/index.d.cts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.js +91 -3
- package/dist/chart/layout-shared.d.cts +2 -1
- package/dist/chart/layout-shared.d.ts +2 -1
- package/dist/chart/layout.d.cts +5 -0
- package/dist/chart/layout.d.ts +5 -0
- package/dist/chart/tooltip.d.cts +53 -0
- package/dist/chart/tooltip.d.ts +53 -0
- package/dist/chart/types.d.cts +14 -0
- package/dist/chart/types.d.ts +14 -0
- package/dist/{chunk-SBAPXFPB.cjs → chunk-FHNGNL3V.cjs} +44 -44
- package/dist/{chunk-2F4GAZL5.cjs → chunk-GXEC4FS6.cjs} +16 -16
- package/dist/{chunk-T62BRXMS.js → chunk-IMHRN4ZZ.js} +1 -1
- package/dist/{chunk-N3ACT6VJ.js → chunk-KPWG3PSW.js} +1 -1
- package/dist/{chunk-M52UCHVZ.js → chunk-OJQVKJYD.js} +12 -1
- package/dist/{chunk-ZUPP4NKM.js → chunk-R2VHVQVY.js} +2 -2
- package/dist/{chunk-GD34ICEX.cjs → chunk-RLOIEDA3.cjs} +10 -10
- package/dist/{chunk-WOIXNDHV.cjs → chunk-TUXKLM5W.cjs} +13 -2
- package/dist/extensions/index.cjs +5 -5
- package/dist/extensions/index.js +4 -4
- package/dist/index.cjs +10 -10
- package/dist/index.js +4 -4
- package/package.json +112 -12
- package/skills/pixerate-chart/SKILL.md +1 -0
package/README.md
CHANGED
|
@@ -6,10 +6,14 @@ Framework bindings: [`@pixerate/editor-react`](https://www.npmjs.com/package/@pi
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @pixerate/editor
|
|
9
|
+
# only if you use rich text or prompts (the root entry, /extensions, /serializers, /agent, /compare):
|
|
10
|
+
npm install @tiptap/core @tiptap/pm @tiptap/starter-kit @tiptap/suggestion @tiptap/extension-character-count @tiptap/extension-color @tiptap/extension-highlight @tiptap/extension-image @tiptap/extension-link @tiptap/extension-mention @tiptap/extension-placeholder @tiptap/extension-subscript @tiptap/extension-superscript @tiptap/extension-table @tiptap/extension-table-cell @tiptap/extension-table-header @tiptap/extension-table-row @tiptap/extension-task-item @tiptap/extension-task-list @tiptap/extension-text-align @tiptap/extension-text-style @tiptap/extension-typography @tiptap/extension-underline markdown-it markdown-it-task-lists prosemirror-markdown
|
|
9
11
|
# only if you use @pixerate/editor/canvas (or the agent canvas planner):
|
|
10
12
|
npm install @dagrejs/dagre
|
|
11
13
|
```
|
|
12
14
|
|
|
15
|
+
TipTap, ProseMirror and markdown-it are optional peer dependencies, so `@pixerate/editor/chart`, `/spreadsheet`, `/canvas` and the other subpaths install without them.
|
|
16
|
+
|
|
13
17
|
## Prompt grammar
|
|
14
18
|
|
|
15
19
|
Prompts use three token types:
|
package/dist/agent/index.cjs
CHANGED
|
@@ -121,12 +121,12 @@ var _chunkN2FGYZ4Qcjs = require('../chunk-N2FGYZ4Q.cjs');
|
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
var
|
|
124
|
+
var _chunkRLOIEDA3cjs = require('../chunk-RLOIEDA3.cjs');
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
var
|
|
127
|
+
var _chunkGXEC4FS6cjs = require('../chunk-GXEC4FS6.cjs');
|
|
128
128
|
require('../chunk-TTCJPX4U.cjs');
|
|
129
|
-
require('../chunk-
|
|
129
|
+
require('../chunk-TUXKLM5W.cjs');
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
|
|
@@ -666,14 +666,14 @@ function describe(chart, includeSpec) {
|
|
|
666
666
|
series: spec.series.map((s) => ({ id: s.id, name: s.name })),
|
|
667
667
|
width: _nullishCoalesce(node.attrs.width, () => ( null)),
|
|
668
668
|
height: node.attrs.height,
|
|
669
|
-
description:
|
|
669
|
+
description: _chunkGXEC4FS6cjs.describeChart.call(void 0, spec),
|
|
670
670
|
...includeSpec ? { spec } : {}
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
673
|
function sparklines(doc) {
|
|
674
674
|
const found = [];
|
|
675
675
|
doc.descendants((node, pos) => {
|
|
676
|
-
if (node.type.name === "sparkline") found.push({ pos, kind: node.attrs.kind, values: node.attrs.values, label:
|
|
676
|
+
if (node.type.name === "sparkline") found.push({ pos, kind: node.attrs.kind, values: node.attrs.values, label: _chunkRLOIEDA3cjs.sparklineLabel.call(void 0, node) });
|
|
677
677
|
});
|
|
678
678
|
return found;
|
|
679
679
|
}
|
|
@@ -684,7 +684,7 @@ function checkPosition(editor, at) {
|
|
|
684
684
|
function createDocumentChartTools(editor) {
|
|
685
685
|
const chartType = () => editor().schema.nodes.chart;
|
|
686
686
|
const findChart = (args) => {
|
|
687
|
-
const charts =
|
|
687
|
+
const charts = _chunkRLOIEDA3cjs.getDocumentCharts.call(void 0, editor().state.doc);
|
|
688
688
|
const list = charts.map((c) => `"${c.id}" at ${c.pos}`).join(", ") || "none; add one with insert_chart";
|
|
689
689
|
if (args.chartId !== void 0) {
|
|
690
690
|
const chart = charts.find((c) => c.id === args.chartId);
|
|
@@ -711,7 +711,7 @@ function createDocumentChartTools(editor) {
|
|
|
711
711
|
annotations: { title: "List charts in the document", ...READ },
|
|
712
712
|
handler: ({ includeSpec = false }) => {
|
|
713
713
|
const doc = editor().state.doc;
|
|
714
|
-
return { charts:
|
|
714
|
+
return { charts: _chunkRLOIEDA3cjs.getDocumentCharts.call(void 0, doc).map((c) => describe(c, includeSpec)), sparklines: editor().schema.nodes.sparkline ? sparklines(doc) : [] };
|
|
715
715
|
}
|
|
716
716
|
};
|
|
717
717
|
const insertChart = {
|
|
@@ -738,7 +738,7 @@ function createDocumentChartTools(editor) {
|
|
|
738
738
|
const node = { type: "chart", attrs: { id, spec, width, ...height !== void 0 ? { height } : {} } };
|
|
739
739
|
const chain = ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true));
|
|
740
740
|
const ok = (at !== void 0 ? chain.insertContentAt(at, node) : chain.insertContent(node)).run();
|
|
741
|
-
const chart =
|
|
741
|
+
const chart = _chunkRLOIEDA3cjs.getDocumentCharts.call(void 0, ed.state.doc).find((c) => c.id === id);
|
|
742
742
|
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.`);
|
|
743
743
|
return { id: chart.id, pos: chart.pos, spec: chart.spec, width: chart.node.attrs.width, height: chart.node.attrs.height };
|
|
744
744
|
}
|
|
@@ -785,8 +785,8 @@ function createDocumentChartTools(editor) {
|
|
|
785
785
|
inputSchema: {
|
|
786
786
|
type: "object",
|
|
787
787
|
properties: {
|
|
788
|
-
values: { type: "array", items: _chunkGTF4RYXJcjs.VALUE, minItems: 1, maxItems:
|
|
789
|
-
kind: { type: "string", enum: [...
|
|
788
|
+
values: { type: "array", items: _chunkGTF4RYXJcjs.VALUE, minItems: 1, maxItems: _chunkRLOIEDA3cjs.MAX_SPARKLINE_VALUES, description: "Values in order (null for a gap)." },
|
|
789
|
+
kind: { type: "string", enum: [..._chunkRLOIEDA3cjs.SPARKLINE_KINDS], description: "line (default), column, or win-loss (sign only)." },
|
|
790
790
|
at: { type: "integer", minimum: 0, description: "Document position inside a paragraph (default: the selection)." },
|
|
791
791
|
width: { type: "number", minimum: 4, maximum: 1e3, description: "Width in pixels (default 80)." },
|
|
792
792
|
height: { type: "number", minimum: 4, maximum: 200, description: "Height in pixels (default 18)." },
|
|
@@ -805,7 +805,7 @@ function createDocumentChartTools(editor) {
|
|
|
805
805
|
if (bad >= 0) throw new Error(`values[${bad}] ("${String(values[bad])}") is not a number; pass numbers, numeric text or null. Nothing was inserted.`);
|
|
806
806
|
const pos = _nullishCoalesce(at, () => ( ed.state.selection.from));
|
|
807
807
|
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}).`);
|
|
808
|
-
const stored =
|
|
808
|
+
const stored = _chunkRLOIEDA3cjs.normalizeSparklineValues.call(void 0, parsed);
|
|
809
809
|
ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true)).insertContentAt(pos, { type: "sparkline", attrs: { values: stored, kind, width, height, color, label } }).run();
|
|
810
810
|
return { pos, kind, values: stored };
|
|
811
811
|
}
|
|
@@ -1143,8 +1143,8 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1143
1143
|
const config = option === false ? null : option === true || option === void 0 ? {} : option;
|
|
1144
1144
|
const caret = {
|
|
1145
1145
|
id: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _43 => _43.id]), () => ( providerId)),
|
|
1146
|
-
name: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _44 => _44.name]), () => (
|
|
1147
|
-
color: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _45 => _45.color]), () => (
|
|
1146
|
+
name: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _44 => _44.name]), () => ( _chunkRLOIEDA3cjs.DEFAULT_AGENT_CARET_NAME)),
|
|
1147
|
+
color: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _45 => _45.color]), () => ( _chunkRLOIEDA3cjs.DEFAULT_AGENT_CARET_COLOR))
|
|
1148
1148
|
};
|
|
1149
1149
|
const typing = !_optionalChain([config, 'optionalAccess', _46 => _46.typing]) ? null : config.typing === true ? {} : config.typing;
|
|
1150
1150
|
const idleMs = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _47 => _47.idleMs]), () => ( 12e3));
|
|
@@ -1157,19 +1157,19 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1157
1157
|
};
|
|
1158
1158
|
const touch = () => {
|
|
1159
1159
|
clearTimeout(idleTimer);
|
|
1160
|
-
if (idleMs > 0) idleTimer = setTimeout(() => live() &&
|
|
1160
|
+
if (idleMs > 0) idleTimer = setTimeout(() => live() && _chunkRLOIEDA3cjs.clearAgentCaret.call(void 0, live(), caret.id), idleMs);
|
|
1161
1161
|
};
|
|
1162
1162
|
const tint = (ed, ranges) => {
|
|
1163
1163
|
clearTimeout(tintTimer);
|
|
1164
|
-
|
|
1165
|
-
if (changedMs > 0 && ranges.length) tintTimer = setTimeout(() => live() &&
|
|
1164
|
+
_chunkRLOIEDA3cjs.markAgentChanges.call(void 0, ed, caret.id, ranges);
|
|
1165
|
+
if (changedMs > 0 && ranges.length) tintTimer = setTimeout(() => live() && _chunkRLOIEDA3cjs.markAgentChanges.call(void 0, live(), caret.id, []), changedMs);
|
|
1166
1166
|
};
|
|
1167
1167
|
return {
|
|
1168
1168
|
/** Puts the caret at `head`, selecting from `anchor`. */
|
|
1169
1169
|
show(anchor, head = anchor) {
|
|
1170
1170
|
const ed = live();
|
|
1171
1171
|
if (!ed) return;
|
|
1172
|
-
|
|
1172
|
+
_chunkRLOIEDA3cjs.setAgentCaret.call(void 0, ed, { ...caret, from: anchor, to: head });
|
|
1173
1173
|
touch();
|
|
1174
1174
|
},
|
|
1175
1175
|
/** Shows the caret after ranges just changed by a tool, tinting them. */
|
|
@@ -1177,7 +1177,7 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1177
1177
|
const ed = live();
|
|
1178
1178
|
if (!ed || !ranges.length) return;
|
|
1179
1179
|
const last = ranges[ranges.length - 1];
|
|
1180
|
-
|
|
1180
|
+
_chunkRLOIEDA3cjs.setAgentCaret.call(void 0, ed, { ...caret, from: last.to });
|
|
1181
1181
|
tint(ed, ranges);
|
|
1182
1182
|
touch();
|
|
1183
1183
|
},
|
|
@@ -1185,12 +1185,12 @@ function createTextPresence(editor, providerId, option) {
|
|
|
1185
1185
|
async write(ed, from, to, text, signal) {
|
|
1186
1186
|
if (live() && typing) {
|
|
1187
1187
|
clearTimeout(tintTimer);
|
|
1188
|
-
const range2 = await
|
|
1189
|
-
if (changedMs > 0) tintTimer = setTimeout(() => live() &&
|
|
1188
|
+
const range2 = await _chunkRLOIEDA3cjs.typeAgentText.call(void 0, ed, { ...typing, from, to, text, caret, signal });
|
|
1189
|
+
if (changedMs > 0) tintTimer = setTimeout(() => live() && _chunkRLOIEDA3cjs.markAgentChanges.call(void 0, live(), caret.id, []), changedMs);
|
|
1190
1190
|
touch();
|
|
1191
1191
|
return range2;
|
|
1192
1192
|
}
|
|
1193
|
-
const tr = _history.closeHistory.call(void 0,
|
|
1193
|
+
const tr = _history.closeHistory.call(void 0, _chunkRLOIEDA3cjs.replaceWithTextTransaction.call(void 0, ed.state, from, to, text));
|
|
1194
1194
|
const end = tr.mapping.map(to, 1);
|
|
1195
1195
|
const range = { from: Math.min(tr.mapping.map(from, -1), end), to: end };
|
|
1196
1196
|
ed.view.dispatch(tr.scrollIntoView());
|
|
@@ -1219,7 +1219,7 @@ function findMatches(editor, query, args, replacement) {
|
|
|
1219
1219
|
wholeWord: !!args.wholeWord,
|
|
1220
1220
|
...args.regex ? { regex: true } : { literal: true }
|
|
1221
1221
|
};
|
|
1222
|
-
const result =
|
|
1222
|
+
const result = _chunkRLOIEDA3cjs.searchDocument.call(void 0, editor.state.doc, query, options, replacement !== void 0 ? { replacement } : {});
|
|
1223
1223
|
if (result.error) throw new Error(`Invalid search pattern: ${result.error.message}`);
|
|
1224
1224
|
return { matches: result.matches, truncated: result.truncated };
|
|
1225
1225
|
}
|
|
@@ -1381,7 +1381,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
1381
1381
|
replacement: String(replace).replace(/\r\n?|\n/g, "\r")
|
|
1382
1382
|
}));
|
|
1383
1383
|
const tr = _history.closeHistory.call(void 0, ed.state.tr);
|
|
1384
|
-
const ends =
|
|
1384
|
+
const ends = _chunkRLOIEDA3cjs.applyReplacements.call(void 0, tr, chosen);
|
|
1385
1385
|
ed.view.dispatch(tr.scrollIntoView());
|
|
1386
1386
|
const ranges = chosen.map((m, i) => ({ from: tr.mapping.map(m.from, -1), to: ends[i] }));
|
|
1387
1387
|
presence.changed(ranges.filter((r) => r.from < r.to));
|
|
@@ -1482,7 +1482,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
1482
1482
|
inputSchema: {
|
|
1483
1483
|
type: "object",
|
|
1484
1484
|
properties: {
|
|
1485
|
-
operation: { type: "string", enum:
|
|
1485
|
+
operation: { type: "string", enum: _chunkRLOIEDA3cjs.TABLE_ACTIONS.map((a) => a.action), description: "Table operation." },
|
|
1486
1486
|
at: { type: "integer", minimum: 0, description: "Document position to place the cursor first (e.g. inside a cell)." },
|
|
1487
1487
|
rows: { type: "integer", minimum: 1, maximum: 100, description: "insertTable: rows (default 3)." },
|
|
1488
1488
|
cols: { type: "integer", minimum: 1, maximum: 50, description: "insertTable: columns (default 3)." },
|
|
@@ -1512,10 +1512,10 @@ function createRichTextToolProvider(target, options) {
|
|
|
1512
1512
|
ed.view.dispatch(ed.state.tr.setSelection(_state.TextSelection.near(ed.state.doc.resolve(at))));
|
|
1513
1513
|
}
|
|
1514
1514
|
const action = operation;
|
|
1515
|
-
const state =
|
|
1515
|
+
const state = _chunkRLOIEDA3cjs.getTableActionState.call(void 0, ed, action, params);
|
|
1516
1516
|
if (state !== true) throw new Error(state);
|
|
1517
|
-
|
|
1518
|
-
const table =
|
|
1517
|
+
_chunkRLOIEDA3cjs.runTableAction.call(void 0, ed, action, params);
|
|
1518
|
+
const table = _chunkRLOIEDA3cjs.getTableState.call(void 0, ed);
|
|
1519
1519
|
return {
|
|
1520
1520
|
operation,
|
|
1521
1521
|
table: table.inTable ? { rows: table.rows, columns: table.columns, row: table.row, column: table.column } : null,
|
|
@@ -1534,7 +1534,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
1534
1534
|
if (!ed || ed.isDestroyed) return [];
|
|
1535
1535
|
if (!ed.isEditable) return [getText, findText, ...charts.read()];
|
|
1536
1536
|
const tools = [getText, findText, insertText, replaceText, replaceRange, replaceSelection, setSelection, ...formatting.tools(ed)];
|
|
1537
|
-
return [...tools, ...
|
|
1537
|
+
return [...tools, ..._chunkRLOIEDA3cjs.isTableEnabled.call(void 0, ed) ? [editTable] : [], ...charts.read(), ...charts.write().map(withCaret)];
|
|
1538
1538
|
},
|
|
1539
1539
|
subscribe: (notify) => {
|
|
1540
1540
|
const ed = editor();
|
package/dist/agent/index.js
CHANGED
|
@@ -121,12 +121,12 @@ import {
|
|
|
121
121
|
setAgentCaret,
|
|
122
122
|
sparklineLabel,
|
|
123
123
|
typeAgentText
|
|
124
|
-
} from "../chunk-
|
|
124
|
+
} from "../chunk-R2VHVQVY.js";
|
|
125
125
|
import {
|
|
126
126
|
describeChart
|
|
127
|
-
} from "../chunk-
|
|
127
|
+
} from "../chunk-KPWG3PSW.js";
|
|
128
128
|
import "../chunk-KGRZMHZB.js";
|
|
129
|
-
import "../chunk-
|
|
129
|
+
import "../chunk-OJQVKJYD.js";
|
|
130
130
|
import {
|
|
131
131
|
normalizeChartSpec,
|
|
132
132
|
parseChartValue
|
package/dist/canvas/index.cjs
CHANGED
|
@@ -113,7 +113,7 @@ var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
|
|
|
113
113
|
var _chunkN2FGYZ4Qcjs = require('../chunk-N2FGYZ4Q.cjs');
|
|
114
114
|
|
|
115
115
|
|
|
116
|
-
var
|
|
116
|
+
var _chunkTUXKLM5Wcjs = require('../chunk-TUXKLM5W.cjs');
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
var _chunkOUO3DSRTcjs = require('../chunk-OUO3DSRT.cjs');
|
|
@@ -8988,12 +8988,12 @@ function translatePath(d, dx, dy) {
|
|
|
8988
8988
|
}
|
|
8989
8989
|
var xyChartScene = ({ graph, theme }) => {
|
|
8990
8990
|
const box = _chunk3FSUJIXNcjs.XY_CHART_BOX;
|
|
8991
|
-
const scene =
|
|
8991
|
+
const scene = _chunkTUXKLM5Wcjs.layoutChart.call(void 0, xyChartSpec(graph, theme.palette), { width: box.width, height: box.height, theme: chartTheme(theme) });
|
|
8992
8992
|
return toDiagramMarks(scene.marks, box.x, box.y);
|
|
8993
8993
|
};
|
|
8994
8994
|
var radarScene = ({ graph, theme }) => {
|
|
8995
8995
|
const box = _chunk3FSUJIXNcjs.RADAR_CHART_BOX;
|
|
8996
|
-
const scene =
|
|
8996
|
+
const scene = _chunkTUXKLM5Wcjs.layoutChart.call(void 0, radarChartSpec(graph, theme.palette), { width: box.width, height: box.height, theme: chartTheme(theme) });
|
|
8997
8997
|
return toDiagramMarks(scene.marks, box.x, box.y);
|
|
8998
8998
|
};
|
|
8999
8999
|
|