docs: sync built-in viewer and tab-action test counts

This commit is contained in:
Menghuan1918 committed 2026-11-08 12:34:06 +08:00
1 parent bc66e8dc53
commit d6e43a007e
4 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@
- 🔍 **mermaid 放大视图只缩放图内容**([#829](https://github.com/omdsh-dev/DSH-better-sidebar/pull/829)):白卡固定在视口、打开即适配,滚轮与拖拽不再连白边一起放大。
- 🧩 **编辑器头部也能挂外部按钮了(`registerTabAction`,新能力 `'tabActions'`)**:文件 tab 进的是本插件的 `editor` / `code` 视图,宿主的 `sidebar.right.tab.document.actions` 插槽属于**宿主自己的**文档预览面,于是「上传到云端」「存到云盘」「在 App 中打开」这类由宿主插槽承载的按钮会整体消失(用户实测:禁用本插件后按钮才出现)。现在 `ctx.betterSidebar.registerTabAction({ id, label, title, icon, order, when, run })` 在刷新与文件树开关右侧加按钮:回调拿到 `tabId / tabType / sessionId / path / isDir / title` 与一个 `fail` 出口,失败落进编辑器上方的错误条,同一 (id, tabId) 在飞行中的重复点击被忽略,`when` 抛错只隐藏该注册。说明与「这一面为什么需要自己的扩展点」写进[指南 §7.4](docs/external-plugin-guide.md)。
- 🧪 测试:新增 `tests/tab-actions.spec.tsx`(9 例:能力声明与初始为空、注册序 = order 升序 + 注册序、重复 id 抛错、旧 disposer 不能拆掉新注册、dispose 清表、头部渲染与 run 上下文、挂载后注册的按钮会补上、`when` 过滤与抛错隔离、失败进错误条)。
- 🧪 测试:新增 `tests/tab-actions.spec.tsx`(10 例:能力声明与初始为空、注册序 = order 升序 + 注册序、重复 id 抛错、旧 disposer 不能拆掉新注册、dispose 清表、头部渲染与 run 上下文、挂载后注册的按钮会补上、`when` 过滤与抛错隔离、异步执行中重复点击被忽略、失败进错误条)。
- 🧩 **插件可以往文件树的行菜单里加自己的动作(`registerFileAction`,新能力 `'fileActions'`)**:此前文件树的右键菜单完全由插件自己组装(打开方式 / 下载 / 上传到此目录 / 复制 / 重命名 / 删除),外部插件没有任何位置能加一项——「把这个文件传到我的云端」这类入口只能另开界面。现在 `ctx.betterSidebar.registerFileAction({ id, label, icon, row, dirs, order, when, run })` 注册的项排在内置打开/下载行之后、复制/重命名之前;`row: true` 再在行右侧「引用」按钮旁加一个悬停按钮(要求同时给 `icon`)。回调拿到的是行的**绝对路径**加上这棵树的根与会话,失败按既有策略落进文件树的错误条(`run` 抛错即 `error.message`),**树只提供入口,不替注册方上传、复制或移动任何东西**;同一 (id, path) 在飞行中的重复点击会被忽略。`when` 抛错只隐藏该注册,不打断文件树。接入面与两条约定写进[指南 §7.3](docs/external-plugin-guide.md)。
- 🧪 测试:新增 `tests/file-actions.spec.tsx`(12 例:注册序 = order 升序 + 注册序、重复 id 抛错、旧 disposer 不能拆掉新注册、菜单位置、绝对路径/根/会话、目录默认不认领、`when` 判定与抛错隔离、悬停按钮与 `title`/`aria-label`、无图标只进菜单、reject 落错误条且成功静默)。
+1 -1
View File
@@ -32,7 +32,7 @@
- 🔍 **The mermaid zoom modal scales only the diagram** ([#829](https://github.com/omdsh-dev/DSH-better-sidebar/pull/829)): the white card stays fixed in the viewport and the diagram is framed on open; wheel and drag no longer grow the card.
- 🧩 **External buttons can now live in the editor header (`registerTabAction`, new `'tabActions'` capability)**: file tabs open in this plugin's `editor` / `code` views, while the host's `sidebar.right.tab.document.actions` slot belongs to the host's own document preview — so host-slot buttons such as "upload to cloud", "save to my drive" or "open in app" vanished entirely whenever this plugin rendered the file (observed in the field: disabling the plugin made the button appear). `ctx.betterSidebar.registerTabAction({ id, label, title, icon, order, when, run })` now adds buttons right of the refresh and tree controls: the callback receives `tabId / tabType / sessionId / path / isDir / title` plus a `fail` exit, a failure lands in the editor's error strip, a second press on the same (id, tabId) while in flight is ignored, and a throwing `when` hides just its own registration. The surface and why this face needs its own extension point are documented in [guide §7.4](docs/external-plugin-guide.md).
- 🧪 `tests/tab-actions.spec.tsx` (9 cases): capability declared and initially empty, render order = `order` ascending then registration order, duplicate ids throw, a stale disposer cannot tear down a newer registration, disposal empties the registry, header render plus run context, a registration made after mount still appears, `when` filtering with throw isolation, and a failure landing in the error strip.
- 🧪 `tests/tab-actions.spec.tsx` (10 cases): capability declared and initially empty, render order = `order` ascending then registration order, duplicate ids throw, a stale disposer cannot tear down a newer registration, disposal empties the registry, header render plus run context, a registration made after mount still appears, `when` filtering with throw isolation, a second press during an async run being ignored, and a failure landing in the error strip.
- 🧩 **Plugins can contribute actions to the file tree's row menu (`registerFileAction`, new `'fileActions'` capability)**: the row menu used to be assembled entirely by this plugin (open with / download / upload here / copy / rename / delete), leaving external plugins no place to add an entry — "send this file to my cloud" had to live in some other surface. Entries registered with `ctx.betterSidebar.registerFileAction({ id, label, icon, row, dirs, order, when, run })` now render after the built-in open/download rows and before the copy/mutation block; `row: true` also adds a hover button next to the row's reference button (an `icon` is required for that). The callback receives the row's **absolute path** plus the tree's root and session, and a failure lands in the tree's error strip under the existing policy (`run` throwing reports `error.message`) — **the tree contributes the entry point only; the registrant does the uploading, copying or moving**. A second press on the same (id, path) while the first is in flight is ignored. A `when` that throws hides just its own registration instead of breaking the tree. The surface and its two rules are documented in [guide §7.3](docs/external-plugin-guide.md).
- 🧪 `tests/file-actions.spec.tsx` (12 cases): render order = `order` ascending then registration order, duplicate ids throw, a stale disposer cannot tear down a newer registration, menu position, absolute path/root/session, directories excluded by default, `when` filtering plus throw isolation, hover button with `title`/`aria-label`, glyph-less registrations stay menu-only, a rejection lands in the strip while success stays silent.
+1 -1
View File
@@ -120,7 +120,7 @@ If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-bett
## 🔌 Plugin Ecosystem
`ctx.betterSidebar` offers five extension points to every plugin — `registerTab` / `registerFileViewer` / `registerFileIcon` / `registerFileAction` / `registerTabAction`; the built-in 6 tabs + 4 viewers use the very same API. The GitHub topic [`dsh-better-sidebar`](https://github.com/topics/dsh-better-sidebar) already lists **30+ ecosystem plugins**; the full integration guide is at **[docs/external-plugin-guide.md](./docs/external-plugin-guide.md)**.
`ctx.betterSidebar` offers five extension points to every plugin — `registerTab` / `registerFileViewer` / `registerFileIcon` / `registerFileAction` / `registerTabAction`; the built-in 6 tabs + 5 viewers use the very same API. The GitHub topic [`dsh-better-sidebar`](https://github.com/topics/dsh-better-sidebar) already lists **30+ ecosystem plugins**; the full integration guide is at **[docs/external-plugin-guide.md](./docs/external-plugin-guide.md)**.
```ts
import type {} from 'dsh-better-sidebar' // triggers the ctx.betterSidebar type merge
+1 -1
View File
@@ -120,7 +120,7 @@ dsh plugin --profile web add dsh-better-sidebar@latest
## 🔌 插件生态
`ctx.betterSidebar` 向所有插件开放 `registerTab` / `registerFileViewer` / `registerFileIcon` / `registerFileAction` / `registerTabAction` 五个扩展点,内置 6 tab + 4 viewer 与第三方插件走同一套 API。GitHub topic [`dsh-better-sidebar`](https://github.com/topics/dsh-better-sidebar) 下已有 **30+ 生态插件**;完整接入文档见 **[docs/external-plugin-guide.md](./docs/external-plugin-guide.md)**。
`ctx.betterSidebar` 向所有插件开放 `registerTab` / `registerFileViewer` / `registerFileIcon` / `registerFileAction` / `registerTabAction` 五个扩展点,内置 6 tab + 5 viewer 与第三方插件走同一套 API。GitHub topic [`dsh-better-sidebar`](https://github.com/topics/dsh-better-sidebar) 下已有 **30+ 生态插件**;完整接入文档见 **[docs/external-plugin-guide.md](./docs/external-plugin-guide.md)**。
```ts
import type {} from 'dsh-better-sidebar' // 触发 ctx.betterSidebar 类型合并