dsh-ppt-canvas 1.0.0 → 1.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ # 更新记录
2
+
3
+ ## 1.1.1 · 2026-11-26
4
+
5
+ - 修复窄浮窗中关闭按钮和工具栏被裁切的问题。点击“返回 DSH”可收起工作台,正在保存的文字和批注草稿会保留。
6
+ - 显示文稿保存位置,支持导出已保存的 PPTX 和批注记录,以及在下次打开时继续编辑原先的导入副本。
7
+
8
+ ## 1.1.0 · 2026-11-14
9
+
10
+ - 新增多点批注工作流:跨页点击对象或框选区域,逐处填写要求,一次发送带编号截图、坐标和目标信息。
11
+ - AI 方案在原画布检查,支持修改前后切换、逐处查看结果、整批确认保存与一步撤销。
12
+ - 新增持久导入副本;拖入 `.pptx` 即可打开,兼容有路径与无路径的文件来源,失败保留当前编辑与草稿。
13
+ - 更新浅深主题工作台、目标旁批注卡、摘要侧栏、键盘焦点、触控板连续缩放和逐页视角恢复。
14
+ - 修复异步保存抢焦点、数值预览竞态、文字描边挤压、透明渐变变色和显式无线条重现等问题。
15
+ - 更新中英文 README、界面截图与市场截图索引,继续保持零额外运行时依赖。
16
+
17
+ 验证:382 项最终通过,Mac、DSH/AI 按约定仿真;Windows 使用本机 Chromium、真实 Host 与 LibreOffice。主题阴影、复杂图表与混合排版在轻量操控预览中仍可能有差异,精确图加载后展示原稿效果。完整记录见 [界面精修验收](docs/UI-POLISH-ACCEPTANCE.md)。
18
+
19
+ ## 1.0.0
20
+
21
+ 初始公开版本:PPT 元素选择、就地编辑、AI 协作及字节级撤销/重做。
package/README.en.md ADDED
@@ -0,0 +1,122 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/icon.svg" alt="dsh-ppt-canvas" width="112" height="112">
3
+ </p>
4
+ <h1 align="center">dsh-ppt-canvas</h1>
5
+
6
+ <p align="center">
7
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/README.md">简体中文</a> · <strong>English</strong>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/package.json"><img src="https://img.shields.io/badge/version-1.1.1-2563eb?style=flat-square" alt="Version 1.1.1"></a>
12
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/SIMULATION-ACCEPTANCE.md"><img src="https://img.shields.io/badge/DSH-Desktop%2FWeb%20simulation-0f766e?style=flat-square" alt="DSH Desktop / Web: simulated validation"></a>
13
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/package.json"><img src="https://img.shields.io/badge/Node-22%2B-337a48?style=flat-square&amp;logo=nodedotjs&amp;logoColor=white" alt="Node 22+"></a>
14
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-64748b?style=flat-square" alt="MIT license"></a>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <strong>Mark what needs changing. Review the AI proposal. Save the batch.</strong><br>
19
+ A PowerPoint editing workbench for DeepSeek Harness.
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="#quick-start"><img src="https://img.shields.io/badge/Quick_Start-2563eb?style=for-the-badge" alt="Quick start"></a>
24
+ <a href="#how-it-works"><img src="https://img.shields.io/badge/How_It_Works-0f766e?style=for-the-badge" alt="How it works"></a>
25
+ <a href="#documentation"><img src="https://img.shields.io/badge/Documentation-334155?style=for-the-badge" alt="Documentation"></a>
26
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/issues"><img src="https://img.shields.io/badge/Issues-334155?style=for-the-badge" alt="Report an issue"></a>
27
+ </p>
28
+
29
+ ---
30
+
31
+ **v1.1.1**, for DSH desktop/web profiles. Windows validation uses local Chromium, the real document engine and LibreOffice. Mac input/paths and DSH/AI sessions use simulation; native Mac and live DSH platform compatibility remain unverified.
32
+
33
+ - **Direct editing**: select, move, resize and rotate objects; edit text, align selections and undo with byte snapshots.
34
+ - **Annotations across pages**: mark objects or regions and send separate instructions with real page images, numbers and coordinates.
35
+ - **Review before saving**: compare before/after on the original canvas, inspect each result and confirm one batch with one-step undo.
36
+ - **Continuous navigation**: zoom around the pointer, pan with a trackpad, retain page views and local drafts, and follow light/dark themes.
37
+
38
+ <a id="how-it-works"></a>
39
+
40
+ ## How it works
41
+
42
+ Open a `.pptx` → edit directly or annotate changes → send to a DSH session → inspect the proposal → confirm and save.
43
+
44
+ ![Light workbench with page navigation and annotation summaries](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/workbench-light.png)
45
+
46
+ <details>
47
+ <summary>Dark theme, proposal review and compact view</summary>
48
+
49
+ ![Dark workbench](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/workbench-dark.png)
50
+
51
+ ![Proposal review on the original canvas](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/annotation-review.png)
52
+
53
+ ![Compact workbench and sidebar editor](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/workbench-compact.png)
54
+
55
+ </details>
56
+
57
+ Screenshots use the same components and real document engine in a local preview. The review image uses fixed AI simulation, not a live model. Gestures use a lightweight preview; an exact image replaces it when ready. Assess complex theme shadows, charts and mixed text layout in the exact preview.
58
+
59
+ <a id="quick-start"></a>
60
+
61
+ ## Installation
62
+
63
+ Search the plugin market for the npm package **`dsh-ppt-canvas`**, or install/update through the official CLI:
64
+
65
+ ```powershell
66
+ dsh plugin --profile desktop add dsh-ppt-canvas@1.1.1
67
+ ```
68
+
69
+ Use `web` instead of `desktop` for DSH Web, then restart that DSH profile. Prepare **Node.js 22+** and **LibreOffice**. Exact previews and images sent to AI require LibreOffice; the selected model must accept image input. The plugin has no additional npm runtime dependencies.
70
+
71
+ See the [development guide][development] for source installation and diagnostics.
72
+
73
+ ## Use from DSH
74
+
75
+ 1. Click **PPT Canvas** in the sidebar footer, or drop one `.pptx` on its entry, minimized launcher or workbench. Alternatively, choose **More → Open local presentation**.
76
+ 2. Click to select; double-click, Enter or F2 to edit text. Drag handles to resize, or use properties to adjust position and style. Manual edits save directly.
77
+ 3. Press **A** to mark an object or region and enter its instructions. Continue on other pages. Enter adds a line; Ctrl/⌘ + Enter finishes the note **without sending it**. One editor moves into the sidebar when the viewport is narrow or space is insufficient, preserving text selection.
78
+ 4. Select notes in the sidebar and send the batch. Check **Before/After** and **Previous/Next change**, then confirm the batch. Generating or discarding a proposal does not write the deck.
79
+ 5. Choose **Return to DSH** in the top-right corner to collapse the workbench. With focus on the canvas, Esc dismisses the current interaction or selection first. Reopen the workbench to resume editing.
80
+
81
+ The title bar identifies the save destination. Choose **More → Export saved PPTX** to download the edited copy, or export annotation drafts and completed rounds as JSON. After restarting, **Continue last presentation** reopens the saved file and its local drafts.
82
+
83
+ | Action | Shortcut |
84
+ | --- | --- |
85
+ | Select / annotate / hand | V / A / H |
86
+ | Add to selection | Shift or Ctrl/⌘ + click |
87
+ | Finish editing / cancel | Ctrl/⌘ + Enter / Esc |
88
+ | Undo / redo | Ctrl/⌘ + Z / Ctrl/⌘ + Shift + Z |
89
+ | Zoom / pan | Ctrl/⌘ + wheel; two-finger scroll, Space + drag or middle button |
90
+
91
+ **Files and limits:** `.pptx` only, **80 MiB** per file, one open deck. A real local path opens the original file for editing. When the browser provides only file contents, a persistent **imported copy** is opened and labeled in the title bar. Copies default to `~/.dsh/ppt-canvas/imports/`; `DSH_PPT_DATA_ROOT` overrides the data root.
92
+
93
+ Batches normally allow **4 pages**, subject to lower host image limits. Limits, unsupported changes, conflicts and invalid anchors are reported without deleting drafts. Drafts and the latest 30 batch records stay in this device's localStorage, not cloud sync or native PPT comments. Undo retains up to 50 steps. This edits existing decks; it does not provide full-deck generation from themes/outlines, new pages or local image insertion. See the [protocol and capability limits][contract].
94
+
95
+ <a id="documentation"></a>
96
+
97
+ ## Documentation
98
+
99
+ - [Development guide][development]: layout, build, diagnostics and isolated tests.
100
+ - [Protocol and capabilities][contract]: Deck, patches, annotation scope, confirmation and storage.
101
+ - [UI acceptance][polish] · [Import acceptance][import] · [Mac and DSH simulation scope][simulation].
102
+
103
+ Detailed technical documentation is currently in Chinese.
104
+
105
+ ## Development
106
+
107
+ ```powershell
108
+ npm ci
109
+ npm run build
110
+ npm test
111
+ npm run preview
112
+ ```
113
+
114
+ Requires local Chromium and LibreOffice. The preview edits a disposable deck with fixed AI simulation; the plugin uses DSH sessions. All **387 checks passed with zero skips** for 1.1.1, including narrow-window exit, failed-save recovery, PPTX downloads and annotation recovery.
115
+
116
+ [Report an issue](https://github.com/hg1048596-pixel/dsh-ppt-canvas/issues) · [MIT License](https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/LICENSE)
117
+
118
+ [development]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/DEVELOPMENT.md
119
+ [contract]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/CONTRACT.md
120
+ [polish]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/UI-POLISH-ACCEPTANCE.md
121
+ [import]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/IMPORT-ACCEPTANCE.md
122
+ [simulation]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/SIMULATION-ACCEPTANCE.md
package/README.md CHANGED
@@ -1,286 +1,120 @@
1
- # dsh-ppt-canvas
2
-
3
- > DeepSeek Harness 插件:在 PPT 画布上**点选 / 框选**组件(文字、色块、图片、线条、表格),
4
- > 输入一句自然语言修改要求,由 AI 生成具体的修改方案并**实时落到 .pptx 文件与画布**。
5
- > 选择状态、AI 结果、PPT 文档三方同步,带撤销/重做与完整的错误处理。
6
-
7
- 灵感来自腾讯 WorkBuddy 的「人机双写」(V5.3.5,2026 07 30 发布)中的 PPT 能力:点选或框选元素 → 下达指令 → 只改选区。
8
- 本插件把它做成 DSH 的原生插件:**改的是磁盘上的真实 .pptx**,不是渲染出来的中间产物。
9
-
10
- ![dsh-ppt-canvas 协同编辑画布](assets/screenshot-1.png)
11
-
12
- > 上图:左侧页面缩略图、中间画布(LibreOffice 精确渲染)、右侧属性面板,最右是折叠起来的对话转播栏;
13
- > 底部是 AI 修改指令框。画布上选中的文本框(`textbox 34`)坐标/字号/填充都可在右侧直接改。
14
-
15
-
16
-
17
- ## ✨ 功能
18
-
19
- | 能力 | 说明 |
20
- | | |
21
- | **可视化选择** | 画布按 .pptx 的真实几何/样式渲染每页元素:文本框、色块(含圆角/描边/渐变)、图片(含裁剪)、线条、表格、组合 |
22
- | **单击选中** | 点击任一元素即选中,2px 主色描边 + 四角把手实时高亮;悬停显示虚线预览 |
23
- | **框选(marquee)** | 空白处拖拽出选框,与选框相交的元素全部选中 |
24
- | **多选 / 批量** | `Shift/Ctrl + 点击` 增删;属性面板出现「批量对齐」(左右/居中/顶底/水平等距) |
25
- | **选整页** | 点击页面缩略图左上角「整页」,一次选中该页全部元素(对应 WorkBuddy 的「选页做 AI 编辑」) |
26
- | **拖拽打开** | 把 `.pptx` 直接拖到面板上即可打开;拖拽时整块界面给出投放提示 |
27
- | **可拖动浮窗** | 面板标题栏可拖动、右下角可缩放,位置与尺寸记忆在 localStorage。**启动时一律最小化**(只留右下角「PPT 画布」入口),打开文稿也不会自动弹出来挡界面 |
28
- | **对话转播** | 右侧把当前会话的对话内容按普通对话形式转播(你 / AI 两条角色),推理过程弱化为附注;不再拆成「思考过程 / 回复」两栏 |
29
- | **PPT 意图提示** | 会话里提到做/改 PPT(PPT、演示文稿、幻灯片…)且画布没打开时,右下角弹出「看起来你在做 PPT · 打开画布 / 不用了」;插件自己发的指令不会触发 |
30
- | **自然语言指令** | 指令框输入要求,`Enter` 直接发送(`Shift+Enter` 换行);「加入待发」可把多条攒起来一起发 |
31
- | **选区上下文** | 选中元素的**位置、尺寸、样式、层级 z、文本内容**随指令一起交给 AI(不需要截图或复述内容) |
32
- | **AI 修改方案** | AI 通过 `ppt_canvas_context` 取回选区,产出 `ops` 数组,再用 `ppt_canvas_apply` 落盘;复杂方案可先 `dryRun` 试算 |
33
- | **实时同步** | 落盘后画布自动刷新到新 rev;AI 刚改动的元素淡黄色呼吸高亮 3 秒(面板每 4 秒轮询 rev) |
34
- | **撤销 / 重做** | Host 侧字节级快照(每次写盘前留档),`Ctrl+Z` / `Ctrl+Shift+Z`,最多 50 步 |
35
- | **错误处理** | 逐条校验错误、版本冲突(staleRev)、文件占用、AI 未产出方案 —— 都有明确提示与「重试」 |
36
-
37
-
38
-
39
- ## 🚀 安装
40
-
41
- ### 方式一:安装到当前 profile(推荐)
42
-
43
- ```powershell
44
- node tools/install-profile.mjs profile desktop
45
- ```
46
-
47
- 脚本做两件幂等的事:在 `~/.dsh/profiles/<profile>/node_modules` 下建一个指向本仓库的
48
- junction,并把包名加进 profile `package.json` 的 `dsh.profile.bundles`。
49
- (`dsh plugin add` 也可以,但本机 profile 的 node_modules 是用 pnpm 从
50
- `~/.pnpm/store/v11` link 出来的,pnpm 11 默认找 `%LOCALAPPDATA%\pnpm\store`,
51
- 会以 `ERR_PNPM_UNEXPECTED_STORE` 失败——本插件零依赖,所以直接建 junction 更稳。)
52
-
53
- 卸载:`node tools/install-profile.mjs profile desktop uninstall`
54
-
55
- 安装后**重启 DSH**(新增 loader 行需要重新 boot)。之后:
56
-
57
- 侧边栏底部出现 **▦ PPT 画布** 按钮;
58
- 对话里 AI 会多出 4 个工具:`ppt_canvas_open` / `ppt_canvas_context` / `ppt_canvas_apply` / `ppt_canvas_history`。
59
-
60
- 验证装好了:
61
-
62
- ```powershell
63
- # Host 路由应在(未重启时会 404)
64
- curl.exe -s http://127.0.0.1:19387/dsh ppt/api/selftest
65
- # 客户端 bundle 应在
66
- curl.exe -s -o NUL -w "%{http_code}" http://127.0.0.1:19387/plugins/dsh-ppt-canvas/client.js
67
- # 或者直接跑加载测试
68
- node tests/host-load.test.mjs
69
- ```
70
-
71
- ### 方式二:改客户端即时生效(开发用)
72
-
73
- `plugin/client.js` 改动**不需要重启**:DSH 的 client modules 每次请求都重读文件,HMR 会按内容 hash 热替换。
74
- 只有 `package.json` 的 `dsh.client` 声明、或 cordis 加载行变化才需要重启。
75
-
76
- ```powershell
77
- # 改完 client/ 下的源码后同步到 plugin/(内联 CSS + 复制引擎)
78
- node tools/sync-plugin.mjs
79
- ```
80
-
81
-
82
-
83
- ## 🖱 用法
84
-
85
- 1. 打开面板:点侧边栏底部 **▦ PPT 画布**(或面板最小化后右下角的「PPT 画布」启动器)。
86
- 2. 打开文件,三种方式任选:
87
- **拖拽**:把 `.pptx` 直接拖到面板上(拖进去时整块界面会变蓝并提示);
88
- **打开**:点「打开」走系统文件选择(DSH 的目录选择服务,返回绝对路径);
89
- **演示文稿**:打开内置示例(会复制到 `~/.dsh/ppt-canvas/`)。
90
- 插件直接读写这个文件,每次修改前自动留档(可撤销)。**建议先备份**。
91
- 3. 选择元素:点选 / `Shift+点击` 多选 / 空白处拖拽框选 / 缩略图「整页」。
92
- 4. 输入指令,回车发送(`Shift+Enter` 换行)。例:
93
- `把标题改成红色并右对齐`
94
- `这三个色块统一成品牌蓝 #1A73E8,圆角 8`
95
- `把这行字缩小到 14px 并居中`
96
- `把这张图片右移 40px,并置顶`
97
- `把选中的两个文本框左对齐、水平等距`
98
- 5. AI 改完后画布自动刷新,改动元素高亮;不满意就 `Ctrl+Z`。
99
-
100
- 也可以在对话里直接说「打开 D:\work\deck.pptx」,AI 会调用 `ppt_canvas_open`。
101
-
102
- ### 独立桌面窗口(已移除)
103
-
104
- 这一版**不包含**「独立桌面窗口」功能。它曾经实现过(Electron 起一个可自由拖动、
105
- 位置记忆的窗口),但在这台机器上始终无法通过宿主侧的验证,已按要求整体撤掉。
106
-
107
- 源文件与恢复步骤都保存在 `archive/standalone-window/`(含一份 `README.md` 说明
108
- 当时踩过的坑:`ELECTRON_RUN_AS_NODE` 必须以删除键的方式清理、被 vendor 的裸
109
- `electron.exe` 不提供 `require('electron')`、`plugin/index.js` 会遮蔽入口等)。
110
-
111
- `tests/no-window.test.mjs` 会守住这个边界:面板里不再有入口按钮、没有窗口路由、
112
- `ppt_canvas_window` 工具已注销、归档文件仍然可恢复。
113
-
114
-
115
-
116
- ## 🧠 它是怎么工作的
117
-
118
- ```
119
- Client half (plugin/client.js) Host half (host/*.js)
120
- ┌──────────────────────────┐ ┌─────────────────────────────┐
121
- │ 画布:按 Deck 模型渲染 │ POST /dsh ppt/api │ api.js HTTP 路由 │
122
- │ 选择:点选/框选/多选 │ ──────────────────► │ deck store.js 唯一权威 │
123
- │ 指令框 + 撤销/重做 UI │ ◄────────────────── │ pptx read.js OOXML → Deck │
124
- └──────────────────────────┘ Deck / ApplyResult │ pptx write.js Patch → OOXML│
125
- │ │ zip.js / xml.js 自研底层 │
126
- │ session.prompt(...) │ history.js 字节级快照 │
127
- ▼ │ tools.js 4 个模型工具 │
128
- ┌───────────┐ ppt_canvas_context/apply │ standalone server.js │
129
- │ DeepSeek │ ──────────────────────────────│ 独立 loopback :19488 │
130
- └───────────┘ └─────────────────────────────┘
131
- ```
132
-
133
- **两条 HTTP 通道,客户端自动择一。** 插件优先访问自起的独立 loopback 服务
134
- (`127.0.0.1:19488`,端口被占用则顺延),失败才回退到宿主路由 `/dsh ppt/api`。
135
- 这样即使宿主的路由表没有注册(受限宿主下很常见),画布也能连上 Host。
136
-
137
- **界面层与宿主解耦。** `client/app.js` 里没有任何 DSH 专有 API:`React` / `ReactDOM`
138
- 由 `plugin/client.js` 从 DSH 的模块表取,`prompt` 走 `session.prompt`,`apiBase` 指向 Host
139
- 通道。`client/app.js` 与 `client/ppt-style.js` 在构建时被内联进 `plugin/client.js`。
140
-
141
- 关键设计:
142
-
143
- **Host 是唯一权威**。磁盘上的 .pptx 是事实,`rev` 每次成功写盘 +1;客户端永远以 Host 返回的 Deck 覆盖本地模型,所以不存在「三方各说各话」。
144
- **选区先暂存,再交给 AI**。客户端发指令前把选区 POST 到 `/dsh ppt/api/context` 拿到 `requestId`,AI 只能通过 `ppt_canvas_context(requestId)` 取回——这样用户消息里不需要塞大段 JSON,也便于审计「AI 是否真的读了选区」。
145
- **校验先于写入**。`applyPatch` 先在内存里跑完整校验与试算,任何一条 op 不合法就整包拒绝并返回逐条原因,文件一个字节都不动。
146
- **编辑作用在解析出来的原树上**。不是正则替换也不是重建 XML,所以不认识的属性、扩展、关系、母版引用都不会丢;未触碰的页字节级不变(有测试守着)。
147
- **撤销存字节不存 diff**。OOXML 补丁的逆运算极易失真,回放写盘前的完整字节是唯一无损的做法。
148
-
149
- ### 为什么不用 npm 依赖
150
-
151
- 插件以 link 方式安装在 profile 的 `node_modules` 下,解析不到宿主包,也不方便带依赖。
152
- 所以 ZIP 读写(`node:zlib` + 自研中央目录解析)、XML 保前缀解析、PPTX 读写全部自研,只依赖 `node:` 内建模块。
153
-
154
-
155
-
156
- ## 📋 Patch 能力(AI 可用的修改指令)
157
-
158
- | op | 作用 |
159
- | | |
160
- | `setText` | 替换整段文本(保留原 run 样式,自动处理 `endParaRPr`) |
161
- | `setTextStyle` | 颜色 / 字号 / 粗体 / 斜体 / 下划线 / 对齐 / 字体(同时写 `a:latin` 与 `a:ea`) |
162
- | `setFill` | 纯色填充(`#RRGGBB`),或 `null` 清空 |
163
- | `setLine` | 描边颜色 / 线宽 / 线型 |
164
- | `setGeometry` | 绝对位置与尺寸(px)、旋转角度 |
165
- | `move` / `resize` | 相对位移 / 相对缩放 |
166
- | `align` | 左/水平居中/右/顶/垂直居中/底对齐,水平或垂直等距 |
167
- | `setZ` / `bringToFront` / `sendToBack` | 层级调整(z = 绘制顺序,与 `p:spTree` 顺序一致) |
168
- | `duplicate` / `remove` | 复制(自动分配新的 `cNvPr` id)/ 删除 |
169
-
170
- 单位约定:**px(96 DPI)**,`1px = 9525 EMU`。完整契约见 [docs/CONTRACT.md](docs/CONTRACT.md)。
171
-
172
-
173
-
174
- ## 🧪 测试
175
-
176
- ```powershell
177
- node tools/test-all.mjs
178
- ```
179
-
180
- 七个套件 + 一个同步校验,全绿才算通过(当前 **137 项全绿**):
181
-
182
- | 套件 | 项数 | 覆盖 |
183
- | | | |
184
- | `tests/engine.test.mjs` | 35 | XML 往返、zip 字节级往返、fixture 解析、补丁应用与回读、校验失败不落盘、`dryRun`、撤销/重做字节还原、CJK 空格保真、未触碰页字节不变、母版文本继承、占位符二级几何继承、逐页主题索引(多母版取色)、文字样式保真(逐段/空行/diff)、fill/line/文本类 op 的能力校验 |
185
- | `tests/api.test.mjs` | 33 | 真实 `node:http` 服务器 + 全链路:open → deck → context → apply(dryRun) → apply → history → staleRev → undo/redo → media → selftest;外部改动检测与 `staleFile`、并发写、`/api/files`、render 令牌与越界、非 loopback 拒绝、CSRF(来源白名单 + JSON content-type)、坏 JSON |
186
- | `tests/concurrency.test.mjs` | 8 | 并发 apply 不丢改动、失败不阻断队列、undo 走同一队列、写盘失败不推进游标、包解析缓存失效、context 大小上限、deck LRU |
187
- | `tests/client-harness.mjs` | 18 | 客户端 bundle 冒烟:经典脚本形态、CSS/应用层内联、factory 导出形状、插槽注册、浮窗最小化/展开、标题栏拖动、无选中时发送禁用、会话菜单能渲染、AI 面板多状态(对话转播/空态/折叠)、默认最小化、PPT 意图提示卡、外部改动轮询触发的自动重载、发送后 sending 及时释放、文件对话框取消能收尾、就地编辑器 ×zoom 定位、失焦提交与无变化守卫、独立窗口入口确已移除 |
188
- | `tests/css.test.mjs` | 4 | CSS 模板结构:大括号配对、规则头未被注释/连接符截断、关键规则仍存在、注释成对 |
189
- | `tests/no-window.test.mjs` | 6 | 独立窗口已移除的回归:窗口模块与 bundle 均已删除、归档文件仍可恢复、host 无窗口路由/启动器残留、面板无入口按钮、`ppt_canvas_window` 已注销、`/api/window` 明确 404 |
190
- | `tests/host-load.test.mjs` | 10 | 安装后加载:`plugin/` 自包含导入、只允许 `./` `node:`、`plugin/index.js` 不得存在(会遮蔽入口)、`apply(ctx)` 装配路由与 4 个工具、缺 `webServer` 时优雅降级、工具可执行、`/api/requests` 诊断、profile 安装位置可解析 |
191
- | `tests/render.test.mjs` | 8 | LibreOffice 精确渲染:`promoteSlide` 外科式改写(其余部件写盘回读后仍一致)、页号↔部件映射、缓存命中与失效、缓存淘汰(清中间产物 + PNG 上限);**未装 LibreOffice 时端到端部分会跳过**(见下) |
192
- | `tools/sync-plugin.mjs --check` | — | `plugin/` 是否与 `host/`、`client/` 源同步 |
193
-
194
- > ⚠️ `render` 的端到端 3 条依赖本机安装 LibreOffice;没有时会打印 skip 并以 0 退出
195
- > (`test-all` 仍显示 OK)。这是已知的假绿点,尚未加 CI 闸门。
196
-
197
-
198
- fixture 由 `tools/build-demo-pptx.py`(python pptx,仅用于造测试素材)+ `tools/demo-deck.json` 生成;
199
- 插件本身运行时不依赖 Python。
200
-
201
- ```powershell
202
- $py = "C:\Users\<user>\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\python\python.exe"
203
- & $py tools/build-demo-pptx.py tests/fixtures/demo.pptx
204
- ```
205
-
206
- 诊断:
207
-
208
- ```powershell
209
- node tools/inspect-deck.mjs tests/fixtures/demo.pptx # 打印解析出来的 Deck
210
- node tools/inspect-deck.mjs tests/fixtures/demo.pptx json # 完整 JSON
211
- ```
212
-
213
- 运行中自检:`GET http://127.0.0.1:19387/dsh ppt/api/selftest`。
214
-
215
-
216
-
217
- ## 📁 目录结构
218
-
219
- ```
220
- dsh-ppt-canvas/
221
- ├── package.json # dsh.bundle.patch + dsh.client 声明
222
- ├── cordis.patch.yml # loader 行:insert id=ppt-canvas
223
- ├── docs/CONTRACT.md # 冻结契约:Deck / SelectionElement / Patch / HTTP API
224
- ├── host/ # Host 引擎(真源)
225
- │ ├── index.js # 插件入口:装配独立服务、宿主路由与模型工具
226
- │ ├── standalone server.js # 自起的 loopback API 服务(127.0.0.1:19488,主通道)
227
- │ ├── api.js # /dsh ppt/* 路由 + loopback 校验 + 请求诊断环形缓冲
228
- │ ├── deck store.js # 唯一权威:打开/补丁/撤销/上下文暂存/原子写盘
229
- │ ├── pptx read.js # OOXML → Deck 模型
230
- │ ├── pptx write.js # Patch → OOXML(校验先于写入)
231
- │ ├── zip.js # 自研 ZIP 读写(node:zlib)
232
- │ ├── xml.js # 自研保前缀 XML 层
233
- │ ├── history.js # 字节级撤销/重做快照
234
- │ ├── tools.js # 4 个模型工具
235
- │ ├── demo.js # 内置演示文稿
236
- │ └── selftest.js # /api/selftest 报告
237
- ├── client/
238
- │ ├── app.js # 界面层(无 DSH 专有 API,宿主能力靠构造参数注入)
239
- │ ├── client.js # DSH 客户端插件入口(注入宿主能力 + 浮窗外壳)
240
- │ └── ppt style.js # 样式(构建时内联进 client bundle)
241
- ├── plugin/ # 随包分发目录(DSH 真正加载这里)
242
- │ ├── host.js # 入口(host/index.js 的逐字节副本)
243
- │ ├── client.js # 客户端 bundle(含内联 CSS + 界面层)
244
- │ ├── *.js / *.cjs # 由 tools/sync-plugin.mjs 从 host/ 同步
245
- │ └── assets/demo.pptx # 内置演示文稿
246
- ├── archive/standalone-window/ # 已移除的独立窗口功能(源文件 + 恢复说明)
247
- ├── tools/
248
- │ ├── install profile.mjs # 装进 DSH profile(junction + bundles,幂等)
249
- │ ├── sync plugin.mjs # 源 → plugin/ 同步( check 只校验)
250
- │ ├── build client.mjs # client bundle 的内联生成
251
- │ ├── test all.mjs # 跑全部测试
252
- │ ├── build demo pptx.py # fixture 生成(仅测试用)
253
- │ ├── demo-deck.json # fixture 设计稿
254
- │ └── inspect deck.mjs # 打印 Deck 模型
255
- └── tests/
256
- ├── engine.test.mjs
257
- ├── api.test.mjs
258
- ├── client-harness.mjs
259
- ├── no-window.test.mjs
260
- ├── host load.test.mjs
261
- ```
262
-
263
-
264
-
265
- ## ⚠️ 限制与已知问题
266
-
267
- - **AI 编辑的是原文件**。插件每次写盘前留档在临时目录(可撤销 50 步),但撤销栈不跨 DSH 重启;重要文件请先备份。
268
- - **渲染是保真近似,不是像素级还原**:主题色/母版继承、SmartArt、图表、艺术字、3D、动画不会渲染成最终观感。图表与组合在画布上是占位标记,可以选择、可以移动/删除,但改不了内部数据。
269
- - **文本溢出只给告警**(按 CJK=1.0em / ASCII=0.55em 估算),不会自动缩排。
270
- - **只处理一个打开中的文档**(多文档需要改 `deck-store.js` 的 `current`)。
271
- - **写盘需要文件未被独占**:PowerPoint 打开着该文件时写入会失败,插件会提示并保留方案供重试。
272
- - **AI 可能不调用工具**:如果它只回了一段文字而没调 `ppt_canvas_apply`,插件会提示「AI 没有返回修改方案」并提供重试;属性面板可以直接手动改。
273
- - **浏览器里拖拽拿不到本地路径**:这是浏览器的隐私限制(Chromium 只把本地路径交给 Electron
274
- 渲染进程)。所以面板里的拖拽只在能拿到路径时生效;拿不到时插件会明确提示改用「打开」按钮选文件。
275
- - **独立桌面窗口已移除**:源文件与恢复步骤保留在 `archive/standalone-window/`(含一份说明,
276
- 记录当时踩过的坑,例如 `ELECTRON_RUN_AS_NODE` 必须整键删除、被 vendor 的裸 `electron.exe`
277
- 不提供 `require('electron')`、`plugin/index.js` 会遮蔽真正的入口)。
278
- - **受限宿主下宿主路由可能不注册**:DSH Desktop 会给 WebServer 的路由套一层准入,实测插件路由
279
- 在这类宿主里拿不到请求。因此插件**优先**走自起的独立 loopback 服务(`127.0.0.1:19488`,
280
- 被占用则顺延),宿主路由只作为附加通道。
281
- - **改 host 代码必须重启 DSH**:HMR 默认忽略 `**/node_modules`,而插件就装在 profile 的
282
- `node_modules` 下 —— 热重载永远不会重新加载它。客户端 bundle 会随页面刷新更新。
283
- - 依赖 Host 的 `webServer` 或 `connection` 服务;`tools` 服务缺失时工具不注册(仅画布可用)。
284
- ## 📄 许可证
285
-
286
- MIT
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/icon.svg" alt="dsh-ppt-canvas" width="112" height="112">
3
+ </p>
4
+ <h1 align="center">dsh-ppt-canvas</h1>
5
+
6
+ <p align="center">
7
+ <strong>简体中文</strong> · <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/README.en.md">English</a>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/package.json"><img src="https://img.shields.io/badge/version-1.1.1-2563eb?style=flat-square" alt="Version 1.1.1"></a>
12
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/SIMULATION-ACCEPTANCE.md"><img src="https://img.shields.io/badge/DSH-Desktop%2FWeb%20simulation-0f766e?style=flat-square" alt="DSH Desktop / Web:仿真验收"></a>
13
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/package.json"><img src="https://img.shields.io/badge/Node-22%2B-337a48?style=flat-square&amp;logo=nodedotjs&amp;logoColor=white" alt="Node 22+"></a>
14
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-64748b?style=flat-square" alt="MIT license"></a>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <strong>在原画布标出要改的地方,检查 AI 方案,再整批保存。</strong><br>
19
+ DeepSeek Harness 的 PPT 编辑工作台。
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="#quick-start"><img src="https://img.shields.io/badge/Quick_Start-2563eb?style=for-the-badge" alt="快速开始"></a>
24
+ <a href="#how-it-works"><img src="https://img.shields.io/badge/How_It_Works-0f766e?style=for-the-badge" alt="工作方式"></a>
25
+ <a href="#documentation"><img src="https://img.shields.io/badge/Documentation-334155?style=for-the-badge" alt="文档"></a>
26
+ <a href="https://github.com/hg1048596-pixel/dsh-ppt-canvas/issues"><img src="https://img.shields.io/badge/Issues-334155?style=for-the-badge" alt="问题反馈"></a>
27
+ </p>
28
+
29
+ ---
30
+
31
+ 当前版本 **v1.1.1**,面向 DSH desktop/web profile。Windows 使用本机 Chromium、真实文档引擎与 LibreOffice 验证;Mac 交互、路径及 DSH/AI 会话链路按仿真验收,尚未据此声明 Mac 实机或真实 DSH 全平台验证。
32
+
33
+ - **直接编辑**:选择、移动、缩放和旋转对象,双击修改文字,支持多选、对齐及字节级撤销。
34
+ - **跨页批注**:点选对象或拖出区域,每处单独填写要求;整批发送真实页面截图、编号与坐标。
35
+ - **先检查后保存**:在原画布比较修改前后,逐条检查结果,确认后整批写盘,一步撤销。
36
+ - **连续操控**:指针中心缩放、触控板平移、逐页视角记忆,深浅主题与本机批注草稿。
37
+
38
+ <a id="how-it-works"></a>
39
+
40
+ ## 工作方式
41
+
42
+ 打开 `.pptx` → 直接调整或标注多处要求 → 发送给 DSH 会话 → 检查候选 → 确认保存。
43
+
44
+ ![浅色工作台:画布、页面列表与批注摘要](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/workbench-light.png)
45
+
46
+ <details>
47
+ <summary>深色主题、方案检查与窄窗口</summary>
48
+
49
+ ![深色工作台](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/workbench-dark.png)
50
+
51
+ ![原画布候选检查与整批确认](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/annotation-review.png)
52
+
53
+ ![窄窗口侧栏与批注输入](https://raw.githubusercontent.com/hg1048596-pixel/dsh-ppt-canvas/main/assets/workbench-compact.png)
54
+
55
+ </details>
56
+
57
+ 截图来自相同组件与真实文档引擎的本机样板;方案检查图使用固定 AI 仿真候选,不代表真实模型效果。操控期间使用轻量预览,精确图就绪后接管;复杂主题阴影、图表与混合排版以精确预览为准。
58
+
59
+ <a id="quick-start"></a>
60
+
61
+ ## 安装
62
+
63
+ 在插件市场搜索 npm 包名 **`dsh-ppt-canvas`**,安装到实际使用的 profile;也可用官方 CLI 安装或升级:
64
+
65
+ ```powershell
66
+ dsh plugin --profile desktop add dsh-ppt-canvas@1.1.1
67
+ ```
68
+
69
+ 使用网页版时将 `desktop` 换成 `web`,完成后重启对应 DSH。准备 **Node.js 22+** 与 **LibreOffice**;精确页面预览和发给 AI 的截图需要 LibreOffice,AI 会话需选用支持图片输入的模型。插件运行时不额外安装 npm 依赖。
70
+
71
+ 源码联调、安装自检及本地 helper 见[开发指南][development]。
72
+
73
+ ## 在 DSH 中使用
74
+
75
+ 1. 点击侧边栏底部 **PPT 画布**,或将一个 `.pptx` 拖到入口/最小化按钮/工作台。也可在“更多操作 → 打开本地演示文稿”选择文件。
76
+ 2. 单击选择对象,双击、Enter 或 F2 编辑文字;拖动把手调整大小,属性栏可修改位置和样式。手动编辑直接保存。
77
+ 3. 按 **A** 添加批注:点击对象或拖出区域,在目标旁填写要求;可跨页继续添加。Enter 换行,Ctrl/⌘ + Enter 完成当前条,**不会发送 AI**。窄窗口或空间不足时,唯一编辑框移入右栏并保留光标选区。
78
+ 4. 在右栏勾选本批要求,点击“发送 N 条修改要求”;用“修改前/修改后”和“上一处/下一处”检查方案,最后确认整批保存。生成或放弃候选不会写入文稿。
79
+ 5. 点击右上角 **返回 DSH** 收起画布。焦点在画布时,Esc 会先退出当前操作或清除选择,再按可收起。重新打开后可以继续编辑。
80
+
81
+ 标题栏显示修改保存到了哪份文稿。编辑导入副本时,从 **更多操作 → 导出已保存的 PPTX** 取回文件。草稿和已完成的批注可用同一菜单导出为 JSON。下次启动后,点 **继续上次文稿** 可找回副本和本机草稿。
82
+
83
+ | 操作 | 快捷键 |
84
+ | --- | --- |
85
+ | 选择/批注/抓手 | V/A/H |
86
+ | 多选 | Shift、Ctrl/⌘ + 点击 |
87
+ | 完成编辑/取消 | Ctrl/⌘ + Enter/Esc |
88
+ | 撤销/重做 | Ctrl/⌘ + Z/Ctrl/⌘ + Shift + Z |
89
+ | 缩放/平移 | Ctrl/⌘ + 滚轮;触控板双指滚动、空格 + 拖动或中键 |
90
+
91
+ **文件与能力边界:**仅支持 `.pptx`,单文件最多 **80 MiB**,同时打开一份文稿。能取得真实本地路径时直接编辑原件;浏览器只提供文件内容时,打开持久保存的**导入副本**,标题栏明确标记。副本默认在 `~/.dsh/ppt-canvas/imports/`,可用 `DSH_PPT_DATA_ROOT` 指定数据根目录。
92
+
93
+ 批注通常每批最多 **4 页**,宿主图片额度更低时跟随其限制;超额、不支持、冲突或失效定位会提示,草稿保留。草稿与最近 30 轮批次记录保存在当前设备的 localStorage,不是云同步或 PPT 原生评论;撤销最多 50 步。当前用于编辑已有文稿,不提供从主题/大纲生成整稿、新建页面或插入本地图片等完整制作功能。详见[协议与能力边界][contract]。
94
+
95
+ <a id="documentation"></a>
96
+
97
+ ## 文档
98
+
99
+ - [开发指南][development]:目录、构建、自检、排障与测试隔离。
100
+ - [协议与能力][contract]:Deck、补丁、批注授权、确认写盘及存储边界。
101
+ - [界面精修验收][polish] · [导入验收][import] · [Mac 与 DSH 仿真范围][simulation]。
102
+
103
+ ## 开发
104
+
105
+ ```powershell
106
+ npm ci
107
+ npm run build
108
+ npm test
109
+ npm run preview
110
+ ```
111
+
112
+ 需要本机 Chromium 和 LibreOffice。样板编辑临时演示文稿,AI 使用固定仿真响应;正常插件连接 DSH 会话。1.1.1 完整回归 **387 项通过,0 跳过**,覆盖窄窗退出、写盘失败后重试、PPTX 下载和批注恢复。
113
+
114
+ [问题反馈](https://github.com/hg1048596-pixel/dsh-ppt-canvas/issues) · [MIT License](https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/LICENSE)
115
+
116
+ [development]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/DEVELOPMENT.md
117
+ [contract]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/CONTRACT.md
118
+ [polish]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/UI-POLISH-ACCEPTANCE.md
119
+ [import]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/IMPORT-ACCEPTANCE.md
120
+ [simulation]: https://github.com/hg1048596-pixel/dsh-ppt-canvas/blob/main/docs/SIMULATION-ACCEPTANCE.md
Binary file
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="112" height="112" viewBox="0 0 112 112" fill="none">
2
+ <title>dsh-ppt-canvas</title>
3
+ <desc>A presentation canvas with an annotation marker.</desc>
4
+ <rect x="4" y="4" width="104" height="104" rx="24" fill="#F8FAFF" stroke="#DCE5F5" stroke-width="2"/>
5
+ <g stroke="#2563EB" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round">
6
+ <rect x="25" y="27" width="62" height="43" rx="6" fill="white"/>
7
+ <path d="M56 71V82M43 88L56 81L69 88"/>
8
+ <path d="M37 41H63M37 50H74M37 59H54"/>
9
+ </g>
10
+ <circle cx="83" cy="29" r="11" fill="#2563EB" stroke="#F8FAFF" stroke-width="3"/>
11
+ <path d="M80 26L83 24V34M80 34H86" stroke="white" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>
12
+ </svg>
Binary file
Binary file
Binary file