@lyra_wang/dsh-quick-commands 0.1.2 → 0.1.3
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 +1 -0
- package/client.js +30 -8
- package/package.json +1 -1
package/README.md
CHANGED
package/client.js
CHANGED
|
@@ -188,21 +188,36 @@ window.__ModuleLoader__.load({
|
|
|
188
188
|
if (!node) return
|
|
189
189
|
const rect = node.getBoundingClientRect()
|
|
190
190
|
const margin = 12
|
|
191
|
-
const
|
|
192
|
-
const
|
|
191
|
+
const host = node.parentElement
|
|
192
|
+
const hostRect = host ? host.getBoundingClientRect() : null
|
|
193
|
+
const usable = hostRect && hostRect.width > 120 ? Math.max(200, hostRect.width - 16) : 352
|
|
194
|
+
const width = Math.min(352, Math.max(240, Math.min(window.innerWidth - margin * 2, usable)))
|
|
195
|
+
const minLeft = Math.max(margin, hostRect ? hostRect.left : margin)
|
|
196
|
+
const maxLeft = Math.min(window.innerWidth - width - margin, hostRect ? hostRect.right - width : window.innerWidth - width - margin)
|
|
197
|
+
const left = Math.max(minLeft, Math.min(rect.left, Math.max(minLeft, maxLeft)))
|
|
193
198
|
const above = rect.top - margin
|
|
194
199
|
const below = window.innerHeight - rect.bottom - margin
|
|
195
200
|
const openUp = above >= 240 || above >= below
|
|
196
201
|
const room = Math.max(openUp ? above : below, 0)
|
|
202
|
+
let next
|
|
197
203
|
if (room >= 160) {
|
|
198
204
|
const maxHeight = Math.min(420, room - 8)
|
|
199
|
-
|
|
205
|
+
next = openUp
|
|
200
206
|
? { left, width, maxHeight, bottom: window.innerHeight - rect.top + 8 }
|
|
201
|
-
: { left, width, maxHeight, top: rect.bottom + 8 }
|
|
202
|
-
|
|
207
|
+
: { left, width, maxHeight, top: rect.bottom + 8 }
|
|
208
|
+
} else {
|
|
209
|
+
// Neither side has room: pin to the viewport and let the list scroll.
|
|
210
|
+
next = { left, width, maxHeight: Math.max(160, window.innerHeight - margin * 2), top: margin }
|
|
203
211
|
}
|
|
204
|
-
|
|
205
|
-
|
|
212
|
+
setAnchor((current) => {
|
|
213
|
+
if (current
|
|
214
|
+
&& current.left === next.left
|
|
215
|
+
&& current.width === next.width
|
|
216
|
+
&& current.maxHeight === next.maxHeight
|
|
217
|
+
&& current.top === next.top
|
|
218
|
+
&& current.bottom === next.bottom) return current
|
|
219
|
+
return next
|
|
220
|
+
})
|
|
206
221
|
}, [])
|
|
207
222
|
|
|
208
223
|
const toggle = useCallback(() => {
|
|
@@ -231,13 +246,20 @@ window.__ModuleLoader__.load({
|
|
|
231
246
|
if (event.key === 'Escape') setOpen(false)
|
|
232
247
|
}
|
|
233
248
|
const onResize = () => place()
|
|
249
|
+
const onScroll = () => place()
|
|
234
250
|
document.addEventListener('mousedown', onDown)
|
|
235
251
|
document.addEventListener('keydown', onKey)
|
|
236
252
|
window.addEventListener('resize', onResize)
|
|
253
|
+
window.addEventListener('scroll', onScroll, true)
|
|
254
|
+
// Sidebars opening or the composer reflowing move the button without a
|
|
255
|
+
// resize event; re-anchor while the panel is open.
|
|
256
|
+
const timer = setInterval(() => place(), 400)
|
|
237
257
|
return () => {
|
|
258
|
+
clearInterval(timer)
|
|
238
259
|
document.removeEventListener('mousedown', onDown)
|
|
239
260
|
document.removeEventListener('keydown', onKey)
|
|
240
261
|
window.removeEventListener('resize', onResize)
|
|
262
|
+
window.removeEventListener('scroll', onScroll, true)
|
|
241
263
|
}
|
|
242
264
|
}, [open, place])
|
|
243
265
|
|
|
@@ -423,4 +445,4 @@ window.__ModuleLoader__.load({
|
|
|
423
445
|
},
|
|
424
446
|
}
|
|
425
447
|
},
|
|
426
|
-
})
|
|
448
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyra_wang/dsh-quick-commands",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Quick commands for DeepSeek Harness: one button next to the composer keeps your reusable snippets, inserts them as editable text, or sends one in a click.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|