@lyra_wang/dsh-quick-commands 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +4 -1
  2. package/client.js +21 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -24,6 +24,7 @@
24
24
 
25
25
  ## 边界
26
26
 
27
+ - 面板位置按可用空间选边(上/下),高度按窗口收;窗口太矮时贴到视口内并滚动
27
28
  - 内容上限 8000 字、最多 300 条(防止一个手滑塞满)
28
29
  - 插入是普通文本编辑,可撤销;发送会把当前草稿替换成该条内容
29
30
  - 只在本机,不跨设备同步
@@ -38,4 +39,6 @@ node --test test/store.test.mjs
38
39
 
39
40
  ## 版本
40
41
 
41
- 0.1.0 — 首个版本:全局常用指令清单、输入框按钮、面板搜索、插入 / 发送 / 编辑 / 删除。
42
+ - 0.1.2 — 按钮文字不再被挤成竖排(flex:none + nowrap)。
43
+ - 0.1.1 — 面板不再超出可视区域:按按钮上/下的剩余空间选展开方向,宽高都夹在视口内,列表自身滚动。
44
+ - 0.1.0 — 首个版本:全局常用指令清单、输入框按钮、面板搜索、插入 / 发送 / 编辑 / 删除。
package/client.js CHANGED
@@ -108,8 +108,9 @@ window.__ModuleLoader__.load({
108
108
 
109
109
  const CSS = [
110
110
  '.dsh-quick-commands-btn{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:4px;height:26px;',
111
- ' padding:0 8px;border-radius:var(--dsw-radius-sm,8px);cursor:pointer;font-size:12px;',
111
+ ' flex:none;white-space:nowrap;padding:0 8px;border-radius:var(--dsw-radius-sm,8px);cursor:pointer;font-size:12px;',
112
112
  ' color:var(--dsw-alias-label-secondary,#b9b9c0)}',
113
+ '.dsh-quick-commands-btn > span{white-space:nowrap}',
113
114
  '.dsh-quick-commands-btn:hover{background:var(--dsw-alias-interactive-bg-hover,#ffffff14);color:var(--dsw-alias-label-primary,#e8e8ea)}',
114
115
  '.dsh-quick-commands-panel{position:fixed;z-index:60;width:352px;max-height:420px;display:flex;flex-direction:column;',
115
116
  ' background:var(--dsw-alias-bg-layer-1,#1f1f22);border:0.5px solid var(--dsw-alias-border-l3,#ffffff1f);',
@@ -186,9 +187,22 @@ window.__ModuleLoader__.load({
186
187
  const node = btnRef.current
187
188
  if (!node) return
188
189
  const rect = node.getBoundingClientRect()
189
- const width = 352
190
- const left = Math.max(12, Math.min(rect.left, window.innerWidth - width - 12))
191
- setAnchor({ left, bottom: window.innerHeight - rect.top + 8 })
190
+ const margin = 12
191
+ const width = Math.min(352, window.innerWidth - margin * 2)
192
+ const left = Math.max(margin, Math.min(rect.left, window.innerWidth - width - margin))
193
+ const above = rect.top - margin
194
+ const below = window.innerHeight - rect.bottom - margin
195
+ const openUp = above >= 240 || above >= below
196
+ const room = Math.max(openUp ? above : below, 0)
197
+ if (room >= 160) {
198
+ const maxHeight = Math.min(420, room - 8)
199
+ setAnchor(openUp
200
+ ? { left, width, maxHeight, bottom: window.innerHeight - rect.top + 8 }
201
+ : { left, width, maxHeight, top: rect.bottom + 8 })
202
+ return
203
+ }
204
+ // Neither side has room: pin to the viewport and let the list scroll.
205
+ setAnchor({ left, width, maxHeight: Math.max(160, window.innerHeight - margin * 2), top: margin })
192
206
  }, [])
193
207
 
194
208
  const toggle = useCallback(() => {
@@ -298,7 +312,9 @@ window.__ModuleLoader__.load({
298
312
  key: 'panel',
299
313
  ref: panelRef,
300
314
  className: ROOT + '-panel',
301
- style: { left: anchor.left + 'px', bottom: anchor.bottom + 'px' },
315
+ style: anchor.top !== undefined
316
+ ? { left: anchor.left + 'px', width: anchor.width + 'px', maxHeight: anchor.maxHeight + 'px', top: anchor.top + 'px' }
317
+ : { left: anchor.left + 'px', width: anchor.width + 'px', maxHeight: anchor.maxHeight + 'px', bottom: anchor.bottom + 'px' },
302
318
  }, [
303
319
  h('div', { key: 'head', className: ROOT + '-head' }, [
304
320
  h('span', { key: 'title', className: ROOT + '-title' }, t('panel.title')),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyra_wang/dsh-quick-commands",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",