@wszhoho/dsh-file-attachment 0.5.8 → 0.5.9
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/lib/client.js +33 -1
- package/lib/index.js +1 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -118,6 +118,38 @@ window.__ModuleLoader__.load({
|
|
|
118
118
|
hijackedInputs.add(el)
|
|
119
119
|
el.addEventListener('change', onNativeFileChange)
|
|
120
120
|
}
|
|
121
|
+
// ---- 移动端双📎兼容:dsh-web-mobile 向 conversation.input.left 注入 file-upload 回形针,
|
|
122
|
+
// 其设计前提是 host(0.1.6-alpha.2+)已删除 composer 原生📎;在 0.1.5-rc.x 上该前提不成立——
|
|
123
|
+
// 该代 host 仍渲染原生📎(即 hidden fileInput 的前邻 button),移动端窄屏下两枚并排出现
|
|
124
|
+
//(PC 宽屏被 dsh-web-mobile 的 pointer:fine 隐藏规则覆盖,故仅移动端可见)。
|
|
125
|
+
// 此处按 host 原生📎是否存在对调:原生📎在 → 内联 display:none!important 隐藏 mobile 注入的
|
|
126
|
+
//(压过其 display:grid!important);原生📎不在(0.1.6+)→ 移除内联声明交还 CSS,保留为唯一入口。
|
|
127
|
+
// 两枚按钮点击后都触发 host 的 hidden fileInput,change 已被本插件劫持走 runBatch,功能不受影响。
|
|
128
|
+
function cardHasNativeClip(card) {
|
|
129
|
+
let inputs
|
|
130
|
+
try { inputs = card.querySelectorAll('input[type="file"], input[type=file]') } catch (err) { return false }
|
|
131
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
132
|
+
const inp = inputs[i]
|
|
133
|
+
if (typeof inp.hidden !== 'undefined' && !inp.hidden) continue // 只认 host 的 hidden fileInput
|
|
134
|
+
let prev = inp.previousElementSibling
|
|
135
|
+
while (prev !== null && prev.tagName !== 'BUTTON') prev = prev.previousElementSibling
|
|
136
|
+
if (prev !== null) return true
|
|
137
|
+
}
|
|
138
|
+
return false
|
|
139
|
+
}
|
|
140
|
+
function reconcileMobileFileUpload() {
|
|
141
|
+
let cards
|
|
142
|
+
try { cards = Array.from(document.querySelectorAll('[data-composer-card]')) } catch (err) { cards = [] }
|
|
143
|
+
for (let i = 0; i < cards.length; i++) {
|
|
144
|
+
const hideMobile = cardHasNativeClip(cards[i])
|
|
145
|
+
let btns
|
|
146
|
+
try { btns = cards[i].querySelectorAll('[data-mobile-nav="file-upload"]') } catch (err) { btns = [] }
|
|
147
|
+
for (let j = 0; j < btns.length; j++) {
|
|
148
|
+
const curHidden = btns[j].style.display === 'none'
|
|
149
|
+
if (hideMobile !== curHidden) btns[j].style.setProperty('display', hideMobile ? 'none' : '', 'important')
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
121
153
|
function installNativeAttachHijack() {
|
|
122
154
|
if (typeof document === 'undefined' || document.body === null || document.body === undefined) return
|
|
123
155
|
let body
|
|
@@ -127,6 +159,7 @@ window.__ModuleLoader__.load({
|
|
|
127
159
|
let all = []
|
|
128
160
|
try { all = Array.from(body.querySelectorAll(nativeFileInputSelector)) } catch (err) { all = [] }
|
|
129
161
|
for (let i = 0; i < all.length; i++) hijackFileInput(all[i])
|
|
162
|
+
reconcileMobileFileUpload() // 双📎对调:host 原生📎在则隐藏 dsh-web-mobile 注入的
|
|
130
163
|
}
|
|
131
164
|
scan()
|
|
132
165
|
const mo = new MutationObserver(() => scan())
|
|
@@ -772,7 +805,6 @@ window.__ModuleLoader__.load({
|
|
|
772
805
|
bridge.input = input
|
|
773
806
|
bridge.sessionId = sessionId
|
|
774
807
|
bridge.mounted = true
|
|
775
|
-
if (typeof console !== 'undefined' && console.log) console.log('[dsh-file-attachment] FaBridge mounted', { sessionId, shell: shell === null ? 'null' : 'ok', addImages: typeof addImages })
|
|
776
808
|
return () => {
|
|
777
809
|
bridge.shell = null
|
|
778
810
|
bridge.addImages = null
|
package/lib/index.js
CHANGED
|
@@ -489,9 +489,8 @@ function registerTools(ctx) {
|
|
|
489
489
|
},
|
|
490
490
|
},
|
|
491
491
|
render: (_args, value) => {
|
|
492
|
-
const thinkingText = (value && value.thinkingType === 'enabled') ? '开启' : '关闭'
|
|
493
492
|
if (value && value.ok === true && typeof value.description === 'string' && value.description !== '') {
|
|
494
|
-
return [{ type: 'text', text: '图片识别结果:' + value.description
|
|
493
|
+
return [{ type: 'text', text: '图片识别结果:' + value.description }]
|
|
495
494
|
}
|
|
496
495
|
return [{ type: 'text', text: (value && value.ok === true) ? '(图片已识别)' : '(图片识别失败)' }]
|
|
497
496
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wszhoho/dsh-file-attachment",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "文件附件:拖拽/粘贴/上传文件(支持多文件);图片与文档统一落盘到 .dsh-file-attachment 并以 @绝对路径 引用发送(文本模型可正常使用);输入框内联显示图片缩略图预览与文件条目,聊天区图片同样渲染为可点击放大的缩略图、文件保持芯片样式;非多模态模型下图片自动调用可配置 VLM 识别生成中文描述回填草稿;文档/代码/配置文件可上传类型可在设置页配置;支持 PC 与移动端浏览器",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|