pptx-viewer-mcp 2.4.1 → 2.5.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/dist/codec/index.d.ts +7 -7
- package/dist/codec/index.d.ts.map +1 -1
- package/dist/index.d.ts +174 -79
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +129 -0
- package/dist/index.mjs +125 -2
- package/dist/mcp/index.js +250 -0
- package/dist/mcp/index.mjs +251 -1
- package/dist/schemas/index.d.ts +115 -73
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +49 -0
- package/dist/schemas/index.mjs +44 -1
- package/package.json +8 -7
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/execution.ts","../src/tools/slide-tools.ts","../src/tools/helpers.ts","../src/tools/element-tools.ts","../src/tools/table-tools.ts","../src/tools/table-style-tools.ts","../src/tools/style-tools.ts","../src/tools/content-tools.ts","../src/tools/conversion-tools.ts","../src/tools/theme-tools.ts","../src/tools/chart-tools.ts","../src/tools/chart-formatting-tools.ts","../src/tools/chart-user-shape-tools.ts","../src/tools/smartart-tools.ts","../src/tools/merge-tools.ts","../src/tools/template-tools.ts","../src/tools/metadata-tools.ts","../src/tools/section-tools.ts","../src/tools/export-tools.ts","../src/tools/json-tools.ts","../src/tools/hyperlink-tools.ts","../src/tools/geometry-tools.ts","../src/tools/lock-tools.ts","../src/tools/validation-tools.ts","../src/tools/presentation-tools.ts","../src/tools/layout-tools.ts"],"mappings":";;;;;;;UAOiB;;EAEhB,UAAU;;EAEV,gBAAgB,iBAAiB,QAAQ;;EAEzC,gBAAgB,iBAAiB,QAAQ;;;;;;;;;;;UAYzB;;EAEhB;;EAEA;;;;;;UAOgB,WAAW;;EAE3B,UAAU;;EAEV,QAAQ;;EAER;;;;;;EAMA,cAAc;;;;;;UAWE;;EAEhB,QAAQ;IAAqB,MAAM;;;EAEnC,SAAS;IACR,QAAQ,MAAM,KAAM,OAAO,YAAY,kBAAkB;IACzD,UAAU,MAAM,MAAO,QAAQ;;;EAGhC,YAAY;;;;;;;UAQI;EAChB,SAAS,eAAe,QAAQ;EAChC,UAAU,cAAc,MAAM,aAAa;;;;;;UAO3B;EAChB,eACC,kBACA,OAAO,YACP;IAAW;IAAoB;;EAEhC,SAAS,mBAAmB;;;;;UAMZ;;EAEhB,YAAY;;EAEZ,gBAAgB;;EAEhB,SAAS;;EAET;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/execution.ts","../src/tools/slide-tools.ts","../src/tools/helpers.ts","../src/tools/element-tools.ts","../src/tools/table-tools.ts","../src/tools/table-style-tools.ts","../src/tools/style-tools.ts","../src/tools/content-tools.ts","../src/tools/conversion-tools.ts","../src/tools/theme-tools.ts","../src/tools/chart-tools.ts","../src/tools/chart-formatting-tools.ts","../src/tools/chart-user-shape-tools.ts","../src/tools/smartart-tools.ts","../src/tools/merge-tools.ts","../src/tools/template-tools.ts","../src/tools/metadata-tools.ts","../src/tools/section-tools.ts","../src/tools/export-tools.ts","../src/tools/json-tools.ts","../src/tools/hyperlink-tools.ts","../src/tools/geometry-tools.ts","../src/tools/lock-tools.ts","../src/tools/validation-tools.ts","../src/tools/presentation-tools.ts","../src/tools/layout-tools.ts","../src/tools/ole-tools.ts"],"mappings":";;;;;;;UAOiB;;EAEhB,UAAU;;EAEV,gBAAgB,iBAAiB,QAAQ;;EAEzC,gBAAgB,iBAAiB,QAAQ;;;;;;;;;;;UAYzB;;EAEhB;;EAEA;;;;;;UAOgB,WAAW;;EAE3B,UAAU;;EAEV,QAAQ;;EAER;;;;;;EAMA,cAAc;;;;;;UAWE;;EAEhB,QAAQ;IAAqB,MAAM;;;EAEnC,SAAS;IACR,QAAQ,MAAM,KAAM,OAAO,YAAY,kBAAkB;IACzD,UAAU,MAAM,MAAO,QAAQ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B,oBAAoB;;;UCpHtC;EAChB;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;;UAGgB;EAChB;EACA;;wBAGe,WACf,KAAK,aACL,QAAQ,mBACN,WAAW;UAmKG;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;EAOA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;wBAGe,cACf,KAAK,aACL,QAAQ,sBACN;EAAa;;UA6HC;EAChB;EACA;;EAEA;;wBAGe,cACf,KAAK,aACL,QAAQ,sBACN;EAAa;EAAmB;;UA4BlB;EAChB;EACA;;wBAGe,eACf,KAAK,aACL,QAAQ,uBACN;EAAa;;UA0BC;EAChB;EACA;EAEA;EACA;EAEA;EACA;;wBAGe,gBACf,KAAK,aACL,QAAQ,wBACN;EAAa;;UA6GC;EAChB;EACA;EACA;EACA;EACA;;UAGgB;EAChB;;wBAGe,aACf,KAAK,aACL,QAAQ,qBACN,WAAW;UA6CG;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGe,oBACf,KAAK,aACL,QAAQ,4BACN;EAAa;;UAsDC;EAChB;EACA;;UAGgB;EAChB;;wBAGe,cACf,KAAK,aACL,QAAQ,sBACN,WAAW;UAmCG;EAChB;EACA;;UAGgB;EAChB;;wBAGe,gBACf,KAAK,aACL,QAAQ,wBACN,WAAW;UA6CG;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;wBAGe,oBACf,KAAK,aACL,QAAQ,4BACN;EAAa;;;;UC/zBC;EAChB;EACA;EACA,OAAO;IAAQ;IAAa;IAAa;;;wBAG1B,iBACf,KAAK,aACL,QAAQ,yBACN;EAAa;;UA6CC;EAChB;EACA;EACA;EACA;EACA;EACA;;wBAGe,qBACf,KAA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QAAQ,uBACN,QAAQ,WAAW"}
|
package/dist/index.js
CHANGED
|
@@ -2953,6 +2953,129 @@ function applyLayout(ctx, params) {
|
|
|
2953
2953
|
result: { slideIndex: params.slideIndex, layoutName: layout.name ?? "Unknown" }
|
|
2954
2954
|
};
|
|
2955
2955
|
}
|
|
2956
|
+
function resolveOleElement(ctx, slideIndex, elementId) {
|
|
2957
|
+
const err = validateSlideIndex(slideIndex, ctx.pptxData.slides.length);
|
|
2958
|
+
if (err) {
|
|
2959
|
+
throw new Error(err);
|
|
2960
|
+
}
|
|
2961
|
+
const slide = ctx.pptxData.slides[slideIndex];
|
|
2962
|
+
const index = slide.elements.findIndex((e) => e.id === elementId);
|
|
2963
|
+
if (index === -1) {
|
|
2964
|
+
throw new Error(`Element '${elementId}' not found on slide ${slideIndex}.`);
|
|
2965
|
+
}
|
|
2966
|
+
const element = slide.elements[index];
|
|
2967
|
+
if (element.type !== "ole") {
|
|
2968
|
+
throw new Error(`Element '${elementId}' is not an OLE object.`);
|
|
2969
|
+
}
|
|
2970
|
+
return { slide, element, index };
|
|
2971
|
+
}
|
|
2972
|
+
function commitOleElement(slide, index, updated) {
|
|
2973
|
+
slide.elements.splice(index, 1, updated);
|
|
2974
|
+
slide.isDirty = true;
|
|
2975
|
+
}
|
|
2976
|
+
async function getOleContent(ctx, params) {
|
|
2977
|
+
const { element } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2978
|
+
const kind = await pptxViewerCore.resolveOleEditorKindFromPayload(element);
|
|
2979
|
+
const base = { pptxData: ctx.pptxData, dirty: false };
|
|
2980
|
+
switch (kind) {
|
|
2981
|
+
case "sheet-xlsx":
|
|
2982
|
+
case "sheet-xls": {
|
|
2983
|
+
const sheet = await pptxViewerCore.getOleSheetGrid(element);
|
|
2984
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, sheet } };
|
|
2985
|
+
}
|
|
2986
|
+
case "document-docx":
|
|
2987
|
+
case "document-doc": {
|
|
2988
|
+
const paragraphs = await pptxViewerCore.getOleDocumentParagraphs(element);
|
|
2989
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, paragraphs } };
|
|
2990
|
+
}
|
|
2991
|
+
case "deck-pptx": {
|
|
2992
|
+
const deckSlides = await pptxViewerCore.getOleNestedDeckDetail(element);
|
|
2993
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, deckSlides } };
|
|
2994
|
+
}
|
|
2995
|
+
default:
|
|
2996
|
+
return {
|
|
2997
|
+
...base,
|
|
2998
|
+
result: {
|
|
2999
|
+
elementId: element.id,
|
|
3000
|
+
kind,
|
|
3001
|
+
editable: false,
|
|
3002
|
+
message: `This OLE object's content (${kind}) is not directly editable; use ole_replace_file to replace it wholesale.`
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
async function setOleSheetCell(ctx, params) {
|
|
3008
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3009
|
+
const updated = await pptxViewerCore.applyOleSheetCellEdit(element, {
|
|
3010
|
+
row: params.row,
|
|
3011
|
+
col: params.col,
|
|
3012
|
+
value: params.value
|
|
3013
|
+
});
|
|
3014
|
+
const changed = updated !== element;
|
|
3015
|
+
if (changed) {
|
|
3016
|
+
commitOleElement(slide, index, updated);
|
|
3017
|
+
}
|
|
3018
|
+
return {
|
|
3019
|
+
pptxData: ctx.pptxData,
|
|
3020
|
+
dirty: changed,
|
|
3021
|
+
result: { elementId: params.elementId, changed }
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
async function setOleDocumentParagraph(ctx, params) {
|
|
3025
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3026
|
+
const updated = await pptxViewerCore.applyOleDocumentParagraphEdit(element, params.paragraphIndex, params.text);
|
|
3027
|
+
const changed = updated !== element;
|
|
3028
|
+
if (changed) {
|
|
3029
|
+
commitOleElement(slide, index, updated);
|
|
3030
|
+
}
|
|
3031
|
+
return {
|
|
3032
|
+
pptxData: ctx.pptxData,
|
|
3033
|
+
dirty: changed,
|
|
3034
|
+
result: { elementId: params.elementId, changed }
|
|
3035
|
+
};
|
|
3036
|
+
}
|
|
3037
|
+
async function setOleDeckSlideTitle(ctx, params) {
|
|
3038
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3039
|
+
const updated = await pptxViewerCore.applyOleNestedDeckElementTextEdit(
|
|
3040
|
+
element,
|
|
3041
|
+
params.deckSlideIndex,
|
|
3042
|
+
params.deckElementId,
|
|
3043
|
+
params.title
|
|
3044
|
+
);
|
|
3045
|
+
const changed = updated !== element;
|
|
3046
|
+
if (changed) {
|
|
3047
|
+
commitOleElement(slide, index, updated);
|
|
3048
|
+
}
|
|
3049
|
+
return {
|
|
3050
|
+
pptxData: ctx.pptxData,
|
|
3051
|
+
dirty: changed,
|
|
3052
|
+
result: { elementId: params.elementId, changed }
|
|
3053
|
+
};
|
|
3054
|
+
}
|
|
3055
|
+
async function setOleObjectNameT(ctx, params) {
|
|
3056
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3057
|
+
const updated = await pptxViewerCore.setOleObjectName(element, params.name);
|
|
3058
|
+
commitOleElement(slide, index, updated);
|
|
3059
|
+
return {
|
|
3060
|
+
pptxData: ctx.pptxData,
|
|
3061
|
+
dirty: true,
|
|
3062
|
+
result: { elementId: params.elementId, changed: true }
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
async function replaceOleFileT(ctx, params) {
|
|
3066
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3067
|
+
const parsed = pptxViewerCore.parseDataUrlToBytes(params.fileData);
|
|
3068
|
+
if (!parsed) {
|
|
3069
|
+
throw new Error('fileData must be a base64 data URL, e.g. "data:<mime-type>;base64,<...>".');
|
|
3070
|
+
}
|
|
3071
|
+
const updated = await pptxViewerCore.replaceOleFile(element, parsed.bytes, params.fileName);
|
|
3072
|
+
commitOleElement(slide, index, updated);
|
|
3073
|
+
return {
|
|
3074
|
+
pptxData: ctx.pptxData,
|
|
3075
|
+
dirty: true,
|
|
3076
|
+
result: { elementId: params.elementId, changed: true }
|
|
3077
|
+
};
|
|
3078
|
+
}
|
|
2956
3079
|
|
|
2957
3080
|
Object.defineProperty(exports, "PptxHandler", {
|
|
2958
3081
|
enumerable: true,
|
|
@@ -2992,6 +3115,7 @@ exports.generateElementId = generateElementId;
|
|
|
2992
3115
|
exports.generateSlideId = generateSlideId;
|
|
2993
3116
|
exports.getLayouts = getLayouts;
|
|
2994
3117
|
exports.getMetadata = getMetadata;
|
|
3118
|
+
exports.getOleContent = getOleContent;
|
|
2995
3119
|
exports.getPresentationProperties = getPresentationProperties;
|
|
2996
3120
|
exports.getSlide = getSlide;
|
|
2997
3121
|
exports.getThemeInfo = getThemeInfo;
|
|
@@ -3011,6 +3135,7 @@ exports.renameElement = renameElement;
|
|
|
3011
3135
|
exports.reorderSlides = reorderSlides;
|
|
3012
3136
|
exports.repairPresentation = repairPresentation;
|
|
3013
3137
|
exports.replaceGeometry = replaceGeometry;
|
|
3138
|
+
exports.replaceOleFileT = replaceOleFileT;
|
|
3014
3139
|
exports.replaceText = replaceText;
|
|
3015
3140
|
exports.runAccessibilityCheck = runAccessibilityCheck;
|
|
3016
3141
|
exports.savePresentation = savePresentation;
|
|
@@ -3019,6 +3144,10 @@ exports.setChartColorMapOverrideT = setChartColorMapOverrideT;
|
|
|
3019
3144
|
exports.setChartHelperLineT = setChartHelperLineT;
|
|
3020
3145
|
exports.setElementAnimation = setElementAnimation;
|
|
3021
3146
|
exports.setElementLockT = setElementLockT;
|
|
3147
|
+
exports.setOleDeckSlideTitle = setOleDeckSlideTitle;
|
|
3148
|
+
exports.setOleDocumentParagraph = setOleDocumentParagraph;
|
|
3149
|
+
exports.setOleObjectNameT = setOleObjectNameT;
|
|
3150
|
+
exports.setOleSheetCell = setOleSheetCell;
|
|
3022
3151
|
exports.setSlideTransition = setSlideTransition;
|
|
3023
3152
|
exports.setTableStyleSection = setTableStyleSection;
|
|
3024
3153
|
exports.ungroupElements = ungroupElements;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PptxHandler, hasTextProperties, resolveDisplayedChartTypeName, 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';
|
|
1
|
+
import { PptxHandler, hasTextProperties, resolveDisplayedChartTypeName, 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, resolveOleEditorKindFromPayload, getOleNestedDeckDetail, getOleDocumentParagraphs, getOleSheetGrid, applyOleSheetCellEdit, applyOleDocumentParagraphEdit, applyOleNestedDeckElementTextEdit, setOleObjectName, parseDataUrlToBytes, replaceOleFile } from 'pptx-viewer-core';
|
|
2
2
|
export { PptxHandler } from 'pptx-viewer-core';
|
|
3
3
|
|
|
4
4
|
// src/execution.ts
|
|
@@ -2952,5 +2952,128 @@ function applyLayout(ctx, params) {
|
|
|
2952
2952
|
result: { slideIndex: params.slideIndex, layoutName: layout.name ?? "Unknown" }
|
|
2953
2953
|
};
|
|
2954
2954
|
}
|
|
2955
|
+
function resolveOleElement(ctx, slideIndex, elementId) {
|
|
2956
|
+
const err = validateSlideIndex(slideIndex, ctx.pptxData.slides.length);
|
|
2957
|
+
if (err) {
|
|
2958
|
+
throw new Error(err);
|
|
2959
|
+
}
|
|
2960
|
+
const slide = ctx.pptxData.slides[slideIndex];
|
|
2961
|
+
const index = slide.elements.findIndex((e) => e.id === elementId);
|
|
2962
|
+
if (index === -1) {
|
|
2963
|
+
throw new Error(`Element '${elementId}' not found on slide ${slideIndex}.`);
|
|
2964
|
+
}
|
|
2965
|
+
const element = slide.elements[index];
|
|
2966
|
+
if (element.type !== "ole") {
|
|
2967
|
+
throw new Error(`Element '${elementId}' is not an OLE object.`);
|
|
2968
|
+
}
|
|
2969
|
+
return { slide, element, index };
|
|
2970
|
+
}
|
|
2971
|
+
function commitOleElement(slide, index, updated) {
|
|
2972
|
+
slide.elements.splice(index, 1, updated);
|
|
2973
|
+
slide.isDirty = true;
|
|
2974
|
+
}
|
|
2975
|
+
async function getOleContent(ctx, params) {
|
|
2976
|
+
const { element } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2977
|
+
const kind = await resolveOleEditorKindFromPayload(element);
|
|
2978
|
+
const base = { pptxData: ctx.pptxData, dirty: false };
|
|
2979
|
+
switch (kind) {
|
|
2980
|
+
case "sheet-xlsx":
|
|
2981
|
+
case "sheet-xls": {
|
|
2982
|
+
const sheet = await getOleSheetGrid(element);
|
|
2983
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, sheet } };
|
|
2984
|
+
}
|
|
2985
|
+
case "document-docx":
|
|
2986
|
+
case "document-doc": {
|
|
2987
|
+
const paragraphs = await getOleDocumentParagraphs(element);
|
|
2988
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, paragraphs } };
|
|
2989
|
+
}
|
|
2990
|
+
case "deck-pptx": {
|
|
2991
|
+
const deckSlides = await getOleNestedDeckDetail(element);
|
|
2992
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, deckSlides } };
|
|
2993
|
+
}
|
|
2994
|
+
default:
|
|
2995
|
+
return {
|
|
2996
|
+
...base,
|
|
2997
|
+
result: {
|
|
2998
|
+
elementId: element.id,
|
|
2999
|
+
kind,
|
|
3000
|
+
editable: false,
|
|
3001
|
+
message: `This OLE object's content (${kind}) is not directly editable; use ole_replace_file to replace it wholesale.`
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
async function setOleSheetCell(ctx, params) {
|
|
3007
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3008
|
+
const updated = await applyOleSheetCellEdit(element, {
|
|
3009
|
+
row: params.row,
|
|
3010
|
+
col: params.col,
|
|
3011
|
+
value: params.value
|
|
3012
|
+
});
|
|
3013
|
+
const changed = updated !== element;
|
|
3014
|
+
if (changed) {
|
|
3015
|
+
commitOleElement(slide, index, updated);
|
|
3016
|
+
}
|
|
3017
|
+
return {
|
|
3018
|
+
pptxData: ctx.pptxData,
|
|
3019
|
+
dirty: changed,
|
|
3020
|
+
result: { elementId: params.elementId, changed }
|
|
3021
|
+
};
|
|
3022
|
+
}
|
|
3023
|
+
async function setOleDocumentParagraph(ctx, params) {
|
|
3024
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3025
|
+
const updated = await applyOleDocumentParagraphEdit(element, params.paragraphIndex, params.text);
|
|
3026
|
+
const changed = updated !== element;
|
|
3027
|
+
if (changed) {
|
|
3028
|
+
commitOleElement(slide, index, updated);
|
|
3029
|
+
}
|
|
3030
|
+
return {
|
|
3031
|
+
pptxData: ctx.pptxData,
|
|
3032
|
+
dirty: changed,
|
|
3033
|
+
result: { elementId: params.elementId, changed }
|
|
3034
|
+
};
|
|
3035
|
+
}
|
|
3036
|
+
async function setOleDeckSlideTitle(ctx, params) {
|
|
3037
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3038
|
+
const updated = await applyOleNestedDeckElementTextEdit(
|
|
3039
|
+
element,
|
|
3040
|
+
params.deckSlideIndex,
|
|
3041
|
+
params.deckElementId,
|
|
3042
|
+
params.title
|
|
3043
|
+
);
|
|
3044
|
+
const changed = updated !== element;
|
|
3045
|
+
if (changed) {
|
|
3046
|
+
commitOleElement(slide, index, updated);
|
|
3047
|
+
}
|
|
3048
|
+
return {
|
|
3049
|
+
pptxData: ctx.pptxData,
|
|
3050
|
+
dirty: changed,
|
|
3051
|
+
result: { elementId: params.elementId, changed }
|
|
3052
|
+
};
|
|
3053
|
+
}
|
|
3054
|
+
async function setOleObjectNameT(ctx, params) {
|
|
3055
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3056
|
+
const updated = await setOleObjectName(element, params.name);
|
|
3057
|
+
commitOleElement(slide, index, updated);
|
|
3058
|
+
return {
|
|
3059
|
+
pptxData: ctx.pptxData,
|
|
3060
|
+
dirty: true,
|
|
3061
|
+
result: { elementId: params.elementId, changed: true }
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
async function replaceOleFileT(ctx, params) {
|
|
3065
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3066
|
+
const parsed = parseDataUrlToBytes(params.fileData);
|
|
3067
|
+
if (!parsed) {
|
|
3068
|
+
throw new Error('fileData must be a base64 data URL, e.g. "data:<mime-type>;base64,<...>".');
|
|
3069
|
+
}
|
|
3070
|
+
const updated = await replaceOleFile(element, parsed.bytes, params.fileName);
|
|
3071
|
+
commitOleElement(slide, index, updated);
|
|
3072
|
+
return {
|
|
3073
|
+
pptxData: ctx.pptxData,
|
|
3074
|
+
dirty: true,
|
|
3075
|
+
result: { elementId: params.elementId, changed: true }
|
|
3076
|
+
};
|
|
3077
|
+
}
|
|
2955
3078
|
|
|
2956
|
-
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 };
|
|
3079
|
+
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, getOleContent, getPresentationProperties, getSlide, getThemeInfo, groupElements, importFromJson, listChartUserShapesT, loadPresentation, manageComments, manageHyperlinks, manageSections, manageSmartArt, manageTableStructure, mergePresentationT, removeChartSeriesT, removeChartUserShapeT, renameElement, reorderSlides, repairPresentation, replaceGeometry, replaceOleFileT, replaceText, runAccessibilityCheck, savePresentation, setCanvasSize, setChartColorMapOverrideT, setChartHelperLineT, setElementAnimation, setElementLockT, setOleDeckSlideTitle, setOleDocumentParagraph, setOleObjectNameT, setOleSheetCell, setSlideTransition, setTableStyleSection, ungroupElements, updateChart, updateChartSeriesData, updateChartUserShapeT, updateElement, updateElementStyle, updateMetadata, updatePresentationProperties, updateSlideProperties, updateTableCells, updateThemeColors, updateThemeFonts, validatePresentation, validateSlideIndex };
|
package/dist/mcp/index.js
CHANGED
|
@@ -881,6 +881,49 @@ var ApplyLayoutSchema = zod.z.object({
|
|
|
881
881
|
layoutName: zod.z.string().optional().describe("Layout name to apply"),
|
|
882
882
|
layoutType: zod.z.string().optional().describe("Layout type to apply (alternative to name)")
|
|
883
883
|
});
|
|
884
|
+
var GetOleContentSchema = zod.z.object({
|
|
885
|
+
filePath: zod.z.string().describe("Path to the PPTX file"),
|
|
886
|
+
slideIndex: zod.z.number().int().min(0).describe("Zero-based slide index"),
|
|
887
|
+
elementId: zod.z.string().describe("OLE element ID")
|
|
888
|
+
});
|
|
889
|
+
var SetOleSheetCellSchema = zod.z.object({
|
|
890
|
+
filePath: zod.z.string().describe("Path to the PPTX file"),
|
|
891
|
+
slideIndex: zod.z.number().int().min(0).describe("Zero-based slide index"),
|
|
892
|
+
elementId: zod.z.string().describe("OLE element ID (Excel payload: .xlsx or .xls)"),
|
|
893
|
+
row: zod.z.number().int().min(0).describe("Zero-based row index on the first worksheet"),
|
|
894
|
+
col: zod.z.number().int().min(0).describe("Zero-based column index on the first worksheet"),
|
|
895
|
+
value: zod.z.string().describe("New cell value")
|
|
896
|
+
});
|
|
897
|
+
var SetOleDocumentParagraphSchema = zod.z.object({
|
|
898
|
+
filePath: zod.z.string().describe("Path to the PPTX file"),
|
|
899
|
+
slideIndex: zod.z.number().int().min(0).describe("Zero-based slide index"),
|
|
900
|
+
elementId: zod.z.string().describe("OLE element ID (Word payload: .docx)"),
|
|
901
|
+
paragraphIndex: zod.z.number().int().min(0).describe("Zero-based paragraph index"),
|
|
902
|
+
text: zod.z.string().describe("New paragraph text")
|
|
903
|
+
});
|
|
904
|
+
var SetOleDeckSlideTitleSchema = zod.z.object({
|
|
905
|
+
filePath: zod.z.string().describe("Path to the PPTX file"),
|
|
906
|
+
slideIndex: zod.z.number().int().min(0).describe("Zero-based slide index"),
|
|
907
|
+
elementId: zod.z.string().describe("OLE element ID (nested-deck payload: .pptx)"),
|
|
908
|
+
deckSlideIndex: zod.z.number().int().min(0).describe("Zero-based slide index within the nested deck"),
|
|
909
|
+
deckElementId: zod.z.string().describe(
|
|
910
|
+
"ID of the text-bearing shape to edit within the nested slide, from ole_get_content's deckSlides[n].elements[i].elementId"
|
|
911
|
+
),
|
|
912
|
+
title: zod.z.string().describe("New text for the chosen shape")
|
|
913
|
+
});
|
|
914
|
+
var ReplaceOleFileSchema = zod.z.object({
|
|
915
|
+
filePath: zod.z.string().describe("Path to the PPTX file"),
|
|
916
|
+
slideIndex: zod.z.number().int().min(0).describe("Zero-based slide index"),
|
|
917
|
+
elementId: zod.z.string().describe("OLE element ID"),
|
|
918
|
+
fileData: zod.z.string().describe('New payload as a base64 data URL (e.g. "data:application/pdf;base64,...")'),
|
|
919
|
+
fileName: zod.z.string().optional().describe("Optional new file name (also updates the resolved MIME type)")
|
|
920
|
+
});
|
|
921
|
+
var SetOleObjectNameSchema = zod.z.object({
|
|
922
|
+
filePath: zod.z.string().describe("Path to the PPTX file"),
|
|
923
|
+
slideIndex: zod.z.number().int().min(0).describe("Zero-based slide index"),
|
|
924
|
+
elementId: zod.z.string().describe("OLE element ID"),
|
|
925
|
+
name: zod.z.string().describe("New Object Name (p:oleObj/@name); blank/whitespace clears it")
|
|
926
|
+
});
|
|
884
927
|
function generateElementId() {
|
|
885
928
|
return `el-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
886
929
|
}
|
|
@@ -2849,6 +2892,129 @@ function updateMetadata(ctx, params) {
|
|
|
2849
2892
|
result: { updated }
|
|
2850
2893
|
};
|
|
2851
2894
|
}
|
|
2895
|
+
function resolveOleElement(ctx, slideIndex, elementId) {
|
|
2896
|
+
const err = validateSlideIndex(slideIndex, ctx.pptxData.slides.length);
|
|
2897
|
+
if (err) {
|
|
2898
|
+
throw new Error(err);
|
|
2899
|
+
}
|
|
2900
|
+
const slide = ctx.pptxData.slides[slideIndex];
|
|
2901
|
+
const index = slide.elements.findIndex((e) => e.id === elementId);
|
|
2902
|
+
if (index === -1) {
|
|
2903
|
+
throw new Error(`Element '${elementId}' not found on slide ${slideIndex}.`);
|
|
2904
|
+
}
|
|
2905
|
+
const element = slide.elements[index];
|
|
2906
|
+
if (element.type !== "ole") {
|
|
2907
|
+
throw new Error(`Element '${elementId}' is not an OLE object.`);
|
|
2908
|
+
}
|
|
2909
|
+
return { slide, element, index };
|
|
2910
|
+
}
|
|
2911
|
+
function commitOleElement(slide, index, updated) {
|
|
2912
|
+
slide.elements.splice(index, 1, updated);
|
|
2913
|
+
slide.isDirty = true;
|
|
2914
|
+
}
|
|
2915
|
+
async function getOleContent(ctx, params) {
|
|
2916
|
+
const { element } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2917
|
+
const kind = await pptxViewerCore.resolveOleEditorKindFromPayload(element);
|
|
2918
|
+
const base = { pptxData: ctx.pptxData, dirty: false };
|
|
2919
|
+
switch (kind) {
|
|
2920
|
+
case "sheet-xlsx":
|
|
2921
|
+
case "sheet-xls": {
|
|
2922
|
+
const sheet = await pptxViewerCore.getOleSheetGrid(element);
|
|
2923
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, sheet } };
|
|
2924
|
+
}
|
|
2925
|
+
case "document-docx":
|
|
2926
|
+
case "document-doc": {
|
|
2927
|
+
const paragraphs = await pptxViewerCore.getOleDocumentParagraphs(element);
|
|
2928
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, paragraphs } };
|
|
2929
|
+
}
|
|
2930
|
+
case "deck-pptx": {
|
|
2931
|
+
const deckSlides = await pptxViewerCore.getOleNestedDeckDetail(element);
|
|
2932
|
+
return { ...base, result: { elementId: element.id, kind, editable: true, deckSlides } };
|
|
2933
|
+
}
|
|
2934
|
+
default:
|
|
2935
|
+
return {
|
|
2936
|
+
...base,
|
|
2937
|
+
result: {
|
|
2938
|
+
elementId: element.id,
|
|
2939
|
+
kind,
|
|
2940
|
+
editable: false,
|
|
2941
|
+
message: `This OLE object's content (${kind}) is not directly editable; use ole_replace_file to replace it wholesale.`
|
|
2942
|
+
}
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
async function setOleSheetCell(ctx, params) {
|
|
2947
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2948
|
+
const updated = await pptxViewerCore.applyOleSheetCellEdit(element, {
|
|
2949
|
+
row: params.row,
|
|
2950
|
+
col: params.col,
|
|
2951
|
+
value: params.value
|
|
2952
|
+
});
|
|
2953
|
+
const changed = updated !== element;
|
|
2954
|
+
if (changed) {
|
|
2955
|
+
commitOleElement(slide, index, updated);
|
|
2956
|
+
}
|
|
2957
|
+
return {
|
|
2958
|
+
pptxData: ctx.pptxData,
|
|
2959
|
+
dirty: changed,
|
|
2960
|
+
result: { elementId: params.elementId, changed }
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
async function setOleDocumentParagraph(ctx, params) {
|
|
2964
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2965
|
+
const updated = await pptxViewerCore.applyOleDocumentParagraphEdit(element, params.paragraphIndex, params.text);
|
|
2966
|
+
const changed = updated !== element;
|
|
2967
|
+
if (changed) {
|
|
2968
|
+
commitOleElement(slide, index, updated);
|
|
2969
|
+
}
|
|
2970
|
+
return {
|
|
2971
|
+
pptxData: ctx.pptxData,
|
|
2972
|
+
dirty: changed,
|
|
2973
|
+
result: { elementId: params.elementId, changed }
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
async function setOleDeckSlideTitle(ctx, params) {
|
|
2977
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2978
|
+
const updated = await pptxViewerCore.applyOleNestedDeckElementTextEdit(
|
|
2979
|
+
element,
|
|
2980
|
+
params.deckSlideIndex,
|
|
2981
|
+
params.deckElementId,
|
|
2982
|
+
params.title
|
|
2983
|
+
);
|
|
2984
|
+
const changed = updated !== element;
|
|
2985
|
+
if (changed) {
|
|
2986
|
+
commitOleElement(slide, index, updated);
|
|
2987
|
+
}
|
|
2988
|
+
return {
|
|
2989
|
+
pptxData: ctx.pptxData,
|
|
2990
|
+
dirty: changed,
|
|
2991
|
+
result: { elementId: params.elementId, changed }
|
|
2992
|
+
};
|
|
2993
|
+
}
|
|
2994
|
+
async function setOleObjectNameT(ctx, params) {
|
|
2995
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
2996
|
+
const updated = await pptxViewerCore.setOleObjectName(element, params.name);
|
|
2997
|
+
commitOleElement(slide, index, updated);
|
|
2998
|
+
return {
|
|
2999
|
+
pptxData: ctx.pptxData,
|
|
3000
|
+
dirty: true,
|
|
3001
|
+
result: { elementId: params.elementId, changed: true }
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
async function replaceOleFileT(ctx, params) {
|
|
3005
|
+
const { slide, element, index } = resolveOleElement(ctx, params.slideIndex, params.elementId);
|
|
3006
|
+
const parsed = pptxViewerCore.parseDataUrlToBytes(params.fileData);
|
|
3007
|
+
if (!parsed) {
|
|
3008
|
+
throw new Error('fileData must be a base64 data URL, e.g. "data:<mime-type>;base64,<...>".');
|
|
3009
|
+
}
|
|
3010
|
+
const updated = await pptxViewerCore.replaceOleFile(element, parsed.bytes, params.fileName);
|
|
3011
|
+
commitOleElement(slide, index, updated);
|
|
3012
|
+
return {
|
|
3013
|
+
pptxData: ctx.pptxData,
|
|
3014
|
+
dirty: true,
|
|
3015
|
+
result: { elementId: params.elementId, changed: true }
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
2852
3018
|
|
|
2853
3019
|
// src/tools/presentation-tools.ts
|
|
2854
3020
|
function getPresentationProperties(ctx) {
|
|
@@ -4962,6 +5128,90 @@ function createServer() {
|
|
|
4962
5128
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
4963
5129
|
}
|
|
4964
5130
|
);
|
|
5131
|
+
server2.registerTool(
|
|
5132
|
+
"ole_get_content",
|
|
5133
|
+
{
|
|
5134
|
+
description: "Inspect an embedded OLE object's editable content: resolved kind, plus the sheet grid, paragraph list, or nested-deck slide summaries, whichever applies",
|
|
5135
|
+
inputSchema: GetOleContentSchema.shape
|
|
5136
|
+
},
|
|
5137
|
+
async (params) => {
|
|
5138
|
+
const result = await runMcpTool(
|
|
5139
|
+
params.filePath,
|
|
5140
|
+
(ctx) => getOleContent(ctx, params)
|
|
5141
|
+
);
|
|
5142
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
5143
|
+
}
|
|
5144
|
+
);
|
|
5145
|
+
server2.registerTool(
|
|
5146
|
+
"ole_set_sheet_cell",
|
|
5147
|
+
{
|
|
5148
|
+
description: "Edit one cell of an embedded Excel OLE object's first worksheet",
|
|
5149
|
+
inputSchema: SetOleSheetCellSchema.shape
|
|
5150
|
+
},
|
|
5151
|
+
async (params) => {
|
|
5152
|
+
const result = await runMcpTool(
|
|
5153
|
+
params.filePath,
|
|
5154
|
+
(ctx) => setOleSheetCell(ctx, params)
|
|
5155
|
+
);
|
|
5156
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
5157
|
+
}
|
|
5158
|
+
);
|
|
5159
|
+
server2.registerTool(
|
|
5160
|
+
"ole_set_document_paragraph",
|
|
5161
|
+
{
|
|
5162
|
+
description: "Replace one paragraph's text in an embedded Word (.docx or legacy .doc) OLE object",
|
|
5163
|
+
inputSchema: SetOleDocumentParagraphSchema.shape
|
|
5164
|
+
},
|
|
5165
|
+
async (params) => {
|
|
5166
|
+
const result = await runMcpTool(
|
|
5167
|
+
params.filePath,
|
|
5168
|
+
(ctx) => setOleDocumentParagraph(ctx, params)
|
|
5169
|
+
);
|
|
5170
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
5171
|
+
}
|
|
5172
|
+
);
|
|
5173
|
+
server2.registerTool(
|
|
5174
|
+
"ole_set_deck_slide_title",
|
|
5175
|
+
{
|
|
5176
|
+
description: "Edit one text-bearing shape on one slide of an embedded nested-deck (PowerPoint) OLE object, via a full load/save round-trip through the nested deck (call ole_get_content first to discover each slide's elementIds)",
|
|
5177
|
+
inputSchema: SetOleDeckSlideTitleSchema.shape
|
|
5178
|
+
},
|
|
5179
|
+
async (params) => {
|
|
5180
|
+
const result = await runMcpTool(
|
|
5181
|
+
params.filePath,
|
|
5182
|
+
(ctx) => setOleDeckSlideTitle(ctx, params)
|
|
5183
|
+
);
|
|
5184
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
5185
|
+
}
|
|
5186
|
+
);
|
|
5187
|
+
server2.registerTool(
|
|
5188
|
+
"ole_replace_file",
|
|
5189
|
+
{
|
|
5190
|
+
description: `Replace an embedded OLE object's payload wholesale with an arbitrary file; works for any OLE kind, including a generic "Package" object or an unsupported format`,
|
|
5191
|
+
inputSchema: ReplaceOleFileSchema.shape
|
|
5192
|
+
},
|
|
5193
|
+
async (params) => {
|
|
5194
|
+
const result = await runMcpTool(
|
|
5195
|
+
params.filePath,
|
|
5196
|
+
(ctx) => replaceOleFileT(ctx, params)
|
|
5197
|
+
);
|
|
5198
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
5199
|
+
}
|
|
5200
|
+
);
|
|
5201
|
+
server2.registerTool(
|
|
5202
|
+
"ole_set_object_name",
|
|
5203
|
+
{
|
|
5204
|
+
description: "Rename an OLE object's Object Name (p:oleObj/@name); regenerates the baked-in icon caption too when the object is displayed as an icon",
|
|
5205
|
+
inputSchema: SetOleObjectNameSchema.shape
|
|
5206
|
+
},
|
|
5207
|
+
async (params) => {
|
|
5208
|
+
const result = await runMcpTool(
|
|
5209
|
+
params.filePath,
|
|
5210
|
+
(ctx) => setOleObjectNameT(ctx, params)
|
|
5211
|
+
);
|
|
5212
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
5213
|
+
}
|
|
5214
|
+
);
|
|
4965
5215
|
return server2;
|
|
4966
5216
|
}
|
|
4967
5217
|
|