@pixerate/editor 0.46.1 → 0.48.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/THIRD_PARTY_NOTICES.md +20 -0
- package/dist/agent/index.cjs +252 -34
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +19 -7
- package/dist/agent/index.d.ts +19 -7
- package/dist/agent/index.js +228 -10
- package/dist/agent/index.js.map +1 -1
- package/dist/{builtins-CZW-aYKS.d.cts → builtins-1kqwLUnb.d.cts} +2 -2
- package/dist/{builtins-DghNQbT-.d.ts → builtins-BKYlHH1s.d.ts} +2 -2
- package/dist/chart/index.cjs +1596 -1849
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +760 -548
- package/dist/chart/index.d.ts +760 -548
- package/dist/chart/index.js +1499 -1752
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-3RPOW4CS.js → chunk-2CJ3LPYQ.js} +12 -10
- package/dist/{chunk-3RPOW4CS.js.map → chunk-2CJ3LPYQ.js.map} +1 -1
- package/dist/{chunk-PQM5W7ZN.js → chunk-4FX5ACVG.js} +29 -2
- package/dist/{chunk-PQM5W7ZN.js.map → chunk-4FX5ACVG.js.map} +1 -1
- package/dist/{chunk-HHQ4XJWT.js → chunk-AMWXSYCI.js} +2 -2
- package/dist/chunk-EKYHKQPG.js +1895 -0
- package/dist/chunk-EKYHKQPG.js.map +1 -0
- package/dist/chunk-HXUL3LS7.js +113 -0
- package/dist/chunk-HXUL3LS7.js.map +1 -0
- package/dist/{chunk-ZRNHGAQT.js → chunk-JQ3BB3E6.js} +43 -1891
- package/dist/chunk-JQ3BB3E6.js.map +1 -0
- package/dist/chunk-LTUM52X6.js +4074 -0
- package/dist/chunk-LTUM52X6.js.map +1 -0
- package/dist/{chunk-J3R2OWOE.cjs → chunk-MUCYWI6W.cjs} +608 -15
- package/dist/chunk-MUCYWI6W.cjs.map +1 -0
- package/dist/chunk-PIMCHMZE.cjs +521 -0
- package/dist/chunk-PIMCHMZE.cjs.map +1 -0
- package/dist/{chunk-TK2XZK6Z.js → chunk-PKBWLEL7.js} +594 -1
- package/dist/chunk-PKBWLEL7.js.map +1 -0
- package/dist/chunk-PRSJJZBS.cjs +4074 -0
- package/dist/chunk-PRSJJZBS.cjs.map +1 -0
- package/dist/{chunk-EFDCLENW.cjs → chunk-RIWPYSKU.cjs} +29 -2
- package/dist/chunk-RIWPYSKU.cjs.map +1 -0
- package/dist/chunk-U6IZKC7B.cjs +113 -0
- package/dist/chunk-U6IZKC7B.cjs.map +1 -0
- package/dist/{chunk-EWCOFSCQ.cjs → chunk-UN33YOXW.cjs} +252 -2100
- package/dist/chunk-UN33YOXW.cjs.map +1 -0
- package/dist/{chunk-Q25ZS4F7.js → chunk-VKPEPWKZ.js} +72 -92
- package/dist/chunk-VKPEPWKZ.js.map +1 -0
- package/dist/{chunk-N4MLNJPO.cjs → chunk-WXEHCVJQ.cjs} +160 -180
- package/dist/chunk-WXEHCVJQ.cjs.map +1 -0
- package/dist/{chunk-K2LVZ4FA.cjs → chunk-XFYUFVAX.cjs} +3 -3
- package/dist/{chunk-K2LVZ4FA.cjs.map → chunk-XFYUFVAX.cjs.map} +1 -1
- package/dist/chunk-XP5IUZUO.cjs +1895 -0
- package/dist/chunk-XP5IUZUO.cjs.map +1 -0
- package/dist/chunk-XUUD43OV.js +521 -0
- package/dist/chunk-XUUD43OV.js.map +1 -0
- package/dist/{chunk-U7VGDSNY.cjs → chunk-YU4WQE5M.cjs} +101 -99
- package/dist/chunk-YU4WQE5M.cjs.map +1 -0
- package/dist/commands/index.cjs +93 -11
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +9 -7
- package/dist/commands/index.d.ts +9 -7
- package/dist/commands/index.js +92 -10
- package/dist/commands/index.js.map +1 -1
- package/dist/controller-ChjCCMLl.d.cts +822 -0
- package/dist/controller-DtbEo3om.d.ts +822 -0
- package/dist/extensions/index.cjs +32 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +5 -2
- package/dist/extensions/index.d.ts +5 -2
- package/dist/extensions/index.js +31 -2
- package/dist/generation/index.cjs +2 -2
- package/dist/generation/index.js +1 -1
- package/dist/{index-CfOQf70b.d.cts → index-DoHqT1mq.d.cts} +222 -5
- package/dist/{index-jwJ_onWf.d.ts → index-YLZ0fKqE.d.ts} +222 -5
- package/dist/index.cjs +38 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +52 -24
- package/dist/index.js.map +1 -1
- package/dist/parameters/index.d.cts +1 -1
- package/dist/parameters/index.d.ts +1 -1
- package/dist/{registry-vz6HOiiy.d.cts → registry-CaR7LC6W.d.cts} +2 -0
- package/dist/{registry-BfVD-vVg.d.ts → registry-rVtFJjRM.d.ts} +2 -0
- package/dist/spreadsheet/index.cjs +5 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +24 -22
- package/dist/tools/index.cjs +3 -3
- package/dist/tools/index.js +2 -2
- package/dist/vector/index.d.cts +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/package.json +2 -1
- package/dist/chunk-EFDCLENW.cjs.map +0 -1
- package/dist/chunk-EWCOFSCQ.cjs.map +0 -1
- package/dist/chunk-J3R2OWOE.cjs.map +0 -1
- package/dist/chunk-N4MLNJPO.cjs.map +0 -1
- package/dist/chunk-Q25ZS4F7.js.map +0 -1
- package/dist/chunk-TK2XZK6Z.js.map +0 -1
- package/dist/chunk-U7VGDSNY.cjs.map +0 -1
- package/dist/chunk-ZRNHGAQT.js.map +0 -1
- /package/dist/{chunk-HHQ4XJWT.js.map → chunk-AMWXSYCI.js.map} +0 -0
package/dist/agent/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHART_UPDATE_PROPERTIES,
|
|
3
|
+
SERIES_PROPS,
|
|
4
|
+
VALUE
|
|
5
|
+
} from "../chunk-HXUL3LS7.js";
|
|
1
6
|
import {
|
|
2
7
|
EDITOR_CANVAS_TOOLS,
|
|
3
8
|
EDITOR_MCP_TOOLS,
|
|
@@ -27,22 +32,32 @@ import {
|
|
|
27
32
|
createMcpServer,
|
|
28
33
|
createToolRegistry,
|
|
29
34
|
toToolResult
|
|
30
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-AMWXSYCI.js";
|
|
31
36
|
import {
|
|
32
37
|
hasVariantCommands
|
|
33
38
|
} from "../chunk-IB3ZHQAX.js";
|
|
34
39
|
import {
|
|
35
40
|
validateJsonSchema
|
|
36
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-4FX5ACVG.js";
|
|
37
42
|
import {
|
|
43
|
+
MAX_SPARKLINE_VALUES,
|
|
44
|
+
SPARKLINE_KINDS,
|
|
38
45
|
TABLE_ACTIONS,
|
|
39
46
|
applyReplacements,
|
|
47
|
+
getDocumentCharts,
|
|
40
48
|
getTableActionState,
|
|
41
49
|
getTableState,
|
|
42
50
|
isTableEnabled,
|
|
51
|
+
normalizeSparklineValues,
|
|
43
52
|
runTableAction,
|
|
44
|
-
searchDocument
|
|
45
|
-
|
|
53
|
+
searchDocument,
|
|
54
|
+
sparklineLabel
|
|
55
|
+
} from "../chunk-PKBWLEL7.js";
|
|
56
|
+
import {
|
|
57
|
+
describeChart,
|
|
58
|
+
normalizeChartSpec,
|
|
59
|
+
parseChartValue
|
|
60
|
+
} from "../chunk-LTUM52X6.js";
|
|
46
61
|
import {
|
|
47
62
|
getEditorMarkdown,
|
|
48
63
|
getEditorText,
|
|
@@ -50,11 +65,14 @@ import {
|
|
|
50
65
|
} from "../chunk-UKI64KUD.js";
|
|
51
66
|
import "../chunk-O5RYH2PG.js";
|
|
52
67
|
import "../chunk-SWE3NPOU.js";
|
|
68
|
+
import "../chunk-JQ3BB3E6.js";
|
|
53
69
|
import {
|
|
54
70
|
colNameToIndex,
|
|
55
71
|
indexToColName,
|
|
56
72
|
isFormulaError
|
|
57
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-EKYHKQPG.js";
|
|
74
|
+
import "../chunk-664LQYFJ.js";
|
|
75
|
+
import "../chunk-QVZZGT4X.js";
|
|
58
76
|
import {
|
|
59
77
|
ensureLayout,
|
|
60
78
|
getLayoutedNodes,
|
|
@@ -386,6 +404,204 @@ function planToolCall(name, args, snapshot, options) {
|
|
|
386
404
|
|
|
387
405
|
// src/agent/providers.ts
|
|
388
406
|
import { TextSelection } from "@tiptap/pm/state";
|
|
407
|
+
|
|
408
|
+
// src/agent/documentChartTools.ts
|
|
409
|
+
import { closeHistory } from "@tiptap/pm/history";
|
|
410
|
+
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
411
|
+
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
412
|
+
var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
413
|
+
var SIZE_WIDTH = {
|
|
414
|
+
type: ["number", "null"],
|
|
415
|
+
minimum: 50,
|
|
416
|
+
maximum: 4096,
|
|
417
|
+
description: "Width in pixels, or null to fill the line (default null)."
|
|
418
|
+
};
|
|
419
|
+
var SIZE_HEIGHT = { type: "number", minimum: 50, maximum: 4096, description: "Height in pixels (default 320)." };
|
|
420
|
+
var SPEC_PROPERTIES = {
|
|
421
|
+
...CHART_UPDATE_PROPERTIES,
|
|
422
|
+
categories: { type: "array", items: { type: "string" }, description: "Category labels in order (x axis labels, or pie slices)." },
|
|
423
|
+
series: {
|
|
424
|
+
type: "array",
|
|
425
|
+
description: "The series, each with one value per category (padded with gaps).",
|
|
426
|
+
items: {
|
|
427
|
+
type: "object",
|
|
428
|
+
properties: { id: { type: "string", description: "Stable id (default: from the name)." }, ...SERIES_PROPS },
|
|
429
|
+
required: ["name", "values"],
|
|
430
|
+
additionalProperties: false
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
function cleanSeries(series) {
|
|
435
|
+
if (!Array.isArray(series)) return series;
|
|
436
|
+
return series.map((s) => s && typeof s === "object" ? Object.fromEntries(Object.entries(s).filter(([, v]) => v !== null)) : s);
|
|
437
|
+
}
|
|
438
|
+
function checkedSpec(input) {
|
|
439
|
+
const { spec, issues } = normalizeChartSpec({ ...input, ...input.series !== void 0 ? { series: cleanSeries(input.series) } : {} });
|
|
440
|
+
if (issues.length) throw new Error(`The chart was not changed: ${issues.map((i) => i.message).join(" ")}`);
|
|
441
|
+
return spec;
|
|
442
|
+
}
|
|
443
|
+
function describe(chart, includeSpec) {
|
|
444
|
+
const { spec, node } = chart;
|
|
445
|
+
return {
|
|
446
|
+
id: chart.id,
|
|
447
|
+
pos: chart.pos,
|
|
448
|
+
type: spec.type,
|
|
449
|
+
title: spec.title,
|
|
450
|
+
categories: spec.categories,
|
|
451
|
+
series: spec.series.map((s) => ({ id: s.id, name: s.name })),
|
|
452
|
+
width: node.attrs.width ?? null,
|
|
453
|
+
height: node.attrs.height,
|
|
454
|
+
description: describeChart(spec),
|
|
455
|
+
...includeSpec ? { spec } : {}
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
function sparklines(doc) {
|
|
459
|
+
const found = [];
|
|
460
|
+
doc.descendants((node, pos) => {
|
|
461
|
+
if (node.type.name === "sparkline") found.push({ pos, kind: node.attrs.kind, values: node.attrs.values, label: sparklineLabel(node) });
|
|
462
|
+
});
|
|
463
|
+
return found;
|
|
464
|
+
}
|
|
465
|
+
function checkPosition(editor, at) {
|
|
466
|
+
const size = editor.state.doc.content.size;
|
|
467
|
+
if (at !== void 0 && at > size) throw new Error(`Position ${at} is outside the document (size ${size}).`);
|
|
468
|
+
}
|
|
469
|
+
function createDocumentChartTools(editor) {
|
|
470
|
+
const chartType = () => editor().schema.nodes.chart;
|
|
471
|
+
const findChart = (args) => {
|
|
472
|
+
const charts = getDocumentCharts(editor().state.doc);
|
|
473
|
+
const list = charts.map((c) => `"${c.id}" at ${c.pos}`).join(", ") || "none; add one with insert_chart";
|
|
474
|
+
if (args.chartId !== void 0) {
|
|
475
|
+
const chart = charts.find((c) => c.id === args.chartId);
|
|
476
|
+
if (!chart) throw new Error(`There is no chart "${args.chartId}" in the document. Charts: ${list}.`);
|
|
477
|
+
if (args.pos !== void 0 && args.pos !== chart.pos) throw new Error(`Chart "${args.chartId}" is at ${chart.pos}, not ${args.pos}; pass one of chartId or pos.`);
|
|
478
|
+
return chart;
|
|
479
|
+
}
|
|
480
|
+
if (args.pos !== void 0) {
|
|
481
|
+
const chart = charts.find((c) => c.pos === args.pos);
|
|
482
|
+
if (!chart) throw new Error(`There is no chart at position ${args.pos}. Charts: ${list}.`);
|
|
483
|
+
return chart;
|
|
484
|
+
}
|
|
485
|
+
throw new Error(`Pass chartId or pos (from list_document_charts). Charts: ${list}.`);
|
|
486
|
+
};
|
|
487
|
+
const listCharts = {
|
|
488
|
+
name: "list_document_charts",
|
|
489
|
+
title: "List charts in the document",
|
|
490
|
+
description: "Lists the charts in the document in order: id, document position, type, title, categories, series (ids and names), size in pixels and a plain-language description of the data. Also lists inline sparklines (position, kind, values). Pass the id or position to update_chart_in_document.",
|
|
491
|
+
inputSchema: {
|
|
492
|
+
type: "object",
|
|
493
|
+
properties: { includeSpec: { type: "boolean", description: "Also return each chart's full spec (default false)." } },
|
|
494
|
+
additionalProperties: false
|
|
495
|
+
},
|
|
496
|
+
annotations: { title: "List charts in the document", ...READ },
|
|
497
|
+
handler: ({ includeSpec = false }) => {
|
|
498
|
+
const doc = editor().state.doc;
|
|
499
|
+
return { charts: getDocumentCharts(doc).map((c) => describe(c, includeSpec)), sparklines: editor().schema.nodes.sparkline ? sparklines(doc) : [] };
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
const insertChart = {
|
|
503
|
+
name: "insert_chart",
|
|
504
|
+
title: "Insert a chart",
|
|
505
|
+
description: "Inserts a chart block at a document position (or the cursor), as one undo step. Give the categories and series (one value per category) and any presentation fields (type, titles, axes, legend, stacking, palette, \u2026). Invalid fields change nothing and come back as sentences. Returns the new chart's id, position and stored spec.",
|
|
506
|
+
inputSchema: {
|
|
507
|
+
type: "object",
|
|
508
|
+
properties: {
|
|
509
|
+
spec: { type: "object", description: "The chart: categories and series, plus optional presentation fields.", properties: SPEC_PROPERTIES, required: ["categories", "series"], additionalProperties: false },
|
|
510
|
+
at: { type: "integer", minimum: 0, description: "Document position (default: the selection). A position inside a paragraph splits it." },
|
|
511
|
+
width: SIZE_WIDTH,
|
|
512
|
+
height: SIZE_HEIGHT
|
|
513
|
+
},
|
|
514
|
+
required: ["spec"],
|
|
515
|
+
additionalProperties: false
|
|
516
|
+
},
|
|
517
|
+
annotations: { title: "Insert a chart", ...WRITE },
|
|
518
|
+
handler: ({ spec: input, at, width = null, height }) => {
|
|
519
|
+
const ed = editor();
|
|
520
|
+
checkPosition(ed, at);
|
|
521
|
+
const spec = checkedSpec(input);
|
|
522
|
+
const id = ed.extensionManager.extensions.find((e) => e.name === "chart")?.options.generateId?.() ?? `chart-${Date.now().toString(36)}`;
|
|
523
|
+
const node = { type: "chart", attrs: { id, spec, width, ...height !== void 0 ? { height } : {} } };
|
|
524
|
+
const chain = ed.chain().command(({ tr }) => (closeHistory(tr), true));
|
|
525
|
+
const ok = (at !== void 0 ? chain.insertContentAt(at, node) : chain.insertContent(node)).run();
|
|
526
|
+
const chart = getDocumentCharts(ed.state.doc).find((c) => c.id === id);
|
|
527
|
+
if (!ok || !chart) throw new Error(`A chart cannot go at ${at ?? ed.state.selection.from}; pass a position between blocks or inside a paragraph.`);
|
|
528
|
+
return { id: chart.id, pos: chart.pos, spec: chart.spec, width: chart.node.attrs.width, height: chart.node.attrs.height };
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
const updateChart = {
|
|
532
|
+
name: "update_chart_in_document",
|
|
533
|
+
title: "Change a chart in the document",
|
|
534
|
+
description: "Changes one chart (by id or position from list_document_charts) as one undo step: data (categories, series \u2014 given series replace all) and / or presentation fields, which merge into the current spec (axes and legend field by field), plus its size. All-or-nothing: invalid values change nothing and come back as sentences. Returns the chart's id, position and new spec.",
|
|
535
|
+
inputSchema: {
|
|
536
|
+
type: "object",
|
|
537
|
+
properties: {
|
|
538
|
+
chartId: { type: "string", description: "Chart id from list_document_charts." },
|
|
539
|
+
pos: { type: "integer", minimum: 0, description: "Document position of the chart (from list_document_charts), instead of chartId." },
|
|
540
|
+
changes: { type: "object", description: "Fields to change; omitted fields keep their value.", properties: SPEC_PROPERTIES, additionalProperties: false },
|
|
541
|
+
width: SIZE_WIDTH,
|
|
542
|
+
height: { ...SIZE_HEIGHT, description: "Height in pixels (default: unchanged)." }
|
|
543
|
+
},
|
|
544
|
+
additionalProperties: false
|
|
545
|
+
},
|
|
546
|
+
annotations: { title: "Change a chart in the document", ...WRITE_IDEMPOTENT },
|
|
547
|
+
handler: ({ chartId, pos, changes, width, height }) => {
|
|
548
|
+
const ed = editor();
|
|
549
|
+
const chart = findChart({ chartId, pos });
|
|
550
|
+
if (!changes && width === void 0 && height === void 0) throw new Error('Nothing to change: pass changes, width or height, e.g. {"changes": {"type": "line"}}.');
|
|
551
|
+
const s = chart.spec;
|
|
552
|
+
const patch = changes ?? {};
|
|
553
|
+
const spec = checkedSpec({
|
|
554
|
+
...s,
|
|
555
|
+
...patch,
|
|
556
|
+
xAxis: patch.xAxis ? { ...s.xAxis, ...patch.xAxis } : s.xAxis,
|
|
557
|
+
yAxis: patch.yAxis ? { ...s.yAxis, ...patch.yAxis } : s.yAxis,
|
|
558
|
+
yAxis2: patch.yAxis2 ? { ...s.yAxis2, ...patch.yAxis2 } : s.yAxis2,
|
|
559
|
+
legend: patch.legend ? { ...s.legend, ...patch.legend } : s.legend
|
|
560
|
+
});
|
|
561
|
+
const attrs = { ...chart.node.attrs, spec, ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} };
|
|
562
|
+
ed.view.dispatch(closeHistory(ed.state.tr.setNodeMarkup(chart.pos, void 0, attrs)));
|
|
563
|
+
return { id: chart.id, pos: chart.pos, spec, width: attrs.width, height: attrs.height };
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const insertSparkline = {
|
|
567
|
+
name: "insert_sparkline",
|
|
568
|
+
title: "Insert a sparkline",
|
|
569
|
+
description: "Inserts a word-sized chart into the text at a document position (or the cursor), as one undo step. Returns its position and stored values.",
|
|
570
|
+
inputSchema: {
|
|
571
|
+
type: "object",
|
|
572
|
+
properties: {
|
|
573
|
+
values: { type: "array", items: VALUE, minItems: 1, maxItems: MAX_SPARKLINE_VALUES, description: "Values in order (null for a gap)." },
|
|
574
|
+
kind: { type: "string", enum: [...SPARKLINE_KINDS], description: "line (default), column, or win-loss (sign only)." },
|
|
575
|
+
at: { type: "integer", minimum: 0, description: "Document position inside a paragraph (default: the selection)." },
|
|
576
|
+
width: { type: "number", minimum: 4, maximum: 1e3, description: "Width in pixels (default 80)." },
|
|
577
|
+
height: { type: "number", minimum: 4, maximum: 200, description: "Height in pixels (default 18)." },
|
|
578
|
+
color: { type: "string", description: "CSS colour (default: the first palette colour)." },
|
|
579
|
+
label: { type: "string", description: 'Accessible label (default: "Trend from <first> to <last>").' }
|
|
580
|
+
},
|
|
581
|
+
required: ["values"],
|
|
582
|
+
additionalProperties: false
|
|
583
|
+
},
|
|
584
|
+
annotations: { title: "Insert a sparkline", ...WRITE },
|
|
585
|
+
handler: ({ values, kind = "line", at, width = 80, height = 18, color = null, label = null }) => {
|
|
586
|
+
const ed = editor();
|
|
587
|
+
checkPosition(ed, at);
|
|
588
|
+
const parsed = values.map((v) => parseChartValue(v));
|
|
589
|
+
const bad = parsed.findIndex((v) => v === void 0);
|
|
590
|
+
if (bad >= 0) throw new Error(`values[${bad}] ("${String(values[bad])}") is not a number; pass numbers, numeric text or null. Nothing was inserted.`);
|
|
591
|
+
const pos = at ?? ed.state.selection.from;
|
|
592
|
+
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}).`);
|
|
593
|
+
const stored = normalizeSparklineValues(parsed);
|
|
594
|
+
ed.chain().command(({ tr }) => (closeHistory(tr), true)).insertContentAt(pos, { type: "sparkline", attrs: { values: stored, kind, width, height, color, label } }).run();
|
|
595
|
+
return { pos, kind, values: stored };
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
return {
|
|
599
|
+
read: () => chartType() ? [listCharts] : [],
|
|
600
|
+
write: () => chartType() ? [insertChart, updateChart, ...editor().schema.nodes.sparkline ? [insertSparkline] : []] : []
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// src/agent/providers.ts
|
|
389
605
|
var toEditor = (target) => "commands" in target ? target : target.editor;
|
|
390
606
|
function replaceWithText(editor, from, to, text) {
|
|
391
607
|
const { state, view } = editor;
|
|
@@ -431,6 +647,7 @@ function findMatches(editor, query, args, replacement) {
|
|
|
431
647
|
}
|
|
432
648
|
function createRichTextToolProvider(target, options) {
|
|
433
649
|
const editor = () => toEditor(target);
|
|
650
|
+
const charts = createDocumentChartTools(editor);
|
|
434
651
|
const getText = {
|
|
435
652
|
name: "get_text",
|
|
436
653
|
title: "Get document text",
|
|
@@ -720,9 +937,9 @@ function createRichTextToolProvider(target, options) {
|
|
|
720
937
|
tools: () => {
|
|
721
938
|
const ed = editor();
|
|
722
939
|
if (!ed || ed.isDestroyed) return [];
|
|
723
|
-
if (!ed.isEditable) return [getText, findText];
|
|
940
|
+
if (!ed.isEditable) return [getText, findText, ...charts.read()];
|
|
724
941
|
const tools = [getText, findText, insertText, replaceText, replaceRange, replaceSelection, setSelection];
|
|
725
|
-
return isTableEnabled(ed) ? [
|
|
942
|
+
return [...tools, ...isTableEnabled(ed) ? [editTable] : [], ...charts.read(), ...charts.write()];
|
|
726
943
|
},
|
|
727
944
|
subscribe: (notify) => {
|
|
728
945
|
const ed = editor();
|
|
@@ -1052,8 +1269,8 @@ var COMPONENT_ID = { type: "string", description: "Component or component set id
|
|
|
1052
1269
|
var PARENT_ID = { type: "string", description: "Frame to place the instance in (default: the canvas root)." };
|
|
1053
1270
|
var X = { type: "number", description: "X position (canvas coordinates, or relative to the parent frame)." };
|
|
1054
1271
|
var Y = { type: "number", description: "Y position (canvas coordinates, or relative to the parent frame)." };
|
|
1055
|
-
var
|
|
1056
|
-
var
|
|
1272
|
+
var READ2 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
1273
|
+
var WRITE2 = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
1057
1274
|
var DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
|
|
1058
1275
|
var TITLES = {
|
|
1059
1276
|
list_components: "List components",
|
|
@@ -1087,7 +1304,7 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
|
|
|
1087
1304
|
inputSchema: { type: "object", properties, ...extra.required ? { required: extra.required } : {}, additionalProperties: false },
|
|
1088
1305
|
annotations: {
|
|
1089
1306
|
title: TITLES[name],
|
|
1090
|
-
...extra.readOnly ?
|
|
1307
|
+
...extra.readOnly ? READ2 : DESTRUCTIVE_TOOLS.has(name) ? DESTRUCTIVE : WRITE2
|
|
1091
1308
|
},
|
|
1092
1309
|
handler
|
|
1093
1310
|
});
|
|
@@ -1267,6 +1484,7 @@ export {
|
|
|
1267
1484
|
ToolRegistry,
|
|
1268
1485
|
ToolRegistryError,
|
|
1269
1486
|
createCanvasComponentToolProvider,
|
|
1487
|
+
createDocumentChartTools,
|
|
1270
1488
|
createEditorMcpToolProvider,
|
|
1271
1489
|
createMcpServer,
|
|
1272
1490
|
createRichTextToolProvider,
|