xrkh-better-sidebar 0.19.5 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -1
- package/README_EN.md +75 -1
- package/lib/client-editor.js +663 -185
- package/lib/client-mermaid.js +622 -184
- package/lib/client-registry.js +2516 -610
- package/lib/client-terminal.js +665 -187
- package/lib/client.js +2507 -601
- package/lib/types/client/FileTree.d.ts +8 -0
- package/lib/types/client/ImagePreview.d.ts +27 -0
- package/lib/types/client/OfficePreview.d.ts +27 -0
- package/lib/types/client/TreePanel.d.ts +4 -0
- package/lib/types/client/api.d.ts +12 -1
- package/lib/types/client/binary-download.d.ts +4 -0
- package/lib/types/client/conversation-draft.d.ts +2 -1
- package/lib/types/client/icons.d.ts +4 -0
- package/lib/types/client/locales.d.ts +19 -0
- package/lib/types/client/office/docx.d.ts +16 -0
- package/lib/types/client/office/pptx.d.ts +26 -0
- package/lib/types/client/office/shared.d.ts +32 -0
- package/lib/types/client/office/xlsx.d.ts +20 -0
- package/lib/types/client/office/xml.d.ts +72 -0
- package/lib/types/client/office/zip.d.ts +34 -0
- package/lib/types/client/service.d.ts +1 -1
- package/package.json +1 -1
- package/src/client/EditorHost.tsx +104 -10
- package/src/client/FileTree.tsx +51 -3
- package/src/client/ImagePreview.tsx +250 -0
- package/src/client/OfficePreview.tsx +276 -0
- package/src/client/Sidebar.tsx +1724 -1713
- package/src/client/TreePanel.tsx +8 -1
- package/src/client/api.ts +33 -1
- package/src/client/binary-download.tsx +9 -3
- package/src/client/builtins/viewers.tsx +19 -8
- package/src/client/conversation-draft.ts +13 -2
- package/src/client/icons.tsx +11 -0
- package/src/client/layout.css +122 -115
- package/src/client/locales-ar.ts +19 -0
- package/src/client/locales-de.ts +19 -0
- package/src/client/locales-fr.ts +19 -0
- package/src/client/locales-hi.ts +19 -0
- package/src/client/locales-id.ts +19 -0
- package/src/client/locales-it.ts +19 -0
- package/src/client/locales-ja.ts +19 -0
- package/src/client/locales-ko.ts +19 -0
- package/src/client/locales-nl.ts +19 -0
- package/src/client/locales-pl.ts +19 -0
- package/src/client/locales-pt.ts +19 -0
- package/src/client/locales-ru.ts +19 -0
- package/src/client/locales-sv.ts +19 -0
- package/src/client/locales-th.ts +19 -0
- package/src/client/locales-tr.ts +19 -0
- package/src/client/locales-vi.ts +19 -0
- package/src/client/locales-zh-HK.ts +19 -0
- package/src/client/locales-zh-MO.ts +19 -0
- package/src/client/locales-zh-TW.ts +19 -0
- package/src/client/locales.ts +38 -0
- package/src/client/office/docx.ts +92 -0
- package/src/client/office/pptx.ts +131 -0
- package/src/client/office/shared.ts +72 -0
- package/src/client/office/xlsx.ts +147 -0
- package/src/client/office/xml.ts +225 -0
- package/src/client/office/zip.ts +321 -0
- package/src/client/service.ts +1 -1
- package/src/client/sidebar.module.css +2989 -2654
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Host 侧 `/sidebar/*` 由产品 Host 原生挂载(`createSidebarPublicHandler`
|
|
|
10
10
|
前置:`xrkh web` 或 `npx @xrkseek/harness-cli web`,Node ≥ 26。建议 Host **≥ 0.3.4**。推荐从 **npmjs** 安装:
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
xrkh plugin add xrkh-better-sidebar@0.
|
|
13
|
+
xrkh plugin add xrkh-better-sidebar@0.20.0
|
|
14
14
|
xrkh restart
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -18,6 +18,72 @@ xrkh restart
|
|
|
18
18
|
|
|
19
19
|
源码路径仍可用(非推荐):`git clone git@github.com:xrkseek/xrkh-better-sidebar.git` 后 `xrkh plugin add ./xrkh-better-sidebar`。
|
|
20
20
|
|
|
21
|
+
## 0.20.0
|
|
22
|
+
|
|
23
|
+
### Office 文档预览(.docx / .xlsx / .pptx)
|
|
24
|
+
|
|
25
|
+
首次真正支持打开 Office 文档,而不只是「下载」按钮。
|
|
26
|
+
|
|
27
|
+
- **零新依赖**:新增 `src/client/office/` 纯逻辑模块——用浏览器原生
|
|
28
|
+
`DecompressionStream('deflate-raw')` 实现 ZIP 读取(`zip.ts`),用原生
|
|
29
|
+
`DOMParser` 做 XML 取值(`xml.ts`),再分别解析 pptx / docx / xlsx 的
|
|
30
|
+
OOXML。不引入任何第三方包,不依赖 LibreOffice,离线可用。
|
|
31
|
+
- **保真度的诚实边界**:这是**结构化预览**,不是像素级还原——
|
|
32
|
+
- pptx:按 `presentation.xml` 的真实页序逐页展示文字、图片、演讲者备注,
|
|
33
|
+
支持左右键翻页。
|
|
34
|
+
- docx:标题分级、段落、列表项。
|
|
35
|
+
- xlsx:多工作表切换、表格网格(每表上限 200 行 × 60 列,代码里有注释说明)。
|
|
36
|
+
|
|
37
|
+
前端**高保真**还原幻灯片/文档排版目前没有可用的开源方案:同类标杆
|
|
38
|
+
`vue-office`(5.7k star)的 pptx 预览是基于其自研闭源库(README 注明
|
|
39
|
+
「源码单独付费」),docx 用 `docx-preview`、excel 用 `exceljs`。所以我们选择
|
|
40
|
+
结构化而非画布级还原——宁可少承诺,不假装。`.doc/.xls/.ppt`(旧二进制)、ODF、
|
|
41
|
+
`.rtf` 没有客户端解析器,继续走下载兜底。
|
|
42
|
+
|
|
43
|
+
- **ZIP 读取健壮性**:支持 ZIP64(EOCD 哨兵 + locator + per-entry extra field)、
|
|
44
|
+
store 与 deflate 两种压缩方法、UTF-8 文件名;截断/损坏/加密/超大条目会抛
|
|
45
|
+
带明确 message 的错误而不是静默返回空。单条目解压上限 512MB(zip bomb 防护)。
|
|
46
|
+
- 修复一个真实 bug:ZIP 解压原先走 `Blob.stream()` + `Response.arrayBuffer()`,
|
|
47
|
+
在 jsdom 环境无 `Blob.stream()` 会直接炸;改为手动 `ReadableStream` + reader
|
|
48
|
+
循环,兼容面更广(浏览器 / jsdom / 部分 polyfill 环境都能跑)。
|
|
49
|
+
|
|
50
|
+
### 图片预览缩放
|
|
51
|
+
|
|
52
|
+
- 图片预览支持 **Ctrl/⌘ + 滚轮** 以光标为中心缩放,拖拽平移,双击在「适应」
|
|
53
|
+
和 2x 之间切换,工具栏有「适应 / 100% / 下载」与实时百分比;`+` `-` `0` 快捷键。
|
|
54
|
+
- 修复:React 17+ 把 `wheel` 注册为 passive listener,合成 `onWheel` 的
|
|
55
|
+
`preventDefault()` 无效——Ctrl+滚轮会连带把整个应用页面一起缩放。改用原生
|
|
56
|
+
`{ passive: false }` 监听抑制页面级缩放。
|
|
57
|
+
- 缩放走 CSS `transform`(不触发布局),平移有 3px 阈值判定,避免误点击把图拖走。
|
|
58
|
+
|
|
59
|
+
### 文件树「在文件夹中显示」可见反馈
|
|
60
|
+
|
|
61
|
+
- 修复「点了没反应」:右键菜单能正常弹出(实测过),但 reveal/open 的失败
|
|
62
|
+
被 catch 成 `console.error`,界面上零反馈。Host 侧 Windows 走
|
|
63
|
+
`explorer.exe /select` 时也可能静默失败。现在失败会以可点击关闭的 notice
|
|
64
|
+
显示在树上,不再静默吞掉。
|
|
65
|
+
|
|
66
|
+
### 文件树文件操作(新建 / 重命名 / 删除)
|
|
67
|
+
|
|
68
|
+
- Host 早已提供 `fs.mkdir` / `fs.delete`,但客户端此前完全没接——右键菜单里
|
|
69
|
+
根本没有这些项,只能看不能管。本轮接上并补齐 UI:
|
|
70
|
+
- 目录右键:新建文件 / 新建文件夹;文件右键:重命名 / 删除(删除为危险项,
|
|
71
|
+
带名称确认)。
|
|
72
|
+
- 取消 prompt 或留空名是 no-op,不会误创建 `dir/`;重命名同名也是 no-op。
|
|
73
|
+
- 所有失败(权限 / 越界 / 占用)走同一条可见 notice,不静默。
|
|
74
|
+
- `fs.rename` 用「读字节 → 写入新路径 → 删源」实现,复用已有路由承载的
|
|
75
|
+
workspace fence,不为这一个功能给 Host 加新动词。
|
|
76
|
+
|
|
77
|
+
### 其它
|
|
78
|
+
|
|
79
|
+
- 新增 `IconOfficeOutline16` 文件预览图标;office viewer 拆成 `office`(OOXML
|
|
80
|
+
应用内预览)与 `office-legacy`(旧格式下载兜底)两个 descriptor,设置页可分别开关。
|
|
81
|
+
- i18n:20 个语言字典补齐本轮全部新键(image* / office* / openExternalFailed /
|
|
82
|
+
newFolder / rename / delete 等)。
|
|
83
|
+
- 新增/更新测试:图片缩放 10 例、Office 组件 8 例、文件操作 10 例、OOXML 解析
|
|
84
|
+
34 例(含真实 LibreOffice/pptx 文件验证,缺 fixture 时自动跳过)。全量测试
|
|
85
|
+
未引入任何回归(基线红/绿保持一致)。
|
|
86
|
+
|
|
21
87
|
## 0.19.5
|
|
22
88
|
|
|
23
89
|
- 修复底栏偶发空白(拖侧栏才出现):未测到中心列时 `left+right` 回退成零宽;改走 `--xrkh-center-*`,未测到前右侧回退为 workbench + Overview inset
|
package/README_EN.md
CHANGED
|
@@ -10,7 +10,7 @@ Host mounts `/sidebar/*` natively (`createSidebarPublicHandler`); this package s
|
|
|
10
10
|
Requires `xrkh web` or `npx @xrkseek/harness-cli web`, Node ≥ 26. Prefer Host **≥ 0.3.4**. Install from **npmjs**:
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
xrkh plugin add xrkh-better-sidebar@0.
|
|
13
|
+
xrkh plugin add xrkh-better-sidebar@0.20.0
|
|
14
14
|
xrkh restart
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -18,6 +18,80 @@ Hard-refresh the browser after install (Ctrl+Shift+R).
|
|
|
18
18
|
|
|
19
19
|
Source path still works (not preferred): `git clone git@github.com:xrkseek/xrkh-better-sidebar.git` then `xrkh plugin add ./xrkh-better-sidebar`.
|
|
20
20
|
|
|
21
|
+
## 0.20.0
|
|
22
|
+
|
|
23
|
+
### Office preview (.docx / .xlsx / .pptx)
|
|
24
|
+
|
|
25
|
+
Office files can now actually be opened instead of offering only a download button.
|
|
26
|
+
|
|
27
|
+
- **Zero new dependencies**: a new `src/client/office/` pure-logic module reads ZIP through
|
|
28
|
+
the browser-native `DecompressionStream('deflate-raw')` (`zip.ts`) and XML through the
|
|
29
|
+
native `DOMParser` (`xml.ts`), then parses OOXML for pptx / docx / xlsx. No third-party
|
|
30
|
+
package, no LibreOffice, works offline.
|
|
31
|
+
- **The fidelity boundary, stated honestly**: this is a **structured preview**, not
|
|
32
|
+
pixel-level reproduction —
|
|
33
|
+
- pptx: real slide order from `presentation.xml`, text, images and speaker notes, arrow keys to page.
|
|
34
|
+
- docx: heading levels, paragraphs, list items.
|
|
35
|
+
- xlsx: multiple sheets, a table grid (capped at 200 rows × 60 columns per sheet, noted in code).
|
|
36
|
+
|
|
37
|
+
High-fidelity slide/document rendering has no usable open-source option on the client: the
|
|
38
|
+
closest reference, `vue-office` (5.7k stars), previews pptx through its own closed-source
|
|
39
|
+
library (its README notes the source is sold separately) and uses `docx-preview` / `exceljs`
|
|
40
|
+
for the rest. So we chose structured over canvas-level fidelity — promise less rather than
|
|
41
|
+
pretend. Legacy `.doc/.xls/.ppt` binaries, ODF and `.rtf` have no client parser and keep the
|
|
42
|
+
download fallback.
|
|
43
|
+
- **ZIP robustness**: ZIP64 (EOCD sentinel + locator + per-entry extra field), store and
|
|
44
|
+
deflate methods, UTF-8 filenames; truncated / corrupt / encrypted / oversized entries throw
|
|
45
|
+
with an explicit message instead of silently returning empty. Per-entry decompression is
|
|
46
|
+
capped at 512MB (zip-bomb guard).
|
|
47
|
+
- Fixes a real bug: extraction went through `Blob.stream()` + `Response.arrayBuffer()`, which
|
|
48
|
+
throws outright where `Blob.stream()` is missing (jsdom); it now uses a manual
|
|
49
|
+
`ReadableStream` + reader loop, so it runs in browsers, jsdom and partial polyfills alike.
|
|
50
|
+
|
|
51
|
+
### Image preview zoom
|
|
52
|
+
|
|
53
|
+
- The image pane zooms around the cursor with **Ctrl/⌘ + wheel**, pans by drag, and toggles
|
|
54
|
+
between fit and 2x on double click; the toolbar has fit / 100% / download and a live
|
|
55
|
+
percentage, with `+` `-` `0` shortcuts.
|
|
56
|
+
- Fix: React 17+ registers `wheel` as a passive listener, so `preventDefault()` inside the
|
|
57
|
+
synthetic `onWheel` was a no-op and Ctrl+wheel zoomed the whole app. A native
|
|
58
|
+
`{ passive: false }` listener now suppresses page-level zoom.
|
|
59
|
+
- Zoom rides a CSS `transform` (no layout), and panning uses a 3px threshold so a click never
|
|
60
|
+
drags the image away.
|
|
61
|
+
|
|
62
|
+
### File tree: visible feedback for "reveal in folder"
|
|
63
|
+
|
|
64
|
+
- Fixes "nothing happens": the context menu opens correctly (verified live), but reveal/open
|
|
65
|
+
failures were caught into `console.error` with zero on-screen feedback, and the host side
|
|
66
|
+
(`explorer.exe /select` on Windows) can fail silently too. Failures now surface as a
|
|
67
|
+
dismissible notice on the tree instead of being swallowed.
|
|
68
|
+
|
|
69
|
+
### File tree: file operations (new / rename / delete)
|
|
70
|
+
|
|
71
|
+
- The host already offered `fs.mkdir` / `fs.delete`, but the client never called them — the
|
|
72
|
+
context menu had no such entries, so files could be viewed but not managed. This release
|
|
73
|
+
wires them up:
|
|
74
|
+
- Directory context menu: new file / new folder; file context menu: rename / delete (delete
|
|
75
|
+
is the dangerous one and asks for the name to confirm).
|
|
76
|
+
- A cancelled or empty prompt is a no-op and never creates `dir/`; renaming to the same name
|
|
77
|
+
is a no-op too.
|
|
78
|
+
- Every failure (permission / out of fence / in use) goes through the same visible notice,
|
|
79
|
+
never silent.
|
|
80
|
+
- `fs.rename` is implemented as read bytes → write to the new path → delete the source,
|
|
81
|
+
reusing the routes that already carry the workspace fence rather than adding a host verb
|
|
82
|
+
for this one feature.
|
|
83
|
+
|
|
84
|
+
### Other
|
|
85
|
+
|
|
86
|
+
- New `IconOfficeOutline16` file-preview icon; the office viewer is split into `office`
|
|
87
|
+
(in-app OOXML preview) and `office-legacy` (legacy download fallback) descriptors, each
|
|
88
|
+
toggleable in settings.
|
|
89
|
+
- i18n: all 20 locale dictionaries gained this round's keys (image* / office* /
|
|
90
|
+
openExternalFailed / newFolder / rename / delete, …).
|
|
91
|
+
- New/updated tests: 10 image-zoom cases, 8 office component cases, 10 file-operation cases,
|
|
92
|
+
34 OOXML parsing cases (including real LibreOffice/pptx files, auto-skipped when the fixture
|
|
93
|
+
is missing). No regressions against the existing suite baseline.
|
|
94
|
+
|
|
21
95
|
## 0.19.5
|
|
22
96
|
|
|
23
97
|
- Fix occasional blank bottom panel (only appeared after resizing the side workbench): unmeasured center column collapsed `left+right` to zero width; edges now use `--xrkh-center-*`, with a workbench + Overview-inset fallback until measured
|