pptx-viewer-mcp 2.1.7 → 2.3.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/CHANGELOG.md +12 -0
- package/README.md +20 -19
- package/dist/index.d.ts +279 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +347 -6
- package/dist/index.mjs +336 -8
- package/dist/mcp/index.js +914 -39
- package/dist/mcp/index.mjs +915 -40
- package/dist/schemas/index.d.ts +679 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +373 -0
- package/dist/schemas/index.mjs +356 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PptxHandler, hasTextProperties, cloneElement as cloneElement$1, isTemplateElementId, makeStoreAwareId, reassignDescendantIds, groupElements as groupElements$1, ungroupElements as ungroupElements$1, PptxMarkdownConverter, ThemePresets, getThemePreset, setChartType, setChartTitle, setChartGrouping, setChartLegend, setChartDataLabels, setChartAxis, setChartCategories, addChartSeries, removeChartSeries, updateChartSeriesValues, ChartBuilder, decomposeSmartArt, demoteSmartArtNode, promoteSmartArtNode, reorderSmartArtNode, updateSmartArtNodeText, removeSmartArtNode, addSmartArtNode, mergePresentation, diffPresentations, findPlaceholders, applyTemplate, getSectionForSlide, moveSlidesToSection, reorderSections, removeSection, addSection, SvgExporter, buildPptxJsonDocument, deserializePptxFromJson, applyImportedPptxData, replaceWithCustomGeometry, replaceShapeGeometry, setElementLocked, validatePptx, repairPptx, findLayoutByName, findLayoutByType } from 'pptx-viewer-core';
|
|
1
|
+
import { PptxHandler, hasTextProperties, resolveThemeColorRef, cloneElement as cloneElement$1, isTemplateElementId, makeStoreAwareId, reassignDescendantIds, groupElements as groupElements$1, ungroupElements as ungroupElements$1, TABLE_STYLE_PART_SEQUENCE, normalizeTableStyleGuid, createTableStyleEntry, addTableStyleToMap, deleteTableStyleFromMap, PptxMarkdownConverter, ThemePresets, getThemePreset, setChartType, setChartTitle, setChartGrouping, setChartLegend, setChartDataLabels, setChartAxis, setChartCategories, addChartSeries, removeChartSeries, updateChartSeriesValues, ChartBuilder, setChartDataPointStyle, setChartDataPointExplosion, setChartDataPointMarker, setChartDataPointLabel, setChartSeriesMarker, setChartSeriesTrendline, setChartSeriesErrorBars, setChartHelperLine, setChartColorMapOverride, listChartUserShapes, addChartUserShape, updateChartUserShape, removeChartUserShape, decomposeSmartArt, demoteSmartArtNode, promoteSmartArtNode, reorderSmartArtNode, updateSmartArtNodeText, removeSmartArtNode, addSmartArtNode, mergePresentation, diffPresentations, findPlaceholders, applyTemplate, getSectionForSlide, moveSlidesToSection, reorderSections, removeSection, addSection, SvgExporter, buildPptxJsonDocument, deserializePptxFromJson, applyImportedPptxData, replaceWithCustomGeometry, replaceShapeGeometry, setElementLocked, validatePptx, repairPptx, findLayoutByName, findLayoutByType } from 'pptx-viewer-core';
|
|
2
2
|
export { PptxHandler } from 'pptx-viewer-core';
|
|
3
3
|
|
|
4
4
|
// src/execution.ts
|
|
@@ -21,11 +21,17 @@ async function loadPresentation(filePath, execCtx) {
|
|
|
21
21
|
const pptxData = await handler.load(rawBytes.buffer);
|
|
22
22
|
return { pptxData, rawBytes };
|
|
23
23
|
}
|
|
24
|
-
async function savePresentation(filePath, pptxData, rawBytes, execCtx) {
|
|
24
|
+
async function savePresentation(filePath, pptxData, rawBytes, execCtx, tableStyleSaveOptions) {
|
|
25
25
|
const handler = new PptxHandler();
|
|
26
26
|
await handler.load(rawBytes.buffer);
|
|
27
27
|
const outputBytes = await handler.save(pptxData.slides, {
|
|
28
|
-
headerFooter: pptxData.headerFooter
|
|
28
|
+
headerFooter: pptxData.headerFooter,
|
|
29
|
+
// `pptxData.tableStyleMap` carries any in-memory table-style edits a
|
|
30
|
+
// tool made (e.g. `set_table_style_section`, `create_table_style`);
|
|
31
|
+
// without forwarding it here those edits were silently dropped on
|
|
32
|
+
// save even though the core save pipeline already supports them.
|
|
33
|
+
tableStyles: pptxData.tableStyleMap,
|
|
34
|
+
...tableStyleSaveOptions
|
|
29
35
|
});
|
|
30
36
|
if (execCtx.collaboration) {
|
|
31
37
|
const room = execCtx.collaboration.getRoom(filePath);
|
|
@@ -57,7 +63,13 @@ async function executeToolWithContext(filePath, execCtx, toolFn) {
|
|
|
57
63
|
const { pptxData, rawBytes } = await loadPresentation(filePath, execCtx);
|
|
58
64
|
const toolResult = await toolFn({ pptxData });
|
|
59
65
|
if (toolResult.dirty) {
|
|
60
|
-
const saveResult = await savePresentation(
|
|
66
|
+
const saveResult = await savePresentation(
|
|
67
|
+
filePath,
|
|
68
|
+
toolResult.pptxData,
|
|
69
|
+
rawBytes,
|
|
70
|
+
execCtx,
|
|
71
|
+
toolResult.saveOptions
|
|
72
|
+
);
|
|
61
73
|
return { ...toolResult.result, ...saveResult };
|
|
62
74
|
}
|
|
63
75
|
return toolResult.result;
|
|
@@ -580,8 +592,17 @@ function updateElement(ctx, params) {
|
|
|
580
592
|
if (params.fontFamily !== void 0) {
|
|
581
593
|
textEl.textStyle.fontFamily = params.fontFamily;
|
|
582
594
|
}
|
|
583
|
-
if (params.
|
|
595
|
+
if (params.fontThemeColor !== void 0) {
|
|
596
|
+
textEl.textStyle.colorRef = params.fontThemeColor;
|
|
597
|
+
const resolved = resolveThemeColorRef(params.fontThemeColor, ctx.pptxData.themeColorMap);
|
|
598
|
+
if (params.fontColor !== void 0) {
|
|
599
|
+
textEl.textStyle.color = params.fontColor;
|
|
600
|
+
} else if (resolved) {
|
|
601
|
+
textEl.textStyle.color = resolved;
|
|
602
|
+
}
|
|
603
|
+
} else if (params.fontColor !== void 0) {
|
|
584
604
|
textEl.textStyle.color = params.fontColor;
|
|
605
|
+
textEl.textStyle.colorRef = void 0;
|
|
585
606
|
}
|
|
586
607
|
if (params.bold !== void 0) {
|
|
587
608
|
textEl.textStyle.bold = params.bold;
|
|
@@ -1072,6 +1093,142 @@ function manageTableStructure(ctx, params) {
|
|
|
1072
1093
|
}
|
|
1073
1094
|
};
|
|
1074
1095
|
}
|
|
1096
|
+
function findTableElement(ctx, slideIndex, elementId) {
|
|
1097
|
+
const err = validateSlideIndex(slideIndex, ctx.pptxData.slides.length);
|
|
1098
|
+
if (err) {
|
|
1099
|
+
throw new Error(err);
|
|
1100
|
+
}
|
|
1101
|
+
const slide = ctx.pptxData.slides[slideIndex];
|
|
1102
|
+
const el = slide.elements.find((e) => e.id === elementId);
|
|
1103
|
+
if (!el) {
|
|
1104
|
+
throw new Error(`Element '${elementId}' not found on slide ${slideIndex}.`);
|
|
1105
|
+
}
|
|
1106
|
+
if (el.type !== "table") {
|
|
1107
|
+
throw new Error(`Element '${elementId}' is not a table.`);
|
|
1108
|
+
}
|
|
1109
|
+
return el;
|
|
1110
|
+
}
|
|
1111
|
+
function tableStyleIdsInUse(ctx) {
|
|
1112
|
+
const used = /* @__PURE__ */ new Set();
|
|
1113
|
+
for (const slide of ctx.pptxData.slides) {
|
|
1114
|
+
for (const el of slide.elements) {
|
|
1115
|
+
if (el.type === "table" && el.tableData?.tableStyleId) {
|
|
1116
|
+
used.add(normalizeTableStyleGuid(el.tableData.tableStyleId));
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
return used;
|
|
1121
|
+
}
|
|
1122
|
+
function setTableStyleSection(ctx, params) {
|
|
1123
|
+
if (!TABLE_STYLE_PART_SEQUENCE.includes(params.section)) {
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
`Unknown table style section '${params.section}'. Valid sections: ${TABLE_STYLE_PART_SEQUENCE.join(", ")}.`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
const map = ctx.pptxData.tableStyleMap ?? {};
|
|
1129
|
+
ctx.pptxData.tableStyleMap = map;
|
|
1130
|
+
const normalizedId = normalizeTableStyleGuid(params.styleId);
|
|
1131
|
+
const entry = map[normalizedId];
|
|
1132
|
+
if (!entry) {
|
|
1133
|
+
throw new Error(
|
|
1134
|
+
`Table style '${params.styleId}' is not loaded in this presentation. Use create_table_style to add a new one.`
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
if (params.styleName !== void 0) {
|
|
1138
|
+
entry.styleName = params.styleName;
|
|
1139
|
+
}
|
|
1140
|
+
const mutableEntry = entry;
|
|
1141
|
+
if (params.fill !== void 0) {
|
|
1142
|
+
mutableEntry[`${params.section}Fill`] = params.fill;
|
|
1143
|
+
}
|
|
1144
|
+
if (params.text !== void 0) {
|
|
1145
|
+
mutableEntry[`${params.section}Text`] = params.text;
|
|
1146
|
+
}
|
|
1147
|
+
if (params.borders !== void 0) {
|
|
1148
|
+
mutableEntry[`${params.section}Borders`] = params.borders;
|
|
1149
|
+
}
|
|
1150
|
+
if (params.cell3D !== void 0) {
|
|
1151
|
+
mutableEntry[`${params.section}Cell3D`] = params.cell3D;
|
|
1152
|
+
}
|
|
1153
|
+
return {
|
|
1154
|
+
pptxData: ctx.pptxData,
|
|
1155
|
+
dirty: true,
|
|
1156
|
+
result: { styleId: normalizedId, section: params.section }
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function createTableStyle(ctx, params) {
|
|
1160
|
+
const map = ctx.pptxData.tableStyleMap ?? {};
|
|
1161
|
+
ctx.pptxData.tableStyleMap = map;
|
|
1162
|
+
const basedOn = params.basedOnStyleId ? map[normalizeTableStyleGuid(params.basedOnStyleId)] : void 0;
|
|
1163
|
+
if (params.basedOnStyleId && !basedOn) {
|
|
1164
|
+
throw new Error(`basedOnStyleId '${params.basedOnStyleId}' is not a loaded table style.`);
|
|
1165
|
+
}
|
|
1166
|
+
const entry = createTableStyleEntry(map, { styleName: params.styleName, basedOn });
|
|
1167
|
+
addTableStyleToMap(map, entry);
|
|
1168
|
+
return {
|
|
1169
|
+
pptxData: ctx.pptxData,
|
|
1170
|
+
dirty: true,
|
|
1171
|
+
result: { styleId: entry.styleId },
|
|
1172
|
+
...params.setAsDefault ? { saveOptions: { tableStylesDefaultId: entry.styleId } } : {}
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
function deleteTableStyle(ctx, params) {
|
|
1176
|
+
const normalizedId = normalizeTableStyleGuid(params.styleId);
|
|
1177
|
+
if (!params.force) {
|
|
1178
|
+
const used = tableStyleIdsInUse(ctx);
|
|
1179
|
+
if (used.has(normalizedId)) {
|
|
1180
|
+
throw new Error(
|
|
1181
|
+
`Table style '${params.styleId}' is assigned to at least one table on this deck. Reassign those tables first, or pass force: true.`
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
const map = ctx.pptxData.tableStyleMap ?? {};
|
|
1186
|
+
ctx.pptxData.tableStyleMap = map;
|
|
1187
|
+
deleteTableStyleFromMap(map, normalizedId);
|
|
1188
|
+
return {
|
|
1189
|
+
pptxData: ctx.pptxData,
|
|
1190
|
+
dirty: true,
|
|
1191
|
+
result: { deleted: true },
|
|
1192
|
+
saveOptions: { tableStylesToDelete: [normalizedId] }
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
function assignTableStyle(ctx, params) {
|
|
1196
|
+
const el = findTableElement(ctx, params.slideIndex, params.elementId);
|
|
1197
|
+
if (!el.tableData) {
|
|
1198
|
+
throw new Error(`Table '${params.elementId}' has no tableData.`);
|
|
1199
|
+
}
|
|
1200
|
+
const styleId = params.styleId ?? ctx.pptxData.tableStylesDefaultId;
|
|
1201
|
+
if (!styleId) {
|
|
1202
|
+
throw new Error(
|
|
1203
|
+
"styleId was not provided and this presentation has no tableStylesDefaultId to fall back to."
|
|
1204
|
+
);
|
|
1205
|
+
}
|
|
1206
|
+
const normalizedId = normalizeTableStyleGuid(styleId);
|
|
1207
|
+
el.tableData.tableStyleId = normalizedId;
|
|
1208
|
+
if (params.bandedRows !== void 0) {
|
|
1209
|
+
el.tableData.bandedRows = params.bandedRows;
|
|
1210
|
+
}
|
|
1211
|
+
if (params.bandedColumns !== void 0) {
|
|
1212
|
+
el.tableData.bandedColumns = params.bandedColumns;
|
|
1213
|
+
}
|
|
1214
|
+
if (params.firstRowHeader !== void 0) {
|
|
1215
|
+
el.tableData.firstRowHeader = params.firstRowHeader;
|
|
1216
|
+
}
|
|
1217
|
+
if (params.lastRow !== void 0) {
|
|
1218
|
+
el.tableData.lastRow = params.lastRow;
|
|
1219
|
+
}
|
|
1220
|
+
if (params.firstCol !== void 0) {
|
|
1221
|
+
el.tableData.firstCol = params.firstCol;
|
|
1222
|
+
}
|
|
1223
|
+
if (params.lastCol !== void 0) {
|
|
1224
|
+
el.tableData.lastCol = params.lastCol;
|
|
1225
|
+
}
|
|
1226
|
+
return {
|
|
1227
|
+
pptxData: ctx.pptxData,
|
|
1228
|
+
dirty: true,
|
|
1229
|
+
result: { elementId: params.elementId, styleId: normalizedId }
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1075
1232
|
function updateElementStyle(ctx, params) {
|
|
1076
1233
|
const err = validateSlideIndex(params.slideIndex, ctx.pptxData.slides.length);
|
|
1077
1234
|
if (err) {
|
|
@@ -1087,8 +1244,17 @@ function updateElementStyle(ctx, params) {
|
|
|
1087
1244
|
el.shapeStyle = {};
|
|
1088
1245
|
}
|
|
1089
1246
|
const ss = el.shapeStyle;
|
|
1090
|
-
if (params.
|
|
1247
|
+
if (params.fillThemeColor !== void 0) {
|
|
1248
|
+
ss.fillColorRef = params.fillThemeColor;
|
|
1249
|
+
const resolved = resolveThemeColorRef(params.fillThemeColor, ctx.pptxData.themeColorMap);
|
|
1250
|
+
if (params.fillColor !== void 0) {
|
|
1251
|
+
ss.fillColor = params.fillColor;
|
|
1252
|
+
} else if (resolved) {
|
|
1253
|
+
ss.fillColor = resolved;
|
|
1254
|
+
}
|
|
1255
|
+
} else if (params.fillColor !== void 0) {
|
|
1091
1256
|
ss.fillColor = params.fillColor;
|
|
1257
|
+
ss.fillColorRef = void 0;
|
|
1092
1258
|
}
|
|
1093
1259
|
if (params.fillMode !== void 0) {
|
|
1094
1260
|
ss.fillMode = params.fillMode;
|
|
@@ -1105,8 +1271,17 @@ function updateElementStyle(ctx, params) {
|
|
|
1105
1271
|
if (params.fillOpacity !== void 0) {
|
|
1106
1272
|
ss.fillOpacity = params.fillOpacity;
|
|
1107
1273
|
}
|
|
1108
|
-
if (params.
|
|
1274
|
+
if (params.strokeThemeColor !== void 0) {
|
|
1275
|
+
ss.strokeColorRef = params.strokeThemeColor;
|
|
1276
|
+
const resolved = resolveThemeColorRef(params.strokeThemeColor, ctx.pptxData.themeColorMap);
|
|
1277
|
+
if (params.strokeColor !== void 0) {
|
|
1278
|
+
ss.strokeColor = params.strokeColor;
|
|
1279
|
+
} else if (resolved) {
|
|
1280
|
+
ss.strokeColor = resolved;
|
|
1281
|
+
}
|
|
1282
|
+
} else if (params.strokeColor !== void 0) {
|
|
1109
1283
|
ss.strokeColor = params.strokeColor;
|
|
1284
|
+
ss.strokeColorRef = void 0;
|
|
1110
1285
|
}
|
|
1111
1286
|
if (params.strokeWidth !== void 0) {
|
|
1112
1287
|
ss.strokeWidth = params.strokeWidth;
|
|
@@ -1847,6 +2022,159 @@ function createChart(ctx, params) {
|
|
|
1847
2022
|
result: { elementId: chart.id, slideIndex: params.slideIndex }
|
|
1848
2023
|
};
|
|
1849
2024
|
}
|
|
2025
|
+
function findChartElement(ctx, slideIndex, elementId) {
|
|
2026
|
+
const err = validateSlideIndex(slideIndex, ctx.pptxData.slides.length);
|
|
2027
|
+
if (err) {
|
|
2028
|
+
throw new Error(err);
|
|
2029
|
+
}
|
|
2030
|
+
const slide = ctx.pptxData.slides[slideIndex];
|
|
2031
|
+
const el = slide.elements.find((e) => e.id === elementId);
|
|
2032
|
+
if (!el) {
|
|
2033
|
+
throw new Error(`Element '${elementId}' not found on slide ${slideIndex}.`);
|
|
2034
|
+
}
|
|
2035
|
+
if (el.type !== "chart") {
|
|
2036
|
+
throw new Error(`Element '${elementId}' is not a chart.`);
|
|
2037
|
+
}
|
|
2038
|
+
return el;
|
|
2039
|
+
}
|
|
2040
|
+
function formatChartDataPoint(ctx, params) {
|
|
2041
|
+
const chart = findChartElement(ctx, params.slideIndex, params.elementId);
|
|
2042
|
+
if (params.clearStyle) {
|
|
2043
|
+
setChartDataPointStyle(chart, params.seriesIndex, params.pointIndex, null);
|
|
2044
|
+
} else if (params.fillColor !== void 0 || params.strokeColor !== void 0 || params.strokeWidth !== void 0 || params.strokeDashStyle !== void 0) {
|
|
2045
|
+
setChartDataPointStyle(chart, params.seriesIndex, params.pointIndex, {
|
|
2046
|
+
...params.fillColor !== void 0 ? { fillColor: params.fillColor } : {},
|
|
2047
|
+
...params.strokeColor !== void 0 ? { strokeColor: params.strokeColor } : {},
|
|
2048
|
+
...params.strokeWidth !== void 0 ? { strokeWidth: params.strokeWidth } : {},
|
|
2049
|
+
...params.strokeDashStyle !== void 0 ? { strokeDashStyle: params.strokeDashStyle } : {}
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
if (params.explosion !== void 0) {
|
|
2053
|
+
setChartDataPointExplosion(chart, params.seriesIndex, params.pointIndex, params.explosion);
|
|
2054
|
+
}
|
|
2055
|
+
if (params.marker !== void 0) {
|
|
2056
|
+
setChartDataPointMarker(chart, params.seriesIndex, params.pointIndex, params.marker);
|
|
2057
|
+
}
|
|
2058
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2059
|
+
}
|
|
2060
|
+
function formatChartDataLabel(ctx, params) {
|
|
2061
|
+
const chart = findChartElement(ctx, params.slideIndex, params.elementId);
|
|
2062
|
+
if (params.remove) {
|
|
2063
|
+
setChartDataPointLabel(chart, params.seriesIndex, params.pointIndex, null);
|
|
2064
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2065
|
+
}
|
|
2066
|
+
setChartDataPointLabel(chart, params.seriesIndex, params.pointIndex, {
|
|
2067
|
+
...params.showValue !== void 0 ? { showValue: params.showValue } : {},
|
|
2068
|
+
...params.showCategory !== void 0 ? { showCategory: params.showCategory } : {},
|
|
2069
|
+
...params.showSeriesName !== void 0 ? { showSeriesName: params.showSeriesName } : {},
|
|
2070
|
+
...params.showPercent !== void 0 ? { showPercent: params.showPercent } : {},
|
|
2071
|
+
...params.showLegendKey !== void 0 ? { showLegendKey: params.showLegendKey } : {},
|
|
2072
|
+
...params.position !== void 0 ? { position: params.position } : {},
|
|
2073
|
+
...params.text !== void 0 ? { text: params.text } : {},
|
|
2074
|
+
...params.spPr !== void 0 ? { spPr: params.spPr } : {},
|
|
2075
|
+
...params.txPr !== void 0 ? { txPr: params.txPr } : {}
|
|
2076
|
+
});
|
|
2077
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2078
|
+
}
|
|
2079
|
+
function formatChartSeries(ctx, params) {
|
|
2080
|
+
const chart = findChartElement(ctx, params.slideIndex, params.elementId);
|
|
2081
|
+
if (params.marker !== void 0) {
|
|
2082
|
+
if (params.marker === null) {
|
|
2083
|
+
setChartSeriesMarker(chart, params.seriesIndex, null);
|
|
2084
|
+
} else if (params.marker.strokeColor !== void 0 || params.marker.strokeWidth !== void 0 || params.marker.strokeDashStyle !== void 0) {
|
|
2085
|
+
setChartSeriesMarker(chart, params.seriesIndex, {
|
|
2086
|
+
symbol: params.marker.symbol ?? "circle",
|
|
2087
|
+
...params.marker.size !== void 0 ? { size: params.marker.size } : {},
|
|
2088
|
+
spPr: {
|
|
2089
|
+
...params.marker.fillColor !== void 0 ? { fillColor: params.marker.fillColor } : {},
|
|
2090
|
+
...params.marker.strokeColor !== void 0 ? { strokeColor: params.marker.strokeColor } : {},
|
|
2091
|
+
...params.marker.strokeWidth !== void 0 ? { strokeWidth: params.marker.strokeWidth } : {},
|
|
2092
|
+
...params.marker.strokeDashStyle !== void 0 ? { strokeDashStyle: params.marker.strokeDashStyle } : {}
|
|
2093
|
+
}
|
|
2094
|
+
});
|
|
2095
|
+
} else {
|
|
2096
|
+
setChartSeriesMarker(chart, params.seriesIndex, params.marker);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
if (params.trendline !== void 0) {
|
|
2100
|
+
setChartSeriesTrendline(chart, params.seriesIndex, params.trendline);
|
|
2101
|
+
}
|
|
2102
|
+
if (params.errorBars !== void 0) {
|
|
2103
|
+
setChartSeriesErrorBars(chart, params.seriesIndex, params.errorBars);
|
|
2104
|
+
}
|
|
2105
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2106
|
+
}
|
|
2107
|
+
function setChartHelperLineT(ctx, params) {
|
|
2108
|
+
const chart = findChartElement(ctx, params.slideIndex, params.elementId);
|
|
2109
|
+
setChartHelperLine(chart, params.line, params.style);
|
|
2110
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2111
|
+
}
|
|
2112
|
+
function setChartColorMapOverrideT(ctx, params) {
|
|
2113
|
+
const chart = findChartElement(ctx, params.slideIndex, params.elementId);
|
|
2114
|
+
setChartColorMapOverride(chart, params.overrides);
|
|
2115
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2116
|
+
}
|
|
2117
|
+
function findChartElement2(ctx, slideIndex, elementId) {
|
|
2118
|
+
const err = validateSlideIndex(slideIndex, ctx.pptxData.slides.length);
|
|
2119
|
+
if (err) {
|
|
2120
|
+
throw new Error(err);
|
|
2121
|
+
}
|
|
2122
|
+
const slide = ctx.pptxData.slides[slideIndex];
|
|
2123
|
+
const el = slide.elements.find((e) => e.id === elementId);
|
|
2124
|
+
if (!el) {
|
|
2125
|
+
throw new Error(`Element '${elementId}' not found on slide ${slideIndex}.`);
|
|
2126
|
+
}
|
|
2127
|
+
if (el.type !== "chart") {
|
|
2128
|
+
throw new Error(`Element '${elementId}' is not a chart.`);
|
|
2129
|
+
}
|
|
2130
|
+
return el;
|
|
2131
|
+
}
|
|
2132
|
+
function buildShape(input) {
|
|
2133
|
+
return {
|
|
2134
|
+
kind: input.kind ?? "sp",
|
|
2135
|
+
anchor: input.anchor ?? "rel",
|
|
2136
|
+
from: input.from,
|
|
2137
|
+
...input.to ? { to: input.to } : {},
|
|
2138
|
+
...input.ext ? { ext: input.ext } : {},
|
|
2139
|
+
...input.prst ? { prst: input.prst } : {},
|
|
2140
|
+
...input.fill ? { fill: input.fill } : {},
|
|
2141
|
+
...input.stroke ? { stroke: input.stroke } : {},
|
|
2142
|
+
...input.strokeWidth !== void 0 ? { strokeWidth: input.strokeWidth } : {},
|
|
2143
|
+
...input.text ? { paragraphs: [{ text: input.text, align: "ctr" }] } : {}
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
function listChartUserShapesT(ctx, params) {
|
|
2147
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
2148
|
+
return { pptxData: ctx.pptxData, dirty: false, result: { shapes: listChartUserShapes(chart) } };
|
|
2149
|
+
}
|
|
2150
|
+
function addChartUserShapeT(ctx, params) {
|
|
2151
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
2152
|
+
addChartUserShape(chart, buildShape(params.shape));
|
|
2153
|
+
const index = (chart.chartData?.userShapes?.length ?? 1) - 1;
|
|
2154
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId, index } };
|
|
2155
|
+
}
|
|
2156
|
+
function updateChartUserShapeT(ctx, params) {
|
|
2157
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
2158
|
+
const patch = {
|
|
2159
|
+
...params.patch.kind ? { kind: params.patch.kind } : {},
|
|
2160
|
+
...params.patch.anchor ? { anchor: params.patch.anchor } : {},
|
|
2161
|
+
...params.patch.from ? { from: params.patch.from } : {},
|
|
2162
|
+
...params.patch.to ? { to: params.patch.to } : {},
|
|
2163
|
+
...params.patch.ext ? { ext: params.patch.ext } : {},
|
|
2164
|
+
...params.patch.prst ? { prst: params.patch.prst } : {},
|
|
2165
|
+
...params.patch.fill ? { fill: params.patch.fill } : {},
|
|
2166
|
+
...params.patch.stroke ? { stroke: params.patch.stroke } : {},
|
|
2167
|
+
...params.patch.strokeWidth !== void 0 ? { strokeWidth: params.patch.strokeWidth } : {},
|
|
2168
|
+
...params.patch.text !== void 0 ? { paragraphs: [{ text: params.patch.text, align: "ctr" }] } : {}
|
|
2169
|
+
};
|
|
2170
|
+
updateChartUserShape(chart, params.index, patch);
|
|
2171
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2172
|
+
}
|
|
2173
|
+
function removeChartUserShapeT(ctx, params) {
|
|
2174
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
2175
|
+
removeChartUserShape(chart, params.index);
|
|
2176
|
+
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
2177
|
+
}
|
|
1850
2178
|
function extractNodes(data) {
|
|
1851
2179
|
if (!data.nodes) {
|
|
1852
2180
|
return [];
|
|
@@ -2587,4 +2915,4 @@ function applyLayout(ctx, params) {
|
|
|
2587
2915
|
};
|
|
2588
2916
|
}
|
|
2589
2917
|
|
|
2590
|
-
export { addChartSeriesT, addElement, addSlide, applyLayout, applyTemplateT, applyThemePreset, arrangeElements, batchUpdateElements, cloneElement, convertToMarkdown, createChart, deleteElements, deleteSlides, describeElement, diffPresentationsT, duplicateSlide, executeToolWithContext, exportSlideSvg, exportToJson, exportToSvg, extractSlideText, findPlaceholdersT, findText, generateElementId, generateSlideId, getLayouts, getMetadata, getPresentationProperties, getSlide, getThemeInfo, groupElements, importFromJson, loadPresentation, manageComments, manageHyperlinks, manageSections, manageSmartArt, manageTableStructure, mergePresentationT, removeChartSeriesT, renameElement, reorderSlides, repairPresentation, replaceGeometry, replaceText, runAccessibilityCheck, savePresentation, setCanvasSize, setElementAnimation, setElementLockT, setSlideTransition, ungroupElements, updateChart, updateChartSeriesData, updateElement, updateElementStyle, updateMetadata, updatePresentationProperties, updateSlideProperties, updateTableCells, updateThemeColors, updateThemeFonts, validatePresentation, validateSlideIndex };
|
|
2918
|
+
export { addChartSeriesT, addChartUserShapeT, addElement, addSlide, applyLayout, applyTemplateT, applyThemePreset, arrangeElements, assignTableStyle, batchUpdateElements, cloneElement, convertToMarkdown, createChart, createTableStyle, deleteElements, deleteSlides, deleteTableStyle, describeElement, diffPresentationsT, duplicateSlide, executeToolWithContext, exportSlideSvg, exportToJson, exportToSvg, extractSlideText, findPlaceholdersT, findText, formatChartDataLabel, formatChartDataPoint, formatChartSeries, generateElementId, generateSlideId, getLayouts, getMetadata, getPresentationProperties, getSlide, getThemeInfo, groupElements, importFromJson, listChartUserShapesT, loadPresentation, manageComments, manageHyperlinks, manageSections, manageSmartArt, manageTableStructure, mergePresentationT, removeChartSeriesT, removeChartUserShapeT, renameElement, reorderSlides, repairPresentation, replaceGeometry, replaceText, runAccessibilityCheck, savePresentation, setCanvasSize, setChartColorMapOverrideT, setChartHelperLineT, setElementAnimation, setElementLockT, setSlideTransition, setTableStyleSection, ungroupElements, updateChart, updateChartSeriesData, updateChartUserShapeT, updateElement, updateElementStyle, updateMetadata, updatePresentationProperties, updateSlideProperties, updateTableCells, updateThemeColors, updateThemeFonts, validatePresentation, validateSlideIndex };
|