Community plugin

511659192 / dsh-plugin-content-width

问答区页面宽度切换(默认 / 较宽 / 全宽),并把正文里的网页链接与文件引用改为弹窗打开:网页链接显示地址,文件引用直接预览内容。

  • JavaScript
  • MIT
  • 0 stars
  • Nov 7, 2026

About this plugin

Written by the registry from verified metadata, not from the README.

dsh-plugin-content-width is a DSH plugin published from the plugins/dsh-plugin-content-width package in the 511659192/ai-plugins repository.

  • Listing statusManifest verified
  • Manifest checkedNov 13, 2026
  • Packagedsh-plugin-content-width
  • Package pathplugins/dsh-plugin-content-width
  • Package version0.1.0
  • DSH engine>=0.2.2-0 <0.3.0-0
  • Source commit5733c71
  • Repository createdNov 7, 2026

Capabilities and topics

dshdsh-plugindsh-clientui
From the repository README

README

Everything below this line is the repository's own document, cached here. This site did not write or review it.

dsh-plugin-content-width

给 dsh Web GUI 的问答区加两件事:

  1. 页面宽度切换:默认 / 较宽 / 全宽。点会话头部右上角的按钮,在下拉的锚定卡片里切换,选择立即生效并被浏览器记住。
  2. 正文链接点击弹窗:对话内容里的网页链接与文件引用点击后弹「链接 / 文件」对话框(域名或路径 + 完整地址 + 复制 / 在浏览器打开 / 在侧边栏打开),不再落到右侧面板或新标签页。

工作原理

页面宽度

dsh 会话外壳在自己的根元素上定义自定义属性 --dsh-chat-content-width: 748px;消息列、输入卡片(+32px)和宽表格都读它。文档中稳定的钩子 [data-conversation-scroll] 包住这些面(含粘性输入区),内联自定义属性又优先于外壳的类规则,所以插件只往该元素上写值,不改任何 dsh 包。

  • 默认 748px(dsh 原值)、较宽 1000px、全宽 9999px(元素是 width:100%; max-width:var(...),写大像素值即铺满;不用 100%,因为输入卡片读 calc(var(...) + 32px) 会多溢出)。
  • 会话切换、页面重挂载会重建滚动容器,MutationObserver 负责重写,保证宽度“黏住”。
  • 选择存在 localStorage 的 dsh.contentWidth.mode。

链接弹窗

dsh 自带的「网页链接默认打开方式」只有两档:应用内侧边栏 / 默认浏览器(dsh-client-ui-chat 的 settings.links.*),没有弹窗档。本插件在 document 的捕获阶段注册 click:捕获阶段早于 React 挂在根容器上的处理,preventDefault() + stopPropagation() 之后应用的打开逻辑不会再跑。

  • 接管两类目标:站外 http(s) 锚点,以及文件引用——行内代码命中文件词表后渲染的 button[class*="fileMention"],和同源的 api/file?path= 附件链接。
  • 文件弹窗直接在弹窗里预览内容:remote.workspaceFiles.read(sessionId, path, { offset: 1, limit: 400 })(会话 id 由头部 slot 的 inject(sessionId) 提供,路径取引用按钮的 title 并去掉 :434 行号后缀)。读不到(无会话 id / 服务缺席 / 不是文本)时降级为提示 + 「在侧边栏打开」,并写明失败原因。
  • remote 与 remote.workspaceFiles 是命名空间服务,只能靠注入拿到;它们放在子 fiber 里做可选注入(ctx.inject([...], cb)),不进 exports.inject——否则服务缺席会让整个插件都不加载。
  • 其他同源链接(设置页等)不接管。
  • 弹窗宽度跟随页面宽度档位:默认 748px、较宽 1000px、全宽铺满(遮罩内边距 24px)。弹窗开着时切换档位,宽度也会立刻跟上。
  • 弹窗用纯 DOM 构建(不依赖 react-dom、不依赖 slot 挂载时机),Esc / 点遮罩 / 关闭按钮都能关。

安装

dsh plugin --profile <profile> add "git+https://gitee.com/yangmengdx3/ai-plugins.git#main&path:/plugins/dsh-plugin-content-width"

装好后重启应用生效;卸载用 dsh plugin --profile <profile> remove dsh-plugin-content-width。

插件自带 cordis.patch.yml(dsh.bundle.patch),loader 行由它提供:

- insert:
    - id: content-width
      name: dsh-plugin-content-width

结构

文件作用
package.jsondsh.bundle.patch + dsh.client.platform: web + exports["./client"]
cordis.patch.yml作为 bundle 层插入 loader 行(id content-width)
lib/client.js全部 UI 与宽度/链接逻辑(纯 JS,window.__ModuleLoader__ 协议,无构建)
index.mjshost 侧空插件,仅让 loader 行可解析
locale/en.json、locale/zh.json插件管理器里的标题与描述
icon.svg插件管理器图标(./icon 导出)
assets/icon-180.png市场卡片位图

许可

MIT,见 LICENSE。

Badge

Listed here? Link back with this badge — paste the snippet into your repository README.

Listed on DSH Plugin badge
[![Listed on DSH Plugin](https://dsh-plugin.com/badges/listed.svg)](https://dsh-plugin.com/plugins/511659192/ai-plugins/plugins/dsh-plugin-content-width)