wps-multitool-mcp 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bridge/cancellable.d.ts.map +1 -1
- package/dist/bridge/cancellable.js +2 -0
- package/dist/bridge/cancellable.js.map +1 -1
- package/dist/bridge/index.js +36 -1
- package/dist/bridge/index.js.map +1 -1
- package/dist/client/action-routes.generated.d.ts +2 -2
- package/dist/client/action-routes.generated.d.ts.map +1 -1
- package/dist/client/action-routes.generated.js +8 -2
- package/dist/client/action-routes.generated.js.map +1 -1
- package/dist/server/auto-snapshot.d.ts.map +1 -1
- package/dist/server/auto-snapshot.js +12 -1
- package/dist/server/auto-snapshot.js.map +1 -1
- package/dist/server/collab-guard.d.ts +13 -0
- package/dist/server/collab-guard.d.ts.map +1 -0
- package/dist/server/collab-guard.js +112 -0
- package/dist/server/collab-guard.js.map +1 -0
- package/dist/server/intent-miss-log.d.ts +28 -0
- package/dist/server/intent-miss-log.d.ts.map +1 -0
- package/dist/server/intent-miss-log.js +143 -0
- package/dist/server/intent-miss-log.js.map +1 -0
- package/dist/server/mcp-server.d.ts +9 -0
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +168 -4
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/progress-context.d.ts +6 -0
- package/dist/server/progress-context.d.ts.map +1 -0
- package/dist/server/progress-context.js +35 -0
- package/dist/server/progress-context.js.map +1 -0
- package/dist/server/task-engine.d.ts +112 -0
- package/dist/server/task-engine.d.ts.map +1 -0
- package/dist/server/task-engine.js +305 -0
- package/dist/server/task-engine.js.map +1 -0
- package/dist/server/tool-aliases.generated.d.ts +1 -1
- package/dist/server/tool-aliases.generated.d.ts.map +1 -1
- package/dist/server/tool-aliases.generated.js +15 -2
- package/dist/server/tool-aliases.generated.js.map +1 -1
- package/dist/server/tool-annotations.d.ts.map +1 -1
- package/dist/server/tool-annotations.generated.d.ts.map +1 -1
- package/dist/server/tool-annotations.generated.js +7 -8
- package/dist/server/tool-annotations.generated.js.map +1 -1
- package/dist/server/tool-annotations.js +18 -0
- package/dist/server/tool-annotations.js.map +1 -1
- package/dist/server/tool-metadata.d.ts.map +1 -1
- package/dist/server/tool-metadata.js +21 -9
- package/dist/server/tool-metadata.js.map +1 -1
- package/dist/server/tool-registry.d.ts.map +1 -1
- package/dist/server/tool-registry.js +26 -1
- package/dist/server/tool-registry.js.map +1 -1
- package/dist/server/tool-tiers.d.ts +2 -2
- package/dist/server/tool-tiers.js +2 -2
- package/dist/server/tool-verification.d.ts +5 -5
- package/dist/server/tool-verification.generated.d.ts +4 -4
- package/dist/server/tool-verification.generated.d.ts.map +1 -1
- package/dist/server/tool-verification.generated.js +78 -79
- package/dist/server/tool-verification.generated.js.map +1 -1
- package/dist/server/tool-verification.js +2 -2
- package/dist/tools/common/batch.d.ts.map +1 -1
- package/dist/tools/common/batch.js +5 -0
- package/dist/tools/common/batch.js.map +1 -1
- package/dist/tools/common/convert.js +34 -34
- package/dist/tools/common/general.d.ts.map +1 -1
- package/dist/tools/common/general.js +81 -79
- package/dist/tools/common/general.js.map +1 -1
- package/dist/tools/common/index.d.ts +1 -0
- package/dist/tools/common/index.d.ts.map +1 -1
- package/dist/tools/common/index.js +3 -0
- package/dist/tools/common/index.js.map +1 -1
- package/dist/tools/common/intent.d.ts +42 -0
- package/dist/tools/common/intent.d.ts.map +1 -1
- package/dist/tools/common/intent.js +307 -19
- package/dist/tools/common/intent.js.map +1 -1
- package/dist/tools/common/snapshot.d.ts.map +1 -1
- package/dist/tools/common/snapshot.js +27 -19
- package/dist/tools/common/snapshot.js.map +1 -1
- package/dist/tools/common/taskrunner.d.ts +25 -0
- package/dist/tools/common/taskrunner.d.ts.map +1 -0
- package/dist/tools/common/taskrunner.js +100 -0
- package/dist/tools/common/taskrunner.js.map +1 -0
- package/dist/tools/common/toolgroups.js +36 -36
- package/dist/tools/excel/chart.d.ts.map +1 -1
- package/dist/tools/excel/chart.js +109 -86
- package/dist/tools/excel/chart.js.map +1 -1
- package/dist/tools/excel/comment-protect.js +2 -2
- package/dist/tools/excel/comment-protect.js.map +1 -1
- package/dist/tools/excel/data.d.ts.map +1 -1
- package/dist/tools/excel/data.js +32 -21
- package/dist/tools/excel/data.js.map +1 -1
- package/dist/tools/excel/format.js +9 -9
- package/dist/tools/excel/formula.js +46 -46
- package/dist/tools/excel/pivot.js +34 -34
- package/dist/tools/excel/sheet.d.ts +4 -0
- package/dist/tools/excel/sheet.d.ts.map +1 -1
- package/dist/tools/excel/sheet.js +103 -1
- package/dist/tools/excel/sheet.js.map +1 -1
- package/dist/tools/ppt/animation.d.ts +2 -2
- package/dist/tools/ppt/animation.d.ts.map +1 -1
- package/dist/tools/ppt/animation.js +35 -97
- package/dist/tools/ppt/animation.js.map +1 -1
- package/dist/tools/ppt/beautify-advanced.d.ts +3 -16
- package/dist/tools/ppt/beautify-advanced.d.ts.map +1 -1
- package/dist/tools/ppt/beautify-advanced.js +65 -355
- package/dist/tools/ppt/beautify-advanced.js.map +1 -1
- package/dist/tools/ppt/chart-flow.d.ts.map +1 -1
- package/dist/tools/ppt/chart-flow.js +113 -278
- package/dist/tools/ppt/chart-flow.js.map +1 -1
- package/dist/tools/ppt/data-viz.d.ts.map +1 -1
- package/dist/tools/ppt/data-viz.js +78 -276
- package/dist/tools/ppt/data-viz.js.map +1 -1
- package/dist/tools/ppt/deckkit.d.ts +209 -0
- package/dist/tools/ppt/deckkit.d.ts.map +1 -0
- package/dist/tools/ppt/deckkit.js +635 -0
- package/dist/tools/ppt/deckkit.js.map +1 -0
- package/dist/tools/ppt/helpers.d.ts +38 -0
- package/dist/tools/ppt/helpers.d.ts.map +1 -0
- package/dist/tools/ppt/helpers.js +60 -0
- package/dist/tools/ppt/helpers.js.map +1 -0
- package/dist/tools/ppt/image.d.ts +6 -4
- package/dist/tools/ppt/image.d.ts.map +1 -1
- package/dist/tools/ppt/image.js +148 -244
- package/dist/tools/ppt/image.js.map +1 -1
- package/dist/tools/ppt/index.d.ts +43 -29
- package/dist/tools/ppt/index.d.ts.map +1 -1
- package/dist/tools/ppt/index.js +106 -95
- package/dist/tools/ppt/index.js.map +1 -1
- package/dist/tools/ppt/misc.d.ts +1 -2
- package/dist/tools/ppt/misc.d.ts.map +1 -1
- package/dist/tools/ppt/misc.js +70 -385
- package/dist/tools/ppt/misc.js.map +1 -1
- package/dist/tools/ppt/page-effects.d.ts +28 -0
- package/dist/tools/ppt/page-effects.d.ts.map +1 -0
- package/dist/tools/ppt/page-effects.js +505 -0
- package/dist/tools/ppt/page-effects.js.map +1 -0
- package/dist/tools/ppt/{background.d.ts → page-info.d.ts} +11 -13
- package/dist/tools/ppt/page-info.d.ts.map +1 -0
- package/dist/tools/ppt/page-info.js +258 -0
- package/dist/tools/ppt/page-info.js.map +1 -0
- package/dist/tools/ppt/presentation.d.ts +3 -6
- package/dist/tools/ppt/presentation.d.ts.map +1 -1
- package/dist/tools/ppt/presentation.js +136 -437
- package/dist/tools/ppt/presentation.js.map +1 -1
- package/dist/tools/ppt/shape-basic.d.ts +22 -3
- package/dist/tools/ppt/shape-basic.d.ts.map +1 -1
- package/dist/tools/ppt/shape-basic.js +518 -421
- package/dist/tools/ppt/shape-basic.js.map +1 -1
- package/dist/tools/ppt/slide-ops.d.ts +6 -42
- package/dist/tools/ppt/slide-ops.d.ts.map +1 -1
- package/dist/tools/ppt/slide-ops.js +93 -1485
- package/dist/tools/ppt/slide-ops.js.map +1 -1
- package/dist/tools/ppt/slide.d.ts +1 -7
- package/dist/tools/ppt/slide.d.ts.map +1 -1
- package/dist/tools/ppt/slide.js +196 -328
- package/dist/tools/ppt/slide.js.map +1 -1
- package/dist/tools/ppt/table.d.ts.map +1 -1
- package/dist/tools/ppt/table.js +94 -264
- package/dist/tools/ppt/table.js.map +1 -1
- package/dist/tools/ppt/textbox.d.ts +1 -22
- package/dist/tools/ppt/textbox.d.ts.map +1 -1
- package/dist/tools/ppt/textbox.js +87 -107
- package/dist/tools/ppt/textbox.js.map +1 -1
- package/dist/tools/word/academic.d.ts +2 -0
- package/dist/tools/word/academic.d.ts.map +1 -1
- package/dist/tools/word/academic.js +77 -111
- package/dist/tools/word/academic.js.map +1 -1
- package/dist/tools/word/content.d.ts +7 -12
- package/dist/tools/word/content.d.ts.map +1 -1
- package/dist/tools/word/content.js +134 -452
- package/dist/tools/word/content.js.map +1 -1
- package/dist/tools/word/document.d.ts +1 -3
- package/dist/tools/word/document.d.ts.map +1 -1
- package/dist/tools/word/document.js +71 -328
- package/dist/tools/word/document.js.map +1 -1
- package/dist/tools/word/format.d.ts.map +1 -1
- package/dist/tools/word/format.js +59 -211
- package/dist/tools/word/format.js.map +1 -1
- package/dist/tools/word/helpers.d.ts +33 -0
- package/dist/tools/word/helpers.d.ts.map +1 -0
- package/dist/tools/word/helpers.js +50 -0
- package/dist/tools/word/helpers.js.map +1 -0
- package/dist/tools/word/index.d.ts +1 -1
- package/dist/tools/word/index.d.ts.map +1 -1
- package/dist/tools/word/index.js +2 -6
- package/dist/tools/word/index.js.map +1 -1
- package/dist/tools/word/professional.d.ts +4 -0
- package/dist/tools/word/professional.d.ts.map +1 -1
- package/dist/tools/word/professional.js +80 -4
- package/dist/tools/word/professional.js.map +1 -1
- package/dist/tools/word/proofread.d.ts.map +1 -1
- package/dist/tools/word/proofread.js +44 -184
- package/dist/tools/word/proofread.js.map +1 -1
- package/dist/types/tools.d.ts +6 -0
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/image-inline.d.ts +3 -0
- package/dist/utils/image-inline.d.ts.map +1 -0
- package/dist/utils/image-inline.js +61 -0
- package/dist/utils/image-inline.js.map +1 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/scripts/wps-com.ps1 +509 -28
- package/skills/wps-multitool/SKILL.md +17 -4
- package/skills/wps-multitool/references/dsh.md +1 -1
- package/skills/wps-multitool/references/recipes.md +20 -4
- package/skills/wps-multitool/references/routing.md +13 -0
- package/dist/client/mac-poll-server.d.ts.map +0 -1
- package/dist/client/mac-poll-server.js.map +0 -1
- package/dist/tools/ppt/background.d.ts.map +0 -1
- package/dist/tools/ppt/background.js +0 -389
- package/dist/tools/ppt/background.js.map +0 -1
|
@@ -1,41 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Input:
|
|
4
|
-
* Output:
|
|
5
|
-
* Pos: PPT
|
|
3
|
+
* Input: 幻灯片页操作参数
|
|
4
|
+
* Output: 幻灯片页操作结果
|
|
5
|
+
* Pos: PPT 幻灯片页操作工具实现。一旦我被修改,请更新我的头部注释,以及所属文件夹的md。
|
|
6
|
+
* PPT幻灯片页操作Tools(风格统一+拆分轮后本文件只留"页"这一群,见 ppt-audit §三之二):
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 包含:
|
|
8
|
+
* 包含(8 个;形状/文本框 6 个迁 shape-basic.ts,动画/背景/切换/备注迁 page-effects.ts,
|
|
9
|
+
* insert_image 迁 image.ts):
|
|
10
10
|
* - wps_ppt_delete_slide: 删除指定幻灯片
|
|
11
|
-
* - wps_ppt_duplicate_slide: 复制幻灯片
|
|
12
11
|
* - wps_ppt_move_slide: 移动幻灯片到指定位置
|
|
13
12
|
* - wps_ppt_get_slide_count: 获取幻灯片总数
|
|
14
13
|
* - wps_ppt_get_slide_info: 获取指定幻灯片的详细信息
|
|
15
14
|
* - wps_ppt_switch_slide: 切换到指定幻灯片
|
|
16
15
|
* - wps_ppt_set_slide_layout: 设置幻灯片版式布局
|
|
17
16
|
* - wps_ppt_get_slide_notes: 获取幻灯片备注内容
|
|
18
|
-
* - wps_ppt_set_slide_notes: 设置幻灯片备注
|
|
19
|
-
* - wps_ppt_add_shape: 添加形状
|
|
20
|
-
* - wps_ppt_set_shape_style: 设置形状样式
|
|
21
|
-
* - wps_ppt_add_textbox: 添加文本框
|
|
22
|
-
* - wps_ppt_set_slide_title: 设置幻灯片标题
|
|
23
|
-
* - wps_ppt_insert_image: 插入图片
|
|
24
|
-
* - wps_ppt_set_shape_text: 设置形状文字
|
|
25
|
-
* - wps_ppt_set_animation: 设置元素动画
|
|
26
|
-
* - wps_ppt_set_background: 设置幻灯片背景
|
|
27
17
|
* - wps_ppt_set_slide_size: 设置幻灯片尺寸
|
|
28
|
-
* - wps_ppt_set_transition: 设置幻灯片切换效果
|
|
29
|
-
* - wps_ppt_add_chart: 在幻灯片中插入图表
|
|
30
|
-
* - wps_ppt_set_shape_fill: 设置形状填充颜色
|
|
31
|
-
* - wps_ppt_add_speaker_notes: 添加演讲者备注
|
|
32
18
|
*/
|
|
33
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.slideOpsTools = exports.
|
|
35
|
-
const uuid_1 = require("uuid");
|
|
20
|
+
exports.slideOpsTools = exports.setSlideSizeHandler = exports.setSlideSizeDefinition = exports.getSlideNotesHandler = exports.getSlideNotesDefinition = exports.setSlideLayoutHandler = exports.setSlideLayoutDefinition = exports.switchSlideHandler = exports.switchSlideDefinition = exports.getSlideInfoHandler = exports.getSlideInfoDefinition = exports.getSlideCountHandler = exports.getSlideCountDefinition = exports.moveSlideHandler = exports.moveSlideDefinition = exports.deleteSlideHandler = exports.deleteSlideDefinition = void 0;
|
|
36
21
|
const tools_1 = require("../../types/tools");
|
|
37
|
-
const
|
|
38
|
-
const wps_1 = require("../../types/wps");
|
|
22
|
+
const helpers_1 = require("./helpers");
|
|
39
23
|
// ============================================================
|
|
40
24
|
// 1. wps_ppt_delete_slide - 删除指定幻灯片
|
|
41
25
|
// ============================================================
|
|
@@ -61,42 +45,14 @@ exports.deleteSlideDefinition = {
|
|
|
61
45
|
};
|
|
62
46
|
const deleteSlideHandler = async (args) => {
|
|
63
47
|
const { slideIndex } = args;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
id: (0, uuid_1.v4)(),
|
|
69
|
-
success: true,
|
|
70
|
-
content: [
|
|
71
|
-
{
|
|
72
|
-
type: 'text',
|
|
73
|
-
text: `幻灯片删除成功!\n已删除: 第 ${slideIndex} 页`,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return {
|
|
80
|
-
id: (0, uuid_1.v4)(),
|
|
81
|
-
success: false,
|
|
82
|
-
content: [{ type: 'text', text: `删除幻灯片失败: ${response.error}` }],
|
|
83
|
-
error: response.error,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
89
|
-
return {
|
|
90
|
-
id: (0, uuid_1.v4)(),
|
|
91
|
-
success: false,
|
|
92
|
-
content: [{ type: 'text', text: `删除幻灯片出错: ${errMsg}` }],
|
|
93
|
-
error: errMsg,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
48
|
+
const r = await (0, helpers_1.call)('deleteSlide', { slideIndex });
|
|
49
|
+
if (!r.ok)
|
|
50
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('删除幻灯片失败', r), r.error);
|
|
51
|
+
return (0, helpers_1.ok)(`幻灯片删除成功!\n已删除: 第 ${slideIndex} 页`, r.warnings);
|
|
96
52
|
};
|
|
97
53
|
exports.deleteSlideHandler = deleteSlideHandler;
|
|
98
54
|
// ============================================================
|
|
99
|
-
//
|
|
55
|
+
// 2. wps_ppt_move_slide - 移动幻灯片到指定位置
|
|
100
56
|
// ============================================================
|
|
101
57
|
exports.moveSlideDefinition = {
|
|
102
58
|
name: 'wps_ppt_move_slide',
|
|
@@ -124,42 +80,14 @@ exports.moveSlideDefinition = {
|
|
|
124
80
|
};
|
|
125
81
|
const moveSlideHandler = async (args) => {
|
|
126
82
|
const { fromIndex, toIndex } = args;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
id: (0, uuid_1.v4)(),
|
|
132
|
-
success: true,
|
|
133
|
-
content: [
|
|
134
|
-
{
|
|
135
|
-
type: 'text',
|
|
136
|
-
text: `幻灯片移动成功!\n从第 ${fromIndex} 页 → 移到第 ${toIndex} 页`,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
return {
|
|
143
|
-
id: (0, uuid_1.v4)(),
|
|
144
|
-
success: false,
|
|
145
|
-
content: [{ type: 'text', text: `移动幻灯片失败: ${response.error}` }],
|
|
146
|
-
error: response.error,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
152
|
-
return {
|
|
153
|
-
id: (0, uuid_1.v4)(),
|
|
154
|
-
success: false,
|
|
155
|
-
content: [{ type: 'text', text: `移动幻灯片出错: ${errMsg}` }],
|
|
156
|
-
error: errMsg,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
83
|
+
const r = await (0, helpers_1.call)('moveSlide', { fromIndex, toIndex });
|
|
84
|
+
if (!r.ok)
|
|
85
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('移动幻灯片失败', r), r.error);
|
|
86
|
+
return (0, helpers_1.ok)(`幻灯片移动成功!\n从第 ${fromIndex} 页 → 移到第 ${toIndex} 页`, r.warnings);
|
|
159
87
|
};
|
|
160
88
|
exports.moveSlideHandler = moveSlideHandler;
|
|
161
89
|
// ============================================================
|
|
162
|
-
//
|
|
90
|
+
// 3. wps_ppt_get_slide_count - 获取幻灯片总数
|
|
163
91
|
// ============================================================
|
|
164
92
|
exports.getSlideCountDefinition = {
|
|
165
93
|
name: 'wps_ppt_get_slide_count',
|
|
@@ -177,42 +105,14 @@ exports.getSlideCountDefinition = {
|
|
|
177
105
|
},
|
|
178
106
|
};
|
|
179
107
|
const getSlideCountHandler = async (_args) => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
id: (0, uuid_1.v4)(),
|
|
185
|
-
success: true,
|
|
186
|
-
content: [
|
|
187
|
-
{
|
|
188
|
-
type: 'text',
|
|
189
|
-
text: `当前演示文稿共有 ${response.data.count} 页幻灯片`,
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
return {
|
|
196
|
-
id: (0, uuid_1.v4)(),
|
|
197
|
-
success: false,
|
|
198
|
-
content: [{ type: 'text', text: `获取幻灯片总数失败: ${response.error}` }],
|
|
199
|
-
error: response.error,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
205
|
-
return {
|
|
206
|
-
id: (0, uuid_1.v4)(),
|
|
207
|
-
success: false,
|
|
208
|
-
content: [{ type: 'text', text: `获取幻灯片总数出错: ${errMsg}` }],
|
|
209
|
-
error: errMsg,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
108
|
+
const r = await (0, helpers_1.call)('getSlideCount', {});
|
|
109
|
+
if (!r.ok || !r.data)
|
|
110
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('获取幻灯片总数失败', r), r.error);
|
|
111
|
+
return (0, helpers_1.ok)(`当前演示文稿共有 ${r.data.count} 页幻灯片`, r.warnings);
|
|
212
112
|
};
|
|
213
113
|
exports.getSlideCountHandler = getSlideCountHandler;
|
|
214
114
|
// ============================================================
|
|
215
|
-
//
|
|
115
|
+
// 4. wps_ppt_get_slide_info - 获取指定幻灯片的详细信息
|
|
216
116
|
// ============================================================
|
|
217
117
|
exports.getSlideInfoDefinition = {
|
|
218
118
|
name: 'wps_ppt_get_slide_info',
|
|
@@ -236,51 +136,34 @@ exports.getSlideInfoDefinition = {
|
|
|
236
136
|
};
|
|
237
137
|
const getSlideInfoHandler = async (args) => {
|
|
238
138
|
const { slideIndex } = args;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
output += '\n';
|
|
254
|
-
});
|
|
139
|
+
const r = await (0, helpers_1.call)('getSlideInfo', { slideIndex });
|
|
140
|
+
if (!r.ok || !r.data)
|
|
141
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('获取幻灯片信息失败', r), r.error);
|
|
142
|
+
const info = r.data;
|
|
143
|
+
let output = `第 ${info.slideIndex} 页幻灯片信息:\n`;
|
|
144
|
+
output += `布局: ${info.layout}\n`;
|
|
145
|
+
output += `元素数量: ${info.shapesCount}\n`;
|
|
146
|
+
if (info.shapes && info.shapes.length > 0) {
|
|
147
|
+
output += `\n元素列表:\n`;
|
|
148
|
+
info.shapes.forEach((shape, i) => {
|
|
149
|
+
output += ` ${i + 1}. [${shape.type}] ${shape.name}`;
|
|
150
|
+
if (shape.placeholderType) {
|
|
151
|
+
output += ` 占位符类型:${shape.placeholderType}`;
|
|
255
152
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
id: (0, uuid_1.v4)(),
|
|
265
|
-
success: false,
|
|
266
|
-
content: [{ type: 'text', text: `获取幻灯片信息失败: ${response.error}` }],
|
|
267
|
-
error: response.error,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
catch (error) {
|
|
272
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
273
|
-
return {
|
|
274
|
-
id: (0, uuid_1.v4)(),
|
|
275
|
-
success: false,
|
|
276
|
-
content: [{ type: 'text', text: `获取幻灯片信息出错: ${errMsg}` }],
|
|
277
|
-
error: errMsg,
|
|
278
|
-
};
|
|
153
|
+
if (shape.hasText !== undefined) {
|
|
154
|
+
output += shape.hasText ? ' 有文本框' : ' 无文本框';
|
|
155
|
+
}
|
|
156
|
+
if (shape.text) {
|
|
157
|
+
output += ` - "${shape.text.substring(0, 50)}${shape.text.length > 50 ? '...' : ''}"`;
|
|
158
|
+
}
|
|
159
|
+
output += '\n';
|
|
160
|
+
});
|
|
279
161
|
}
|
|
162
|
+
return (0, helpers_1.ok)(output, r.warnings);
|
|
280
163
|
};
|
|
281
164
|
exports.getSlideInfoHandler = getSlideInfoHandler;
|
|
282
165
|
// ============================================================
|
|
283
|
-
//
|
|
166
|
+
// 5. wps_ppt_switch_slide - 切换到指定幻灯片
|
|
284
167
|
// ============================================================
|
|
285
168
|
exports.switchSlideDefinition = {
|
|
286
169
|
name: 'wps_ppt_switch_slide',
|
|
@@ -304,42 +187,14 @@ exports.switchSlideDefinition = {
|
|
|
304
187
|
};
|
|
305
188
|
const switchSlideHandler = async (args) => {
|
|
306
189
|
const { slideIndex } = args;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
id: (0, uuid_1.v4)(),
|
|
312
|
-
success: true,
|
|
313
|
-
content: [
|
|
314
|
-
{
|
|
315
|
-
type: 'text',
|
|
316
|
-
text: `已切换到第 ${slideIndex} 页幻灯片`,
|
|
317
|
-
},
|
|
318
|
-
],
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
return {
|
|
323
|
-
id: (0, uuid_1.v4)(),
|
|
324
|
-
success: false,
|
|
325
|
-
content: [{ type: 'text', text: `切换幻灯片失败: ${response.error}` }],
|
|
326
|
-
error: response.error,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
catch (error) {
|
|
331
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
332
|
-
return {
|
|
333
|
-
id: (0, uuid_1.v4)(),
|
|
334
|
-
success: false,
|
|
335
|
-
content: [{ type: 'text', text: `切换幻灯片出错: ${errMsg}` }],
|
|
336
|
-
error: errMsg,
|
|
337
|
-
};
|
|
338
|
-
}
|
|
190
|
+
const r = await (0, helpers_1.call)('switchSlide', { slideIndex });
|
|
191
|
+
if (!r.ok)
|
|
192
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('切换幻灯片失败', r), r.error);
|
|
193
|
+
return (0, helpers_1.ok)(`已切换到第 ${slideIndex} 页幻灯片`, r.warnings);
|
|
339
194
|
};
|
|
340
195
|
exports.switchSlideHandler = switchSlideHandler;
|
|
341
196
|
// ============================================================
|
|
342
|
-
//
|
|
197
|
+
// 6. wps_ppt_set_slide_layout - 设置幻灯片版式布局
|
|
343
198
|
// ============================================================
|
|
344
199
|
exports.setSlideLayoutDefinition = {
|
|
345
200
|
name: 'wps_ppt_set_slide_layout',
|
|
@@ -376,51 +231,23 @@ exports.setSlideLayoutDefinition = {
|
|
|
376
231
|
};
|
|
377
232
|
const setSlideLayoutHandler = async (args) => {
|
|
378
233
|
const { slideIndex, layout } = args;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
id: (0, uuid_1.v4)(),
|
|
393
|
-
success: true,
|
|
394
|
-
content: [
|
|
395
|
-
{
|
|
396
|
-
type: 'text',
|
|
397
|
-
text: `幻灯片布局设置成功!\n幻灯片: 第 ${slideIndex} 页\n布局: ${layoutName[layout] || layout}`,
|
|
398
|
-
},
|
|
399
|
-
],
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
return {
|
|
404
|
-
id: (0, uuid_1.v4)(),
|
|
405
|
-
success: false,
|
|
406
|
-
content: [{ type: 'text', text: `设置幻灯片布局失败: ${response.error}` }],
|
|
407
|
-
error: response.error,
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
catch (error) {
|
|
412
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
413
|
-
return {
|
|
414
|
-
id: (0, uuid_1.v4)(),
|
|
415
|
-
success: false,
|
|
416
|
-
content: [{ type: 'text', text: `设置幻灯片布局出错: ${errMsg}` }],
|
|
417
|
-
error: errMsg,
|
|
418
|
-
};
|
|
419
|
-
}
|
|
234
|
+
const r = await (0, helpers_1.call)('setSlideLayout', { slideIndex, layout });
|
|
235
|
+
if (!r.ok)
|
|
236
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('设置幻灯片布局失败', r), r.error);
|
|
237
|
+
const layoutName = {
|
|
238
|
+
title: '标题页',
|
|
239
|
+
title_content: '标题+内容',
|
|
240
|
+
blank: '空白页',
|
|
241
|
+
two_column: '两栏内容',
|
|
242
|
+
comparison: '对比布局',
|
|
243
|
+
section_header: '节标题',
|
|
244
|
+
title_only: '仅标题',
|
|
245
|
+
};
|
|
246
|
+
return (0, helpers_1.ok)(`幻灯片布局设置成功!\n幻灯片: 第 ${slideIndex} 页\n布局: ${layoutName[layout] || layout}`, r.warnings);
|
|
420
247
|
};
|
|
421
248
|
exports.setSlideLayoutHandler = setSlideLayoutHandler;
|
|
422
249
|
// ============================================================
|
|
423
|
-
//
|
|
250
|
+
// 7. wps_ppt_get_slide_notes - 获取幻灯片备注内容
|
|
424
251
|
// ============================================================
|
|
425
252
|
exports.getSlideNotesDefinition = {
|
|
426
253
|
name: 'wps_ppt_get_slide_notes',
|
|
@@ -444,987 +271,32 @@ exports.getSlideNotesDefinition = {
|
|
|
444
271
|
};
|
|
445
272
|
const getSlideNotesHandler = async (args) => {
|
|
446
273
|
const { slideIndex } = args;
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
content: [
|
|
455
|
-
{
|
|
456
|
-
type: 'text',
|
|
457
|
-
text: notes
|
|
458
|
-
? `第 ${slideIndex} 页备注内容:\n${notes}`
|
|
459
|
-
: `第 ${slideIndex} 页没有备注内容`,
|
|
460
|
-
},
|
|
461
|
-
],
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
return {
|
|
466
|
-
id: (0, uuid_1.v4)(),
|
|
467
|
-
success: false,
|
|
468
|
-
content: [{ type: 'text', text: `获取幻灯片备注失败: ${response.error}` }],
|
|
469
|
-
error: response.error,
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
catch (error) {
|
|
474
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
475
|
-
return {
|
|
476
|
-
id: (0, uuid_1.v4)(),
|
|
477
|
-
success: false,
|
|
478
|
-
content: [{ type: 'text', text: `获取幻灯片备注出错: ${errMsg}` }],
|
|
479
|
-
error: errMsg,
|
|
480
|
-
};
|
|
481
|
-
}
|
|
274
|
+
const r = await (0, helpers_1.call)('getSlideNotes', { slideIndex });
|
|
275
|
+
if (!r.ok || !r.data)
|
|
276
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('获取幻灯片备注失败', r), r.error);
|
|
277
|
+
const notes = r.data.notes;
|
|
278
|
+
return (0, helpers_1.ok)(notes
|
|
279
|
+
? `第 ${slideIndex} 页备注内容:\n${notes}`
|
|
280
|
+
: `第 ${slideIndex} 页没有备注内容`, r.warnings);
|
|
482
281
|
};
|
|
483
282
|
exports.getSlideNotesHandler = getSlideNotesHandler;
|
|
484
283
|
// ============================================================
|
|
485
|
-
//
|
|
486
|
-
// ============================================================
|
|
487
|
-
exports.addShapeDefinition = {
|
|
488
|
-
name: 'wps_ppt_add_shape',
|
|
489
|
-
description: `在幻灯片中添加形状。
|
|
490
|
-
|
|
491
|
-
支持的形状类型:
|
|
492
|
-
- rectangle: 矩形
|
|
493
|
-
- oval: 椭圆
|
|
494
|
-
- triangle: 三角形
|
|
495
|
-
- diamond: 菱形
|
|
496
|
-
- pentagon: 五边形
|
|
497
|
-
- hexagon: 六边形
|
|
498
|
-
- arrow: 箭头
|
|
499
|
-
- star: 星形
|
|
500
|
-
- heart: 心形
|
|
501
|
-
- cloud: 云形
|
|
502
|
-
|
|
503
|
-
使用场景:
|
|
504
|
-
- "在第1页添加一个矩形"
|
|
505
|
-
- "插入一个蓝色的圆形"
|
|
506
|
-
- "添加一个带文字的箭头"`,
|
|
507
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
508
|
-
inputSchema: {
|
|
509
|
-
type: 'object',
|
|
510
|
-
properties: {
|
|
511
|
-
slideIndex: {
|
|
512
|
-
type: 'number',
|
|
513
|
-
description: '幻灯片索引(从1开始),默认1',
|
|
514
|
-
},
|
|
515
|
-
type: {
|
|
516
|
-
type: 'string',
|
|
517
|
-
description: '形状类型',
|
|
518
|
-
enum: ['rectangle', 'oval', 'triangle', 'diamond', 'pentagon', 'hexagon', 'arrow', 'star', 'heart', 'cloud'],
|
|
519
|
-
},
|
|
520
|
-
left: {
|
|
521
|
-
type: 'number',
|
|
522
|
-
description: '左边距(像素),默认100',
|
|
523
|
-
},
|
|
524
|
-
top: {
|
|
525
|
-
type: 'number',
|
|
526
|
-
description: '上边距(像素),默认100',
|
|
527
|
-
},
|
|
528
|
-
width: {
|
|
529
|
-
type: 'number',
|
|
530
|
-
description: '宽度(像素),默认100',
|
|
531
|
-
},
|
|
532
|
-
height: {
|
|
533
|
-
type: 'number',
|
|
534
|
-
description: '高度(像素),默认100',
|
|
535
|
-
},
|
|
536
|
-
text: {
|
|
537
|
-
type: 'string',
|
|
538
|
-
description: '形状内的文本',
|
|
539
|
-
},
|
|
540
|
-
fillColor: {
|
|
541
|
-
type: 'string',
|
|
542
|
-
description: '填充颜色,十六进制如 #FF0000',
|
|
543
|
-
},
|
|
544
|
-
},
|
|
545
|
-
required: [],
|
|
546
|
-
},
|
|
547
|
-
};
|
|
548
|
-
const addShapeHandler = async (args) => {
|
|
549
|
-
const { slideIndex, type, left, top, width, height, text, fillColor } = args;
|
|
550
|
-
try {
|
|
551
|
-
const response = await wps_client_1.wpsClient.executeMethod('addShape', {
|
|
552
|
-
slideIndex: slideIndex || 1,
|
|
553
|
-
type: type || 'rectangle',
|
|
554
|
-
left: left || 100,
|
|
555
|
-
top: top || 100,
|
|
556
|
-
width: width || 100,
|
|
557
|
-
height: height || 100,
|
|
558
|
-
text,
|
|
559
|
-
fillColor,
|
|
560
|
-
}, wps_1.WpsAppType.PRESENTATION);
|
|
561
|
-
if (response.success && response.data) {
|
|
562
|
-
const shapeNameMap = {
|
|
563
|
-
rectangle: '矩形', oval: '椭圆', triangle: '三角形', diamond: '菱形',
|
|
564
|
-
pentagon: '五边形', hexagon: '六边形', arrow: '箭头', star: '星形',
|
|
565
|
-
heart: '心形', cloud: '云形',
|
|
566
|
-
};
|
|
567
|
-
const typeName = shapeNameMap[type || 'rectangle'] || type;
|
|
568
|
-
return {
|
|
569
|
-
id: (0, uuid_1.v4)(),
|
|
570
|
-
success: true,
|
|
571
|
-
content: [
|
|
572
|
-
{
|
|
573
|
-
type: 'text',
|
|
574
|
-
text: `形状添加成功!\n幻灯片: 第 ${response.data.slideIndex} 页\n形状类型: ${typeName}\n形状名称: ${response.data.name}${text ? `\n文本: ${text}` : ''}${fillColor ? `\n填充色: ${fillColor}` : ''}`,
|
|
575
|
-
},
|
|
576
|
-
],
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
return {
|
|
581
|
-
id: (0, uuid_1.v4)(),
|
|
582
|
-
success: false,
|
|
583
|
-
content: [{ type: 'text', text: `添加形状失败: ${response.error}` }],
|
|
584
|
-
error: response.error,
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
catch (error) {
|
|
589
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
590
|
-
return {
|
|
591
|
-
id: (0, uuid_1.v4)(),
|
|
592
|
-
success: false,
|
|
593
|
-
content: [{ type: 'text', text: `添加形状出错: ${errMsg}` }],
|
|
594
|
-
error: errMsg,
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
exports.addShapeHandler = addShapeHandler;
|
|
599
|
-
// ============================================================
|
|
600
|
-
// 11. wps_ppt_set_shape_style - 设置形状样式
|
|
601
|
-
// ============================================================
|
|
602
|
-
exports.setShapeStyleDefinition = {
|
|
603
|
-
name: 'wps_ppt_set_shape_style',
|
|
604
|
-
description: `设置幻灯片中形状的样式,包括填充颜色、边框颜色和边框粗细。
|
|
605
|
-
|
|
606
|
-
使用场景:
|
|
607
|
-
- "把矩形改成红色"
|
|
608
|
-
- "设置形状的边框为蓝色"
|
|
609
|
-
- "修改形状样式"`,
|
|
610
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
611
|
-
inputSchema: {
|
|
612
|
-
type: 'object',
|
|
613
|
-
properties: {
|
|
614
|
-
slideIndex: {
|
|
615
|
-
type: 'number',
|
|
616
|
-
description: '幻灯片索引(从1开始),默认1',
|
|
617
|
-
},
|
|
618
|
-
name: {
|
|
619
|
-
type: 'string',
|
|
620
|
-
description: '形状名称(通过getSlideInfo获取)',
|
|
621
|
-
},
|
|
622
|
-
shapeIndex: {
|
|
623
|
-
type: 'number',
|
|
624
|
-
description: '形状索引(与name二选一)',
|
|
625
|
-
},
|
|
626
|
-
fillColor: {
|
|
627
|
-
type: 'string',
|
|
628
|
-
description: '填充颜色,十六进制如 #FF0000',
|
|
629
|
-
},
|
|
630
|
-
lineColor: {
|
|
631
|
-
type: 'string',
|
|
632
|
-
description: '边框颜色,十六进制如 #000000',
|
|
633
|
-
},
|
|
634
|
-
lineWidth: {
|
|
635
|
-
type: 'number',
|
|
636
|
-
description: '边框粗细(磅)',
|
|
637
|
-
},
|
|
638
|
-
},
|
|
639
|
-
required: [],
|
|
640
|
-
},
|
|
641
|
-
};
|
|
642
|
-
const setShapeStyleHandler = async (args) => {
|
|
643
|
-
const { slideIndex, name, shapeIndex, fillColor, lineColor, lineWidth } = args;
|
|
644
|
-
try {
|
|
645
|
-
const response = await wps_client_1.wpsClient.executeMethod('setShapeStyle', {
|
|
646
|
-
slideIndex: slideIndex || 1,
|
|
647
|
-
name,
|
|
648
|
-
shapeIndex,
|
|
649
|
-
fillColor,
|
|
650
|
-
lineColor,
|
|
651
|
-
lineWidth,
|
|
652
|
-
}, wps_1.WpsAppType.PRESENTATION);
|
|
653
|
-
if (response.success && response.data) {
|
|
654
|
-
let output = `形状样式设置成功!\n形状: ${response.data.name}`;
|
|
655
|
-
if (fillColor)
|
|
656
|
-
output += `\n填充色: ${fillColor}`;
|
|
657
|
-
if (lineColor)
|
|
658
|
-
output += `\n边框色: ${lineColor}`;
|
|
659
|
-
if (lineWidth)
|
|
660
|
-
output += `\n边框粗细: ${lineWidth}pt`;
|
|
661
|
-
return {
|
|
662
|
-
id: (0, uuid_1.v4)(),
|
|
663
|
-
success: true,
|
|
664
|
-
content: [{ type: 'text', text: output }],
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
else {
|
|
668
|
-
return {
|
|
669
|
-
id: (0, uuid_1.v4)(),
|
|
670
|
-
success: false,
|
|
671
|
-
content: [{ type: 'text', text: `设置形状样式失败: ${response.error}` }],
|
|
672
|
-
error: response.error,
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
catch (error) {
|
|
677
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
678
|
-
return {
|
|
679
|
-
id: (0, uuid_1.v4)(),
|
|
680
|
-
success: false,
|
|
681
|
-
content: [{ type: 'text', text: `设置形状样式出错: ${errMsg}` }],
|
|
682
|
-
error: errMsg,
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
exports.setShapeStyleHandler = setShapeStyleHandler;
|
|
687
|
-
// ============================================================
|
|
688
|
-
// 12. wps_ppt_add_textbox - 添加文本框
|
|
689
|
-
// ============================================================
|
|
690
|
-
exports.addTextboxDefinition = {
|
|
691
|
-
name: 'wps_ppt_add_textbox',
|
|
692
|
-
description: `在幻灯片中添加文本框。
|
|
693
|
-
|
|
694
|
-
使用场景:
|
|
695
|
-
- "在第1页添加一个文本框"
|
|
696
|
-
- "插入一个写着标题的文本框"
|
|
697
|
-
- "添加文本框并设置字号"`,
|
|
698
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
699
|
-
inputSchema: {
|
|
700
|
-
type: 'object',
|
|
701
|
-
properties: {
|
|
702
|
-
slideIndex: {
|
|
703
|
-
type: 'number',
|
|
704
|
-
description: '幻灯片索引(从1开始),默认1',
|
|
705
|
-
},
|
|
706
|
-
left: {
|
|
707
|
-
type: 'number',
|
|
708
|
-
description: '左边距(像素),默认100',
|
|
709
|
-
},
|
|
710
|
-
top: {
|
|
711
|
-
type: 'number',
|
|
712
|
-
description: '上边距(像素),默认100',
|
|
713
|
-
},
|
|
714
|
-
width: {
|
|
715
|
-
type: 'number',
|
|
716
|
-
description: '宽度(像素),默认200',
|
|
717
|
-
},
|
|
718
|
-
height: {
|
|
719
|
-
type: 'number',
|
|
720
|
-
description: '高度(像素),默认50',
|
|
721
|
-
},
|
|
722
|
-
text: {
|
|
723
|
-
type: 'string',
|
|
724
|
-
description: '文本框内容',
|
|
725
|
-
},
|
|
726
|
-
fontSize: {
|
|
727
|
-
type: 'number',
|
|
728
|
-
description: '字号大小',
|
|
729
|
-
},
|
|
730
|
-
fontName: {
|
|
731
|
-
type: 'string',
|
|
732
|
-
description: '字体名称,如 "微软雅黑"',
|
|
733
|
-
},
|
|
734
|
-
},
|
|
735
|
-
required: [],
|
|
736
|
-
},
|
|
737
|
-
};
|
|
738
|
-
const addTextboxHandler = async (args) => {
|
|
739
|
-
const { slideIndex, left, top, width, height, text, fontSize, fontName } = args;
|
|
740
|
-
try {
|
|
741
|
-
const response = await wps_client_1.wpsClient.executeMethod('addTextBox', {
|
|
742
|
-
slideIndex: slideIndex || 1,
|
|
743
|
-
left: left || 100,
|
|
744
|
-
top: top || 100,
|
|
745
|
-
width: width || 200,
|
|
746
|
-
height: height || 50,
|
|
747
|
-
text,
|
|
748
|
-
fontSize,
|
|
749
|
-
fontName,
|
|
750
|
-
}, wps_1.WpsAppType.PRESENTATION);
|
|
751
|
-
if (response.success && response.data) {
|
|
752
|
-
return {
|
|
753
|
-
id: (0, uuid_1.v4)(),
|
|
754
|
-
success: true,
|
|
755
|
-
content: [
|
|
756
|
-
{
|
|
757
|
-
type: 'text',
|
|
758
|
-
text: `文本框添加成功!\n幻灯片: 第 ${response.data.slideIndex} 页\n名称: ${response.data.name}${text ? `\n内容: "${text}"` : ''}${fontSize ? `\n字号: ${fontSize}` : ''}${fontName ? `\n字体: ${fontName}` : ''}`,
|
|
759
|
-
},
|
|
760
|
-
],
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
else {
|
|
764
|
-
return {
|
|
765
|
-
id: (0, uuid_1.v4)(),
|
|
766
|
-
success: false,
|
|
767
|
-
content: [{ type: 'text', text: `添加文本框失败: ${response.error}` }],
|
|
768
|
-
error: response.error,
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
catch (error) {
|
|
773
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
774
|
-
return {
|
|
775
|
-
id: (0, uuid_1.v4)(),
|
|
776
|
-
success: false,
|
|
777
|
-
content: [{ type: 'text', text: `添加文本框出错: ${errMsg}` }],
|
|
778
|
-
error: errMsg,
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
exports.addTextboxHandler = addTextboxHandler;
|
|
783
|
-
// ============================================================
|
|
784
|
-
// 13. wps_ppt_set_slide_title - 设置幻灯片标题
|
|
785
|
-
// ============================================================
|
|
786
|
-
exports.setSlideTitleDefinition = {
|
|
787
|
-
name: 'wps_ppt_set_slide_title',
|
|
788
|
-
description: `设置幻灯片的标题文本。
|
|
789
|
-
|
|
790
|
-
使用场景:
|
|
791
|
-
- "把第1页标题改成'年度总结'"
|
|
792
|
-
- "设置标题为'项目进展'"
|
|
793
|
-
- "修改幻灯片标题"`,
|
|
794
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
795
|
-
inputSchema: {
|
|
796
|
-
type: 'object',
|
|
797
|
-
properties: {
|
|
798
|
-
slideIndex: {
|
|
799
|
-
type: 'number',
|
|
800
|
-
description: '幻灯片索引(从1开始),默认1',
|
|
801
|
-
},
|
|
802
|
-
title: {
|
|
803
|
-
type: 'string',
|
|
804
|
-
description: '标题文本',
|
|
805
|
-
},
|
|
806
|
-
},
|
|
807
|
-
required: ['title'],
|
|
808
|
-
},
|
|
809
|
-
};
|
|
810
|
-
const setSlideTitleHandler = async (args) => {
|
|
811
|
-
const { slideIndex, title } = args;
|
|
812
|
-
try {
|
|
813
|
-
const response = await wps_client_1.wpsClient.executeMethod('setSlideTitle', {
|
|
814
|
-
slideIndex: slideIndex || 1,
|
|
815
|
-
title,
|
|
816
|
-
}, wps_1.WpsAppType.PRESENTATION);
|
|
817
|
-
if (response.success && response.data) {
|
|
818
|
-
return {
|
|
819
|
-
id: (0, uuid_1.v4)(),
|
|
820
|
-
success: true,
|
|
821
|
-
content: [
|
|
822
|
-
{
|
|
823
|
-
type: 'text',
|
|
824
|
-
text: `幻灯片标题设置成功!\n幻灯片: 第 ${response.data.slideIndex} 页\n标题: "${response.data.title}"`,
|
|
825
|
-
},
|
|
826
|
-
],
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
else {
|
|
830
|
-
return {
|
|
831
|
-
id: (0, uuid_1.v4)(),
|
|
832
|
-
success: false,
|
|
833
|
-
content: [{ type: 'text', text: `设置幻灯片标题失败: ${response.error}` }],
|
|
834
|
-
error: response.error,
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
catch (error) {
|
|
839
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
840
|
-
return {
|
|
841
|
-
id: (0, uuid_1.v4)(),
|
|
842
|
-
success: false,
|
|
843
|
-
content: [{ type: 'text', text: `设置幻灯片标题出错: ${errMsg}` }],
|
|
844
|
-
error: errMsg,
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
exports.setSlideTitleHandler = setSlideTitleHandler;
|
|
849
|
-
// ============================================================
|
|
850
|
-
// 14. wps_ppt_insert_image - 插入图片
|
|
851
|
-
// ============================================================
|
|
852
|
-
exports.insertImageDefinition = {
|
|
853
|
-
name: 'wps_ppt_insert_image',
|
|
854
|
-
description: `在幻灯片中插入图片。
|
|
855
|
-
|
|
856
|
-
使用场景:
|
|
857
|
-
- "在第1页插入一张图片"
|
|
858
|
-
- "添加图片到幻灯片"
|
|
859
|
-
- "把这个图片放到PPT里"`,
|
|
860
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
861
|
-
inputSchema: {
|
|
862
|
-
type: 'object',
|
|
863
|
-
properties: {
|
|
864
|
-
slideIndex: {
|
|
865
|
-
type: 'number',
|
|
866
|
-
description: '幻灯片索引(从1开始),默认1',
|
|
867
|
-
},
|
|
868
|
-
path: {
|
|
869
|
-
type: 'string',
|
|
870
|
-
description: '图片文件的完整路径',
|
|
871
|
-
},
|
|
872
|
-
left: {
|
|
873
|
-
type: 'number',
|
|
874
|
-
description: '左边距(像素),默认100',
|
|
875
|
-
},
|
|
876
|
-
top: {
|
|
877
|
-
type: 'number',
|
|
878
|
-
description: '上边距(像素),默认100',
|
|
879
|
-
},
|
|
880
|
-
width: {
|
|
881
|
-
type: 'number',
|
|
882
|
-
description: '宽度(像素),不填则保持原始尺寸',
|
|
883
|
-
},
|
|
884
|
-
height: {
|
|
885
|
-
type: 'number',
|
|
886
|
-
description: '高度(像素),不填则保持原始尺寸',
|
|
887
|
-
},
|
|
888
|
-
},
|
|
889
|
-
required: ['path'],
|
|
890
|
-
},
|
|
891
|
-
};
|
|
892
|
-
const insertImageHandler = async (args) => {
|
|
893
|
-
const { slideIndex, path, left, top, width, height } = args;
|
|
894
|
-
try {
|
|
895
|
-
const response = await wps_client_1.wpsClient.executeMethod('insertPptImage', {
|
|
896
|
-
slideIndex: slideIndex || 1,
|
|
897
|
-
path,
|
|
898
|
-
left: left || 100,
|
|
899
|
-
top: top || 100,
|
|
900
|
-
width: width || -1,
|
|
901
|
-
height: height || -1,
|
|
902
|
-
}, wps_1.WpsAppType.PRESENTATION);
|
|
903
|
-
if (response.success && response.data) {
|
|
904
|
-
return {
|
|
905
|
-
id: (0, uuid_1.v4)(),
|
|
906
|
-
success: true,
|
|
907
|
-
content: [
|
|
908
|
-
{
|
|
909
|
-
type: 'text',
|
|
910
|
-
text: `图片插入成功!\n幻灯片: 第 ${slideIndex || 1} 页\n图片名称: ${response.data.name}\n图片路径: ${response.data.path}`,
|
|
911
|
-
},
|
|
912
|
-
],
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
else {
|
|
916
|
-
return {
|
|
917
|
-
id: (0, uuid_1.v4)(),
|
|
918
|
-
success: false,
|
|
919
|
-
content: [{ type: 'text', text: `插入图片失败: ${response.error}` }],
|
|
920
|
-
error: response.error,
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
catch (error) {
|
|
925
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
926
|
-
return {
|
|
927
|
-
id: (0, uuid_1.v4)(),
|
|
928
|
-
success: false,
|
|
929
|
-
content: [{ type: 'text', text: `插入图片出错: ${errMsg}` }],
|
|
930
|
-
error: errMsg,
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
exports.insertImageHandler = insertImageHandler;
|
|
935
|
-
// ============================================================
|
|
936
|
-
// 15. wps_ppt_set_shape_text - 设置形状文字
|
|
937
|
-
// ============================================================
|
|
938
|
-
exports.setShapeTextDefinition = {
|
|
939
|
-
name: 'wps_ppt_set_shape_text',
|
|
940
|
-
description: `设置幻灯片中指定形状的文字内容。
|
|
941
|
-
|
|
942
|
-
使用场景:
|
|
943
|
-
- "把第1页的第2个形状文字改成'销售额'"
|
|
944
|
-
- "修改形状里的文字"`,
|
|
945
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
946
|
-
inputSchema: {
|
|
947
|
-
type: 'object',
|
|
948
|
-
properties: {
|
|
949
|
-
slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
|
|
950
|
-
shapeIndex: { type: 'number', description: '形状索引(从1开始)' },
|
|
951
|
-
text: { type: 'string', description: '要设置的文字内容' },
|
|
952
|
-
},
|
|
953
|
-
required: ['slideIndex', 'shapeIndex', 'text'],
|
|
954
|
-
},
|
|
955
|
-
};
|
|
956
|
-
const setShapeTextHandler = async (args) => {
|
|
957
|
-
const { slideIndex, shapeIndex, text } = args;
|
|
958
|
-
try {
|
|
959
|
-
const response = await wps_client_1.wpsClient.executeMethod('setShapeText', { slideIndex, shapeIndex, text }, wps_1.WpsAppType.PRESENTATION);
|
|
960
|
-
if (response.success && response.data) {
|
|
961
|
-
return {
|
|
962
|
-
id: (0, uuid_1.v4)(),
|
|
963
|
-
success: true,
|
|
964
|
-
content: [{ type: 'text', text: `形状文字设置成功!\n形状: ${response.data.name}\n文字: "${text}"` }],
|
|
965
|
-
};
|
|
966
|
-
}
|
|
967
|
-
else {
|
|
968
|
-
return {
|
|
969
|
-
id: (0, uuid_1.v4)(),
|
|
970
|
-
success: false,
|
|
971
|
-
content: [{ type: 'text', text: `设置形状文字失败: ${response.error}` }],
|
|
972
|
-
error: response.error,
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
catch (error) {
|
|
977
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
978
|
-
return {
|
|
979
|
-
id: (0, uuid_1.v4)(),
|
|
980
|
-
success: false,
|
|
981
|
-
content: [{ type: 'text', text: `设置形状文字出错: ${errMsg}` }],
|
|
982
|
-
error: errMsg,
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
exports.setShapeTextHandler = setShapeTextHandler;
|
|
987
|
-
// ============================================================
|
|
988
|
-
// 16. wps_ppt_set_animation - 设置元素动画
|
|
989
|
-
// ============================================================
|
|
990
|
-
exports.setAnimationDefinition = {
|
|
991
|
-
name: 'wps_ppt_set_animation',
|
|
992
|
-
description: `给形状加动画,或调整已有动画的播放顺序(第 8 轮合并了动画族 5 个工具)。
|
|
993
|
-
|
|
994
|
-
**两个分支用 \`op\` 选**:
|
|
995
|
-
- \`op:'add'\`(默认):给形状加动画,要 \`shapeIndex\` + \`category\` + \`effect\`
|
|
996
|
-
- \`op:'reorder'\`:把已有动画挪位置,要 \`animationIndex\` + \`order\`
|
|
997
|
-
|
|
998
|
-
\`category\` 决定动作落在哪个动画窗格:
|
|
999
|
-
- entrance 入场(appear / fadeIn / flyIn / wipeIn / zoomIn / bounceIn / spinIn)
|
|
1000
|
-
- emphasis 强调(pulse / grow / teeter / colorPulse)
|
|
1001
|
-
- exit 退场(fadeOut / flyOut / wipeOut / zoomOut / disappear)
|
|
1002
|
-
|
|
1003
|
-
什么时候用:
|
|
1004
|
-
- "给第1页第2个形状加个淡入" → { op:'add', slideIndex:1, shapeIndex:2, category:'entrance', effect:'fadeIn' }
|
|
1005
|
-
- "让这个元素闪一下强调" → { op:'add', slideIndex:1, shapeIndex:2, category:'emphasis', effect:'pulse' }
|
|
1006
|
-
- "把第3个动画移到最前面" → { op:'reorder', slideIndex:1, animationIndex:3, order:1 }
|
|
1007
|
-
|
|
1008
|
-
限制:\`.add\` 是【累加】的 —— 同一形状重复加会叠出多条动画,不会替换。
|
|
1009
|
-
想看现在有哪些动画用 wps_ppt_get_animations,删掉某一条用 wps_ppt_remove_animation。`,
|
|
1010
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
1011
|
-
inputSchema: {
|
|
1012
|
-
type: 'object',
|
|
1013
|
-
properties: {
|
|
1014
|
-
op: {
|
|
1015
|
-
type: 'string',
|
|
1016
|
-
enum: ['add', 'reorder'],
|
|
1017
|
-
description: '操作:add 加动画(默认)/ reorder 调顺序',
|
|
1018
|
-
},
|
|
1019
|
-
slideIndex: {
|
|
1020
|
-
type: 'number',
|
|
1021
|
-
description: '幻灯片索引(从1开始)',
|
|
1022
|
-
},
|
|
1023
|
-
shapeIndex: {
|
|
1024
|
-
type: 'number',
|
|
1025
|
-
description: '形状索引(从1开始);op=add 时必填',
|
|
1026
|
-
},
|
|
1027
|
-
category: {
|
|
1028
|
-
type: 'string',
|
|
1029
|
-
enum: ['entrance', 'emphasis', 'exit'],
|
|
1030
|
-
description: '动画类别;op=add 时必填',
|
|
1031
|
-
},
|
|
1032
|
-
effect: {
|
|
1033
|
-
type: 'string',
|
|
1034
|
-
description: '具体效果名。entrance: fadeIn/flyIn/wipeIn/zoomIn/bounceIn/spinIn;emphasis: pulse/spin/grow/teeter/colorPulse;exit: fadeOut/flyOut/wipeOut/zoomOut/disappear',
|
|
1035
|
-
},
|
|
1036
|
-
trigger: {
|
|
1037
|
-
type: 'string',
|
|
1038
|
-
enum: ['onClick', 'withPrevious', 'afterPrevious'],
|
|
1039
|
-
description: '触发方式,默认 onClick(单击时)',
|
|
1040
|
-
},
|
|
1041
|
-
animationIndex: {
|
|
1042
|
-
type: 'number',
|
|
1043
|
-
description: '已有动画的序号(从1开始);op=reorder 时必填',
|
|
1044
|
-
},
|
|
1045
|
-
order: {
|
|
1046
|
-
type: 'number',
|
|
1047
|
-
description: '新的播放位置(从1开始);op=reorder 时必填',
|
|
1048
|
-
},
|
|
1049
|
-
},
|
|
1050
|
-
required: ['slideIndex'],
|
|
1051
|
-
},
|
|
1052
|
-
};
|
|
1053
|
-
/** 旧 animationType → { category, effect }。旧名 wps_ppt_set_animation 只收一个字符串,
|
|
1054
|
-
* 收尾先按 Out/Exit 结尾判退场,其余按入场;未知名默认入场(宁可多加一个也别不加)。 */
|
|
1055
|
-
function splitLegacyAnimationType(animationType) {
|
|
1056
|
-
return {
|
|
1057
|
-
category: /(out|exit)$/i.test(animationType) ? 'exit' : 'entrance',
|
|
1058
|
-
effect: animationType,
|
|
1059
|
-
};
|
|
1060
|
-
}
|
|
1061
|
-
const ANIM_NAME_MAP = {
|
|
1062
|
-
fadeIn: '淡入', flyIn: '飞入', wipeIn: '擦除', zoomIn: '缩放进入',
|
|
1063
|
-
bounceIn: '弹跳进入', spinIn: '旋转进入', fadeOut: '淡出', flyOut: '飞出',
|
|
1064
|
-
wipeOut: '擦除退场', zoomOut: '缩小退场', disappear: '消失',
|
|
1065
|
-
pulse: '脉冲', grow: '放大缩小', teeter: '跷跷板', colorPulse: '颜色脉冲',
|
|
1066
|
-
};
|
|
1067
|
-
const TRIGGER_NAME_MAP = {
|
|
1068
|
-
onClick: '单击时',
|
|
1069
|
-
withPrevious: '与上一动画同时',
|
|
1070
|
-
afterPrevious: '上一动画之后',
|
|
1071
|
-
};
|
|
1072
|
-
const CATEGORY_NAME_MAP = {
|
|
1073
|
-
entrance: '入场', emphasis: '强调', exit: '退场',
|
|
1074
|
-
};
|
|
1075
|
-
/**
|
|
1076
|
-
* category + effect → PS 真正认的效果名。
|
|
1077
|
-
* 为什么要在 TS 侧合成:WPS COM 的 AddEffect 只吃一个效果 ID,不认"入场/强调/退场"这个维度。
|
|
1078
|
-
* 不做这层合成的话,category 就是一个装饰参数(PS 收不到、进不了动画窗格对应格),
|
|
1079
|
-
* 那才是真的骗人 —— 用户以为加了退场动画,实际加的还是入场。
|
|
1080
|
-
*/
|
|
1081
|
-
function resolveEffectId(category, effect) {
|
|
1082
|
-
const normalized = String(effect || '').trim();
|
|
1083
|
-
const lower = normalized.toLowerCase();
|
|
1084
|
-
if (category === 'exit') {
|
|
1085
|
-
const outMap = {
|
|
1086
|
-
fade: 'fadeOut', fly: 'flyOut', wipe: 'wipeOut', zoom: 'zoomOut',
|
|
1087
|
-
vanish: 'vanish', disappear: 'disappear', dissolve: 'dissolveOut',
|
|
1088
|
-
};
|
|
1089
|
-
// 已经带 Out 尾名的(fadeOut)原样送下去,不重复拼
|
|
1090
|
-
if (lower.endsWith('out') || lower === 'disappear' || lower === 'vanish')
|
|
1091
|
-
return normalized;
|
|
1092
|
-
return outMap[lower] || normalized;
|
|
1093
|
-
}
|
|
1094
|
-
const inMap = {
|
|
1095
|
-
fade: 'fadeIn', fly: 'flyIn', wipe: 'wipeIn', zoom: 'zoomIn',
|
|
1096
|
-
dissolve: 'dissolveIn', appear: 'appear',
|
|
1097
|
-
};
|
|
1098
|
-
if (lower.endsWith('in') || lower === 'appear')
|
|
1099
|
-
return normalized;
|
|
1100
|
-
return inMap[lower] || normalized;
|
|
1101
|
-
}
|
|
1102
|
-
const setAnimationHandler = async (args) => {
|
|
1103
|
-
const op = args.op || 'add';
|
|
1104
|
-
try {
|
|
1105
|
-
if (op === 'reorder') {
|
|
1106
|
-
const { slideIndex, animationIndex, order } = args;
|
|
1107
|
-
if (!animationIndex || !order) {
|
|
1108
|
-
return {
|
|
1109
|
-
id: (0, uuid_1.v4)(),
|
|
1110
|
-
success: false,
|
|
1111
|
-
content: [{ type: 'text', text: `op=reorder 时必须同时给 animationIndex 和 order` }],
|
|
1112
|
-
error: 'Missing required parameter: animationIndex / order',
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
const response = await wps_client_1.wpsClient.executeMethod('setAnimationOrder', { slideIndex, animationIndex, newOrder: order }, wps_1.WpsAppType.PRESENTATION);
|
|
1116
|
-
if (response.success) {
|
|
1117
|
-
return {
|
|
1118
|
-
id: (0, uuid_1.v4)(),
|
|
1119
|
-
success: true,
|
|
1120
|
-
content: [
|
|
1121
|
-
{
|
|
1122
|
-
type: 'text',
|
|
1123
|
-
text: `动画顺序调整成功!\n幻灯片: 第 ${slideIndex} 页\n动画 ${animationIndex} → 新位置 ${order}`,
|
|
1124
|
-
},
|
|
1125
|
-
],
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
return {
|
|
1129
|
-
id: (0, uuid_1.v4)(),
|
|
1130
|
-
success: false,
|
|
1131
|
-
content: [{ type: 'text', text: `调整动画顺序失败: ${response.error}` }],
|
|
1132
|
-
error: response.error,
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
// op=add:effect 缺失时兜住旧的 animationType(第 2 轮起这个参数就叫 animationType)
|
|
1136
|
-
const raw = args;
|
|
1137
|
-
const legacy = !raw.effect && raw.animationType
|
|
1138
|
-
? splitLegacyAnimationType(String(raw.animationType))
|
|
1139
|
-
: null;
|
|
1140
|
-
const category = raw.category || (legacy ? legacy.category : undefined);
|
|
1141
|
-
const effect = raw.effect || (legacy ? legacy.effect : undefined);
|
|
1142
|
-
if (!raw.shapeIndex || !category || !effect) {
|
|
1143
|
-
return {
|
|
1144
|
-
id: (0, uuid_1.v4)(),
|
|
1145
|
-
success: false,
|
|
1146
|
-
content: [
|
|
1147
|
-
{
|
|
1148
|
-
type: 'text',
|
|
1149
|
-
text: `op=add 时必须同时给 shapeIndex、category(entrance/emphasis/exit)和 effect`,
|
|
1150
|
-
},
|
|
1151
|
-
],
|
|
1152
|
-
error: 'Missing required parameter: shapeIndex / category / effect',
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
|
-
// category 在这里落地成真正的效果名(exit+fade → fadeOut),PS 侧只认效果 ID
|
|
1156
|
-
const effectId = resolveEffectId(category, effect);
|
|
1157
|
-
const response = await wps_client_1.wpsClient.executeMethod('addAnimation', {
|
|
1158
|
-
slideIndex: raw.slideIndex,
|
|
1159
|
-
shapeIndex: raw.shapeIndex,
|
|
1160
|
-
effect: effectId,
|
|
1161
|
-
trigger: raw.trigger || 'onClick',
|
|
1162
|
-
}, wps_1.WpsAppType.PRESENTATION);
|
|
1163
|
-
if (response.success) {
|
|
1164
|
-
const lines = [
|
|
1165
|
-
`动画设置成功!`,
|
|
1166
|
-
`幻灯片: 第 ${raw.slideIndex} 页`,
|
|
1167
|
-
`形状: 第 ${raw.shapeIndex} 个`,
|
|
1168
|
-
`类别: ${CATEGORY_NAME_MAP[category] || category}`,
|
|
1169
|
-
`动画: ${ANIM_NAME_MAP[effect] || effect}(${effectId})`,
|
|
1170
|
-
`触发: ${TRIGGER_NAME_MAP[raw.trigger || 'onClick'] || raw.trigger || 'onClick'}`,
|
|
1171
|
-
];
|
|
1172
|
-
if (response.data && response.data.animationIndex) {
|
|
1173
|
-
lines.push(`动画序号: ${response.data.animationIndex}`);
|
|
1174
|
-
}
|
|
1175
|
-
return {
|
|
1176
|
-
id: (0, uuid_1.v4)(),
|
|
1177
|
-
success: true,
|
|
1178
|
-
content: [{ type: 'text', text: lines.join('\n') }],
|
|
1179
|
-
};
|
|
1180
|
-
}
|
|
1181
|
-
return {
|
|
1182
|
-
id: (0, uuid_1.v4)(),
|
|
1183
|
-
success: false,
|
|
1184
|
-
content: [{ type: 'text', text: `设置动画失败: ${response.error}` }],
|
|
1185
|
-
error: response.error,
|
|
1186
|
-
};
|
|
1187
|
-
}
|
|
1188
|
-
catch (error) {
|
|
1189
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1190
|
-
return {
|
|
1191
|
-
id: (0, uuid_1.v4)(),
|
|
1192
|
-
success: false,
|
|
1193
|
-
content: [{ type: 'text', text: `设置动画出错: ${errMsg}` }],
|
|
1194
|
-
error: errMsg,
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
};
|
|
1198
|
-
exports.setAnimationHandler = setAnimationHandler;
|
|
1199
|
-
// ============================================================
|
|
1200
|
-
// 17. wps_ppt_set_background - 设置背景(第 5 轮:background 族 6→1 合并)
|
|
1201
|
-
// ============================================================
|
|
1202
|
-
exports.setBackgroundDefinition = {
|
|
1203
|
-
name: 'wps_ppt_set_background',
|
|
1204
|
-
description: `设置背景:某一页、整份文稿、或幻灯片母版。
|
|
1205
|
-
|
|
1206
|
-
**三个维度一次说清**(合并了原来 6 个背景工具,别再找 set_background_color / _image / _gradient / set_slide_background / set_master_background):
|
|
1207
|
-
- \`target\`: slide(默认,单页)/ all(整份文稿)/ master(母版)
|
|
1208
|
-
- \`type\`: solid(纯色)/ image(图片)/ gradient(渐变)/ pattern
|
|
1209
|
-
- 具体的填充物:\`color\` / \`imagePath\` / \`gradient\`
|
|
1210
|
-
|
|
1211
|
-
什么时候用:
|
|
1212
|
-
- "把这页背景改成深蓝" → { target:'slide', slideIndex:2, type:'solid', color:'#003366' }
|
|
1213
|
-
- "整份文稿统一白底" → { target:'all', type:'solid', color:'#FFFFFF' }
|
|
1214
|
-
- "用这张图做背景" → { target:'slide', slideIndex:1, type:'image', imagePath:'C:\\\\pics\\\\bg.png' }
|
|
1215
|
-
- "母版加渐变" → { target:'master', type:'gradient', gradient:{ type:'linear', colors:['#FF0000','#00FF00'] } }
|
|
1216
|
-
|
|
1217
|
-
不填 \`type\` 也能用:按你给的 color / imagePath / gradient 自动推断(老名字走别名过来时就是这条路)。
|
|
1218
|
-
|
|
1219
|
-
限制(真限制,不是没实现):
|
|
1220
|
-
- \`target:'master'\` 只支持纯色与渐变 —— 母版背景换图片 WPS 不认,会明确报错而不是假装成功。
|
|
1221
|
-
- \`type:'pattern'\`(图案填充)WPS COM 没有对应接口,明确报错。`,
|
|
1222
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
1223
|
-
inputSchema: {
|
|
1224
|
-
type: 'object',
|
|
1225
|
-
properties: {
|
|
1226
|
-
target: {
|
|
1227
|
-
type: 'string',
|
|
1228
|
-
enum: ['slide', 'all', 'master'],
|
|
1229
|
-
description: '作用范围:slide 单页(默认)/ all 整份文稿 / master 母版',
|
|
1230
|
-
},
|
|
1231
|
-
slideIndex: {
|
|
1232
|
-
type: 'number',
|
|
1233
|
-
description: '页码(从1开始);target=all/master 时忽略',
|
|
1234
|
-
},
|
|
1235
|
-
type: {
|
|
1236
|
-
type: 'string',
|
|
1237
|
-
enum: ['solid', 'gradient', 'image', 'pattern'],
|
|
1238
|
-
description: '填充类型。不填则按 color→solid / imagePath→image / gradient→gradient 推断',
|
|
1239
|
-
},
|
|
1240
|
-
color: { type: 'string', description: 'type=solid 时的颜色,十六进制如 #FF0000' },
|
|
1241
|
-
imagePath: { type: 'string', description: 'type=image 时的图片路径' },
|
|
1242
|
-
gradient: {
|
|
1243
|
-
type: 'object',
|
|
1244
|
-
description: 'type=gradient 时的渐变配置:{ type:"linear"|"radial", colors:["#FF0000","#00FF00"] }。' +
|
|
1245
|
-
'WPS 只吃前两个颜色,多余的颜色会被忽略(会在提示里说明)',
|
|
1246
|
-
},
|
|
1247
|
-
pattern: { type: 'string', description: 'type=pattern 时的图案名(WPS 不支持,传了会明确报错)' },
|
|
1248
|
-
// 老名字(别名)可能会带过来的历史参数,接受但不推荐
|
|
1249
|
-
background: {
|
|
1250
|
-
type: 'object',
|
|
1251
|
-
description: '(历史形状){type,color,colors,imagePath,pattern},等价于把里面几项平铺到顶层',
|
|
1252
|
-
},
|
|
1253
|
-
},
|
|
1254
|
-
// 刻意不 required['type']:草案里是必填,但那样 5 个旧名就没法走别名(别名不能注入参数),
|
|
1255
|
-
// 而合并的目标恰恰是"旧名无损映射"。改为按参数推断,并在描述里写明。
|
|
1256
|
-
required: [],
|
|
1257
|
-
},
|
|
1258
|
-
};
|
|
1259
|
-
/** 把老形状 background{} 摊平到顶层(只补缺失的键) */
|
|
1260
|
-
function flattenLegacyBackground(args) {
|
|
1261
|
-
const out = { ...args };
|
|
1262
|
-
const bg = args.background;
|
|
1263
|
-
if (bg && typeof bg === 'object') {
|
|
1264
|
-
for (const [k, v] of Object.entries(bg)) {
|
|
1265
|
-
if (out[k] === undefined)
|
|
1266
|
-
out[k] = v;
|
|
1267
|
-
}
|
|
1268
|
-
// 老形状里 "colors" 是渐变色数组
|
|
1269
|
-
if (out.gradient === undefined && Array.isArray(bg.colors)) {
|
|
1270
|
-
out.gradient = { type: 'linear', colors: bg.colors };
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return out;
|
|
1274
|
-
}
|
|
1275
|
-
const setBackgroundHandler = async (args) => {
|
|
1276
|
-
const a = flattenLegacyBackground(args);
|
|
1277
|
-
const target = a.target || 'slide';
|
|
1278
|
-
const slideIndex = a.slideIndex;
|
|
1279
|
-
const color = a.color;
|
|
1280
|
-
const imagePath = a.imagePath;
|
|
1281
|
-
const pattern = a.pattern;
|
|
1282
|
-
const gradient = a.gradient;
|
|
1283
|
-
// type 推断:草案要求必填,但旧名走别名时给不出 type(别名不能注入参数)。
|
|
1284
|
-
// 按"给了什么填什么"推断 —— 唯一有歧义的情况是同时给了多个,那时按 image > gradient > color 取先。
|
|
1285
|
-
const type = a.type ||
|
|
1286
|
-
(imagePath ? 'image' : gradient ? 'gradient' : pattern ? 'pattern' : color ? 'solid' : '');
|
|
1287
|
-
const fail = (msg, err) => ({
|
|
1288
|
-
id: (0, uuid_1.v4)(),
|
|
1289
|
-
success: false,
|
|
1290
|
-
content: [{ type: 'text', text: msg }],
|
|
1291
|
-
error: err ?? msg,
|
|
1292
|
-
});
|
|
1293
|
-
const ok = (text) => ({
|
|
1294
|
-
id: (0, uuid_1.v4)(),
|
|
1295
|
-
success: true,
|
|
1296
|
-
content: [{ type: 'text', text }],
|
|
1297
|
-
});
|
|
1298
|
-
if (!type) {
|
|
1299
|
-
return fail('要说清怎么填:给 color(纯色)/ imagePath(图片)/ gradient(渐变)之一,或显式传 type。' +
|
|
1300
|
-
'示例:{ "target":"slide", "slideIndex":1, "type":"solid", "color":"#003366" }');
|
|
1301
|
-
}
|
|
1302
|
-
if (type === 'pattern') {
|
|
1303
|
-
return fail('WPS COM 没有图案填充的接口,type:"pattern" 无法执行(这不是参数问题,换 solid/gradient/image)。');
|
|
1304
|
-
}
|
|
1305
|
-
if (type === 'solid' && !color)
|
|
1306
|
-
return fail('type=solid 需要 color,例如 "#003366"。');
|
|
1307
|
-
if (type === 'image' && !imagePath)
|
|
1308
|
-
return fail('type=image 需要 imagePath(图片在本机的绝对路径)。');
|
|
1309
|
-
if (type === 'gradient') {
|
|
1310
|
-
const colors = (gradient && gradient.colors) || [];
|
|
1311
|
-
if (!Array.isArray(colors) || colors.length < 2) {
|
|
1312
|
-
return fail('type=gradient 需要 gradient.colors 至少两个颜色,例如 ["#FF0000","#00FF00"]。');
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
if (target === 'master' && type === 'image') {
|
|
1316
|
-
return fail('母版背景不支持图片(WPS 的母版 Fill 只吃纯色/渐变)。要整份文稿用图片背景,用 target:"all"。');
|
|
1317
|
-
}
|
|
1318
|
-
if (target === 'slide' && !slideIndex) {
|
|
1319
|
-
return fail('target=slide 需要 slideIndex(从 1 开始)。要改整份文稿用 target:"all"。');
|
|
1320
|
-
}
|
|
1321
|
-
// 一个内部小包装。注意:动作名走变量 → param-shape-audit(扫 executeMethod 的字面量)看不到这 4 个
|
|
1322
|
-
// 调用点,属于那个脚本自己写明的"动态拼参数抓不到 = 漏报"。所以这里的参数是【手工对着 PS 的读法核过的】:
|
|
1323
|
-
// setMasterBackground 读 color / color1 / color2
|
|
1324
|
-
// setBackgroundColor 读 color / applyToAll
|
|
1325
|
-
// setSlideBackground 读 slideIndex / color / imagePath
|
|
1326
|
-
// getSlideCount 无参数
|
|
1327
|
-
// 改这里的参数名时,请同步改上面这份清单(它就是这几个动作的"参数契约")。
|
|
1328
|
-
const exec = (action, params) => wps_client_1.wpsClient.executeMethod(action, params, wps_1.WpsAppType.PRESENTATION);
|
|
1329
|
-
const warnings = [];
|
|
1330
|
-
const where = target === 'all' ? '整份文稿' : target === 'master' ? '母版' : `第 ${slideIndex} 页`;
|
|
1331
|
-
try {
|
|
1332
|
-
// ---- 母版 ----
|
|
1333
|
-
if (target === 'master') {
|
|
1334
|
-
const params = type === 'gradient'
|
|
1335
|
-
? { color1: gradient.colors[0], color2: gradient.colors[1] }
|
|
1336
|
-
: { color };
|
|
1337
|
-
const r = await exec('setMasterBackground', params);
|
|
1338
|
-
if (!r.success)
|
|
1339
|
-
return fail(`设置母版背景失败: ${r.error}`, r.error);
|
|
1340
|
-
return ok(`母版背景已设置:${type === 'gradient' ? `渐变 ${gradient.colors.slice(0, 2).join(' → ')}` : color}`);
|
|
1341
|
-
}
|
|
1342
|
-
// ---- 整份文稿 ----
|
|
1343
|
-
if (target === 'all') {
|
|
1344
|
-
if (type === 'solid') {
|
|
1345
|
-
const r = await exec('setBackgroundColor', { color, applyToAll: true });
|
|
1346
|
-
if (!r.success)
|
|
1347
|
-
return fail(`设置整份文稿背景失败: ${r.error}`, r.error);
|
|
1348
|
-
return ok(`整份文稿背景已设为 ${color}(applyToAll)`);
|
|
1349
|
-
}
|
|
1350
|
-
// 渐变/图片没有"一次全设"的动作 → 逐页设。先问页数,别拿失败当终止条件。
|
|
1351
|
-
const cnt = await exec('getSlideCount', {});
|
|
1352
|
-
const total = Number((cnt.data && cnt.data.count) || 0);
|
|
1353
|
-
if (!total)
|
|
1354
|
-
return fail('拿不到页数,无法逐页设置背景。');
|
|
1355
|
-
let done = 0;
|
|
1356
|
-
const failedPages = [];
|
|
1357
|
-
for (let i = 1; i <= total; i++) {
|
|
1358
|
-
const r = type === 'image'
|
|
1359
|
-
? await exec('setSlideBackground', { slideIndex: i, imagePath })
|
|
1360
|
-
: await exec('setSlideBackground', {
|
|
1361
|
-
slideIndex: i,
|
|
1362
|
-
color1: gradient.colors[0],
|
|
1363
|
-
color2: gradient.colors[1],
|
|
1364
|
-
});
|
|
1365
|
-
if (r.success)
|
|
1366
|
-
done++;
|
|
1367
|
-
else
|
|
1368
|
-
failedPages.push(i);
|
|
1369
|
-
}
|
|
1370
|
-
if (done === 0)
|
|
1371
|
-
return fail(`整份文稿逐页设置背景全部失败(共 ${total} 页)。`);
|
|
1372
|
-
if (failedPages.length) {
|
|
1373
|
-
warnings.push({
|
|
1374
|
-
step: 'set_background.all',
|
|
1375
|
-
message: `第 ${failedPages.join('、')} 页没设置成功(共 ${total} 页,成功 ${done} 页)`,
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
return {
|
|
1379
|
-
id: (0, uuid_1.v4)(),
|
|
1380
|
-
success: true,
|
|
1381
|
-
content: [{ type: 'text', text: `整份文稿背景已设置:${done}/${total} 页` }],
|
|
1382
|
-
...(warnings.length ? { warnings } : {}),
|
|
1383
|
-
};
|
|
1384
|
-
}
|
|
1385
|
-
// ---- 单页 ----
|
|
1386
|
-
const params = { slideIndex };
|
|
1387
|
-
if (type === 'solid')
|
|
1388
|
-
params.color = color;
|
|
1389
|
-
else if (type === 'image')
|
|
1390
|
-
params.imagePath = imagePath;
|
|
1391
|
-
else {
|
|
1392
|
-
params.color1 = gradient.colors[0];
|
|
1393
|
-
params.color2 = gradient.colors[1];
|
|
1394
|
-
}
|
|
1395
|
-
const r = await exec('setSlideBackground', params);
|
|
1396
|
-
if (!r.success)
|
|
1397
|
-
return fail(`设置背景失败: ${r.error}`, r.error);
|
|
1398
|
-
const detail = type === 'solid' ? `颜色 ${color}` : type === 'image' ? `图片 ${imagePath}` : `渐变 ${gradient.colors.slice(0, 2).join(' → ')}`;
|
|
1399
|
-
if (type === 'gradient' && gradient.colors.length > 2) {
|
|
1400
|
-
warnings.push({ step: 'gradient', message: 'WPS 的渐变只支持两个色标,多余的颜色已忽略' });
|
|
1401
|
-
}
|
|
1402
|
-
return {
|
|
1403
|
-
id: (0, uuid_1.v4)(),
|
|
1404
|
-
success: true,
|
|
1405
|
-
content: [{ type: 'text', text: `背景已设置:${where},${detail}` }],
|
|
1406
|
-
...(warnings.length ? { warnings } : {}),
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
catch (error) {
|
|
1410
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1411
|
-
return fail(`设置背景出错: ${errMsg}`);
|
|
1412
|
-
}
|
|
1413
|
-
};
|
|
1414
|
-
exports.setBackgroundHandler = setBackgroundHandler;
|
|
1415
|
-
// ============================================================
|
|
1416
|
-
// 18. wps_ppt_set_slide_size - 设置幻灯片尺寸
|
|
284
|
+
// 8. wps_ppt_set_slide_size - 设置幻灯片尺寸
|
|
1417
285
|
// ============================================================
|
|
1418
286
|
exports.setSlideSizeDefinition = {
|
|
1419
287
|
name: 'wps_ppt_set_slide_size',
|
|
1420
|
-
description:
|
|
288
|
+
description: `设置演示文稿的幻灯片尺寸(单位:磅)。
|
|
1421
289
|
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
290
|
+
**⚠️ v1.0.5 起单位为磅**(此前版本按像素收并自动 ×0.75 换算成磅)。
|
|
291
|
+
迁移提示:16:9 的 960×540 数值恰好磅/像素相同,旧调用不受影响;
|
|
292
|
+
4:3 旧写法 960×720 现在会得到更大的 960×720 磅版面——4:3 请改传 **720×540**。
|
|
293
|
+
|
|
294
|
+
常用尺寸(磅):
|
|
295
|
+
- 标准(4:3): 宽720, 高540(10×7.5 英寸)
|
|
296
|
+
- 宽屏(16:9): 宽960, 高540(13.3×7.5 英寸)
|
|
1425
297
|
- 宽屏(16:10): 宽960, 高600
|
|
1426
|
-
- A4横版: 宽
|
|
1427
|
-
- A4竖版: 宽
|
|
298
|
+
- A4横版: 宽842, 高595
|
|
299
|
+
- A4竖版: 宽595, 高842
|
|
1428
300
|
|
|
1429
301
|
注意:改尺寸会重排整份文稿,元素可能溢出页面。改完建议 wps_ppt_export_slide_as_image 看一眼。
|
|
1430
302
|
|
|
@@ -1438,11 +310,11 @@ exports.setSlideSizeDefinition = {
|
|
|
1438
310
|
properties: {
|
|
1439
311
|
width: {
|
|
1440
312
|
type: 'number',
|
|
1441
|
-
description: '
|
|
313
|
+
description: '幻灯片宽度(磅)。v1.0.5 起为磅;16:9 用 960,4:3 用 720',
|
|
1442
314
|
},
|
|
1443
315
|
height: {
|
|
1444
316
|
type: 'number',
|
|
1445
|
-
description: '
|
|
317
|
+
description: '幻灯片高度(磅)。v1.0.5 起为磅;16:9 用 540,4:3 用 540',
|
|
1446
318
|
},
|
|
1447
319
|
},
|
|
1448
320
|
required: ['width', 'height'],
|
|
@@ -1450,270 +322,17 @@ exports.setSlideSizeDefinition = {
|
|
|
1450
322
|
};
|
|
1451
323
|
const setSlideSizeHandler = async (args) => {
|
|
1452
324
|
const { width, height } = args;
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
content: [
|
|
1461
|
-
{
|
|
1462
|
-
type: 'text',
|
|
1463
|
-
text: `幻灯片尺寸设置成功!\n宽度: ${width}px\n高度: ${height}px`,
|
|
1464
|
-
},
|
|
1465
|
-
],
|
|
1466
|
-
};
|
|
1467
|
-
}
|
|
1468
|
-
else {
|
|
1469
|
-
return {
|
|
1470
|
-
id: (0, uuid_1.v4)(),
|
|
1471
|
-
success: false,
|
|
1472
|
-
content: [{ type: 'text', text: `设置幻灯片尺寸失败: ${response.error}` }],
|
|
1473
|
-
error: response.error,
|
|
1474
|
-
};
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
catch (error) {
|
|
1478
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1479
|
-
return {
|
|
1480
|
-
id: (0, uuid_1.v4)(),
|
|
1481
|
-
success: false,
|
|
1482
|
-
content: [{ type: 'text', text: `设置幻灯片尺寸出错: ${errMsg}` }],
|
|
1483
|
-
error: errMsg,
|
|
1484
|
-
};
|
|
1485
|
-
}
|
|
325
|
+
const r = await (0, helpers_1.call)(
|
|
326
|
+
// 第 1 期第 2 章第 2 轮:这句原为「仅Windows支持」,是假注释 —— 该动作曾长期不存在于 ps1。第 6 轮已补 case,现在 Windows 上真能用。
|
|
327
|
+
// v1.0.5 起单位为磅(ps1 的 ×0.75 换算已按所有者裁定移除),schema 描述已同步。
|
|
328
|
+
'setSlideSize', { width, height });
|
|
329
|
+
if (!r.ok)
|
|
330
|
+
return (0, helpers_1.fail)((0, helpers_1.errText)('设置幻灯片尺寸失败', r), r.error);
|
|
331
|
+
return (0, helpers_1.ok)(`幻灯片尺寸设置成功!\n宽度: ${width} 磅\n高度: ${height} 磅`, r.warnings);
|
|
1486
332
|
};
|
|
1487
333
|
exports.setSlideSizeHandler = setSlideSizeHandler;
|
|
1488
334
|
// ============================================================
|
|
1489
|
-
//
|
|
1490
|
-
// ============================================================
|
|
1491
|
-
exports.setTransitionDefinition = {
|
|
1492
|
-
name: 'wps_ppt_set_transition',
|
|
1493
|
-
description: `设置幻灯片切换效果:单页 or 整份文稿(第 8 轮合并了切换族 3 个工具)。
|
|
1494
|
-
|
|
1495
|
-
- \`target\`: slide(默认,只改 \`slideIndex\` 那一页)/ all(整份文稿统一)
|
|
1496
|
-
- \`effect\`(**必填**): fade 淡出 / push 推入 / wipe 擦除 / split 拆分 / reveal 揭开 / cover 覆盖 / dissolve 溶解 / curtains 帷幕 / **none 取消切换**
|
|
1497
|
-
|
|
1498
|
-
什么时候用:
|
|
1499
|
-
- "给第1页加个淡出切换" → { target:'slide', slideIndex:1, effect:'fade', duration:1 }
|
|
1500
|
-
- "所有页统一用推入" → { target:'all', effect:'push' }
|
|
1501
|
-
- "第2页不要切换效果" → { target:'slide', slideIndex:2, effect:'none' }
|
|
1502
|
-
|
|
1503
|
-
取消切换用 \`effect:'none'\`,不要去找"删除切换"的工具 —— 切换本来就是"切走时播放的东西",
|
|
1504
|
-
把它设成没有就等价于删掉,而且这样不会因为名字里有"删/删掉"而弹破坏性确认框。
|
|
1505
|
-
|
|
1506
|
-
真限制:没有"切换音效"参数。WPS 的 COM 接口里没有"切走时播一段音频"这个能力
|
|
1507
|
-
(那是 PowerPoint 的 AddMediaObject2),所以本工具不提供该参数 —— 要音效得先在 WPS 里录进切换设置。`,
|
|
1508
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
1509
|
-
inputSchema: {
|
|
1510
|
-
type: 'object',
|
|
1511
|
-
properties: {
|
|
1512
|
-
target: {
|
|
1513
|
-
type: 'string',
|
|
1514
|
-
enum: ['slide', 'all'],
|
|
1515
|
-
description: '作用范围:slide 单页(默认)/ all 整份文稿',
|
|
1516
|
-
},
|
|
1517
|
-
slideIndex: {
|
|
1518
|
-
type: 'number',
|
|
1519
|
-
description: '幻灯片索引(从1开始);target=all 时忽略',
|
|
1520
|
-
},
|
|
1521
|
-
effect: {
|
|
1522
|
-
type: 'string',
|
|
1523
|
-
description: '切换效果:fade / push / wipe / split / reveal / cover / dissolve / curtains;none = 取消切换',
|
|
1524
|
-
},
|
|
1525
|
-
duration: {
|
|
1526
|
-
type: 'number',
|
|
1527
|
-
description: '切换持续时间(秒),默认1秒',
|
|
1528
|
-
},
|
|
1529
|
-
},
|
|
1530
|
-
required: [],
|
|
1531
|
-
},
|
|
1532
|
-
};
|
|
1533
|
-
const TRANS_NAME_MAP = {
|
|
1534
|
-
fade: '淡出', push: '推入', wipe: '擦除', split: '拆分',
|
|
1535
|
-
reveal: '揭开', cover: '覆盖', dissolve: '溶解', curtains: '帷幕',
|
|
1536
|
-
none: '取消切换',
|
|
1537
|
-
};
|
|
1538
|
-
const setTransitionHandler = async (args) => {
|
|
1539
|
-
const { slideIndex, duration } = args;
|
|
1540
|
-
const target = (args.target || 'slide');
|
|
1541
|
-
// 第 2 轮起的旧参数名是 transition;旧名调用经别名进来时带的是它
|
|
1542
|
-
const effect = args.effect || args.transition;
|
|
1543
|
-
if (!effect) {
|
|
1544
|
-
return {
|
|
1545
|
-
id: (0, uuid_1.v4)(),
|
|
1546
|
-
success: false,
|
|
1547
|
-
content: [{ type: 'text', text: `必须给 effect(切换效果名,或 none 表示取消切换)` }],
|
|
1548
|
-
error: 'Missing required parameter: effect',
|
|
1549
|
-
};
|
|
1550
|
-
}
|
|
1551
|
-
if (target === 'slide' && !slideIndex) {
|
|
1552
|
-
return {
|
|
1553
|
-
id: (0, uuid_1.v4)(),
|
|
1554
|
-
success: false,
|
|
1555
|
-
content: [{ type: 'text', text: `target='slide' 时必须给 slideIndex` }],
|
|
1556
|
-
error: 'Missing required parameter: slideIndex',
|
|
1557
|
-
};
|
|
1558
|
-
}
|
|
1559
|
-
try {
|
|
1560
|
-
// 整份文稿走 PS 侧的 applyTransitionToAll:它是独立的动作,
|
|
1561
|
-
// 而 setSlideTransition 的循环版不在这个 case 里,硬塞 all 进去等于让 PS 认一个它不认的键。
|
|
1562
|
-
const response = target === 'all'
|
|
1563
|
-
? await wps_client_1.wpsClient.executeMethod('applyTransitionToAll', { effect, duration: duration || 1 }, wps_1.WpsAppType.PRESENTATION)
|
|
1564
|
-
: await wps_client_1.wpsClient.executeMethod('setSlideTransition', { slideIndex, effect, duration: duration || 1 }, wps_1.WpsAppType.PRESENTATION);
|
|
1565
|
-
if (response.success) {
|
|
1566
|
-
const lines = [
|
|
1567
|
-
`切换效果设置成功!`,
|
|
1568
|
-
target === 'all' ? `范围: 全部幻灯片` : `幻灯片: 第 ${slideIndex} 页`,
|
|
1569
|
-
`切换效果: ${TRANS_NAME_MAP[effect] || effect}`,
|
|
1570
|
-
`持续时间: ${duration || 1} 秒`,
|
|
1571
|
-
];
|
|
1572
|
-
if (response.data && response.data.slideCount) {
|
|
1573
|
-
lines.push(`已应用: ${response.data.slideCount} 页`);
|
|
1574
|
-
}
|
|
1575
|
-
return {
|
|
1576
|
-
id: (0, uuid_1.v4)(),
|
|
1577
|
-
success: true,
|
|
1578
|
-
content: [{ type: 'text', text: lines.join('\n') }],
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
return {
|
|
1582
|
-
id: (0, uuid_1.v4)(),
|
|
1583
|
-
success: false,
|
|
1584
|
-
content: [{ type: 'text', text: `设置切换效果失败: ${response.error}` }],
|
|
1585
|
-
error: response.error,
|
|
1586
|
-
};
|
|
1587
|
-
}
|
|
1588
|
-
catch (error) {
|
|
1589
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1590
|
-
return {
|
|
1591
|
-
id: (0, uuid_1.v4)(),
|
|
1592
|
-
success: false,
|
|
1593
|
-
content: [{ type: 'text', text: `设置切换效果出错: ${errMsg}` }],
|
|
1594
|
-
error: errMsg,
|
|
1595
|
-
};
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
exports.setTransitionHandler = setTransitionHandler;
|
|
1599
|
-
// ============================================================
|
|
1600
|
-
// 21. wps_ppt_set_shape_fill - 设置形状填充颜色
|
|
1601
|
-
// ============================================================
|
|
1602
|
-
exports.setShapeFillDefinition = {
|
|
1603
|
-
name: 'wps_ppt_set_shape_fill',
|
|
1604
|
-
description: `设置幻灯片中指定形状的填充颜色。
|
|
1605
|
-
|
|
1606
|
-
使用场景:
|
|
1607
|
-
- "把第1页的第2个形状填充为红色"
|
|
1608
|
-
- "修改形状背景色为#00FF00"
|
|
1609
|
-
- "设置形状的填充颜色"`,
|
|
1610
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
1611
|
-
inputSchema: {
|
|
1612
|
-
type: 'object',
|
|
1613
|
-
properties: {
|
|
1614
|
-
slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
|
|
1615
|
-
shapeIndex: { type: 'number', description: '形状索引(从1开始)' },
|
|
1616
|
-
color: { type: 'string', description: '填充颜色,十六进制如 #FF0000' },
|
|
1617
|
-
},
|
|
1618
|
-
required: ['slideIndex', 'shapeIndex', 'color'],
|
|
1619
|
-
},
|
|
1620
|
-
};
|
|
1621
|
-
const setShapeFillHandler = async (args) => {
|
|
1622
|
-
const { slideIndex, shapeIndex, color } = args;
|
|
1623
|
-
try {
|
|
1624
|
-
const response = await wps_client_1.wpsClient.executeMethod('setShapeFill', // 第 1 期第 2 章第 2 轮:这句原为「仅Windows支持」,是假注释 —— 该动作曾长期不存在于 ps1。第 6 轮已补 case,现在 Windows 上真能用。
|
|
1625
|
-
{ slideIndex, shapeIndex, color }, wps_1.WpsAppType.PRESENTATION);
|
|
1626
|
-
if (response.success) {
|
|
1627
|
-
return {
|
|
1628
|
-
id: (0, uuid_1.v4)(),
|
|
1629
|
-
success: true,
|
|
1630
|
-
content: [
|
|
1631
|
-
{
|
|
1632
|
-
type: 'text',
|
|
1633
|
-
text: `形状填充颜色设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n填充颜色: ${color}`,
|
|
1634
|
-
},
|
|
1635
|
-
],
|
|
1636
|
-
};
|
|
1637
|
-
}
|
|
1638
|
-
else {
|
|
1639
|
-
return {
|
|
1640
|
-
id: (0, uuid_1.v4)(),
|
|
1641
|
-
success: false,
|
|
1642
|
-
content: [{ type: 'text', text: `设置形状填充失败: ${response.error}` }],
|
|
1643
|
-
error: response.error,
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
catch (error) {
|
|
1648
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1649
|
-
return {
|
|
1650
|
-
id: (0, uuid_1.v4)(),
|
|
1651
|
-
success: false,
|
|
1652
|
-
content: [{ type: 'text', text: `设置形状填充出错: ${errMsg}` }],
|
|
1653
|
-
error: errMsg,
|
|
1654
|
-
};
|
|
1655
|
-
}
|
|
1656
|
-
};
|
|
1657
|
-
exports.setShapeFillHandler = setShapeFillHandler;
|
|
1658
|
-
// ============================================================
|
|
1659
|
-
// 22. wps_ppt_add_speaker_notes - 添加演讲者备注
|
|
1660
|
-
// ============================================================
|
|
1661
|
-
exports.addSpeakerNotesDefinition = {
|
|
1662
|
-
name: 'wps_ppt_add_speaker_notes',
|
|
1663
|
-
description: `添加或追加演讲者备注到指定幻灯片。
|
|
1664
|
-
|
|
1665
|
-
使用场景:
|
|
1666
|
-
- "给第1页添加演讲者备注"
|
|
1667
|
-
- "在备注中写上提示词"
|
|
1668
|
-
- "追加演讲提示到第3页"`,
|
|
1669
|
-
category: tools_1.ToolCategory.PRESENTATION,
|
|
1670
|
-
inputSchema: {
|
|
1671
|
-
type: 'object',
|
|
1672
|
-
properties: {
|
|
1673
|
-
slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
|
|
1674
|
-
notes: { type: 'string', description: '演讲者备注内容' },
|
|
1675
|
-
},
|
|
1676
|
-
required: ['slideIndex', 'notes'],
|
|
1677
|
-
},
|
|
1678
|
-
};
|
|
1679
|
-
const addSpeakerNotesHandler = async (args) => {
|
|
1680
|
-
const { slideIndex, notes } = args;
|
|
1681
|
-
try {
|
|
1682
|
-
const response = await wps_client_1.wpsClient.executeMethod('setSlideNotes', { slideIndex, notes }, wps_1.WpsAppType.PRESENTATION);
|
|
1683
|
-
if (response.success) {
|
|
1684
|
-
return {
|
|
1685
|
-
id: (0, uuid_1.v4)(),
|
|
1686
|
-
success: true,
|
|
1687
|
-
content: [
|
|
1688
|
-
{
|
|
1689
|
-
type: 'text',
|
|
1690
|
-
text: `演讲者备注添加成功!\n幻灯片: 第 ${slideIndex} 页\n备注内容: "${notes.length > 50 ? notes.substring(0, 50) + '...' : notes}"`,
|
|
1691
|
-
},
|
|
1692
|
-
],
|
|
1693
|
-
};
|
|
1694
|
-
}
|
|
1695
|
-
else {
|
|
1696
|
-
return {
|
|
1697
|
-
id: (0, uuid_1.v4)(),
|
|
1698
|
-
success: false,
|
|
1699
|
-
content: [{ type: 'text', text: `添加演讲者备注失败: ${response.error}` }],
|
|
1700
|
-
error: response.error,
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
catch (error) {
|
|
1705
|
-
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1706
|
-
return {
|
|
1707
|
-
id: (0, uuid_1.v4)(),
|
|
1708
|
-
success: false,
|
|
1709
|
-
content: [{ type: 'text', text: `添加演讲者备注出错: ${errMsg}` }],
|
|
1710
|
-
error: errMsg,
|
|
1711
|
-
};
|
|
1712
|
-
}
|
|
1713
|
-
};
|
|
1714
|
-
exports.addSpeakerNotesHandler = addSpeakerNotesHandler;
|
|
1715
|
-
// ============================================================
|
|
1716
|
-
// 导出所有幻灯片操作相关的Tools
|
|
335
|
+
// 导出所有幻灯片页操作相关的Tools
|
|
1717
336
|
// ============================================================
|
|
1718
337
|
exports.slideOpsTools = [
|
|
1719
338
|
{ definition: exports.deleteSlideDefinition, handler: exports.deleteSlideHandler },
|
|
@@ -1723,18 +342,7 @@ exports.slideOpsTools = [
|
|
|
1723
342
|
{ definition: exports.switchSlideDefinition, handler: exports.switchSlideHandler },
|
|
1724
343
|
{ definition: exports.setSlideLayoutDefinition, handler: exports.setSlideLayoutHandler },
|
|
1725
344
|
{ definition: exports.getSlideNotesDefinition, handler: exports.getSlideNotesHandler },
|
|
1726
|
-
{ definition: exports.addShapeDefinition, handler: exports.addShapeHandler },
|
|
1727
|
-
{ definition: exports.setShapeStyleDefinition, handler: exports.setShapeStyleHandler },
|
|
1728
|
-
{ definition: exports.addTextboxDefinition, handler: exports.addTextboxHandler },
|
|
1729
|
-
{ definition: exports.setSlideTitleDefinition, handler: exports.setSlideTitleHandler },
|
|
1730
|
-
{ definition: exports.insertImageDefinition, handler: exports.insertImageHandler },
|
|
1731
|
-
{ definition: exports.setShapeTextDefinition, handler: exports.setShapeTextHandler },
|
|
1732
|
-
{ definition: exports.setAnimationDefinition, handler: exports.setAnimationHandler },
|
|
1733
|
-
{ definition: exports.setBackgroundDefinition, handler: exports.setBackgroundHandler },
|
|
1734
345
|
{ definition: exports.setSlideSizeDefinition, handler: exports.setSlideSizeHandler },
|
|
1735
|
-
{ definition: exports.setTransitionDefinition, handler: exports.setTransitionHandler },
|
|
1736
|
-
{ definition: exports.setShapeFillDefinition, handler: exports.setShapeFillHandler },
|
|
1737
|
-
{ definition: exports.addSpeakerNotesDefinition, handler: exports.addSpeakerNotesHandler },
|
|
1738
346
|
];
|
|
1739
347
|
exports.default = exports.slideOpsTools;
|
|
1740
348
|
//# sourceMappingURL=slide-ops.js.map
|