pptx-viewer-mcp 2.2.0 → 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 +6 -0
- package/README.md +20 -19
- package/dist/index.d.ts +221 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +286 -10
- package/dist/index.mjs +279 -12
- package/dist/mcp/index.js +758 -44
- package/dist/mcp/index.mjs +759 -45
- package/dist/schemas/index.d.ts +601 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +325 -0
- package/dist/schemas/index.mjs +312 -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, 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';
|
|
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;
|
|
@@ -1862,6 +2037,98 @@ function findChartElement(ctx, slideIndex, elementId) {
|
|
|
1862
2037
|
}
|
|
1863
2038
|
return el;
|
|
1864
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
|
+
}
|
|
1865
2132
|
function buildShape(input) {
|
|
1866
2133
|
return {
|
|
1867
2134
|
kind: input.kind ?? "sp",
|
|
@@ -1877,17 +2144,17 @@ function buildShape(input) {
|
|
|
1877
2144
|
};
|
|
1878
2145
|
}
|
|
1879
2146
|
function listChartUserShapesT(ctx, params) {
|
|
1880
|
-
const chart =
|
|
2147
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
1881
2148
|
return { pptxData: ctx.pptxData, dirty: false, result: { shapes: listChartUserShapes(chart) } };
|
|
1882
2149
|
}
|
|
1883
2150
|
function addChartUserShapeT(ctx, params) {
|
|
1884
|
-
const chart =
|
|
2151
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
1885
2152
|
addChartUserShape(chart, buildShape(params.shape));
|
|
1886
2153
|
const index = (chart.chartData?.userShapes?.length ?? 1) - 1;
|
|
1887
2154
|
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId, index } };
|
|
1888
2155
|
}
|
|
1889
2156
|
function updateChartUserShapeT(ctx, params) {
|
|
1890
|
-
const chart =
|
|
2157
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
1891
2158
|
const patch = {
|
|
1892
2159
|
...params.patch.kind ? { kind: params.patch.kind } : {},
|
|
1893
2160
|
...params.patch.anchor ? { anchor: params.patch.anchor } : {},
|
|
@@ -1904,7 +2171,7 @@ function updateChartUserShapeT(ctx, params) {
|
|
|
1904
2171
|
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
1905
2172
|
}
|
|
1906
2173
|
function removeChartUserShapeT(ctx, params) {
|
|
1907
|
-
const chart =
|
|
2174
|
+
const chart = findChartElement2(ctx, params.slideIndex, params.elementId);
|
|
1908
2175
|
removeChartUserShape(chart, params.index);
|
|
1909
2176
|
return { pptxData: ctx.pptxData, dirty: true, result: { elementId: params.elementId } };
|
|
1910
2177
|
}
|
|
@@ -2648,4 +2915,4 @@ function applyLayout(ctx, params) {
|
|
|
2648
2915
|
};
|
|
2649
2916
|
}
|
|
2650
2917
|
|
|
2651
|
-
export { addChartSeriesT, addChartUserShapeT, 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, listChartUserShapesT, loadPresentation, manageComments, manageHyperlinks, manageSections, manageSmartArt, manageTableStructure, mergePresentationT, removeChartSeriesT, removeChartUserShapeT, renameElement, reorderSlides, repairPresentation, replaceGeometry, replaceText, runAccessibilityCheck, savePresentation, setCanvasSize, setElementAnimation, setElementLockT, setSlideTransition, ungroupElements, updateChart, updateChartSeriesData, updateChartUserShapeT, 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 };
|