@lyra_wang/dsh-pending-queue 0.3.3 → 0.4.0
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 +152 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ node --test test/routes.test.mjs
|
|
|
63
63
|
## 版本
|
|
64
64
|
|
|
65
65
|
- 0.1.0 — 首个版本:新增、编辑、删除、排序、发送、填入、已发送留痕。
|
|
66
|
+
- 0.4.0 — 飞书引用:面板里的「飞书引用」按钮复用 feishu-ref 插件的搜索(`POST /plugins/feishu-ref/search`),选中文档 / 云盘 / 群 / 消息 / 联系人后,插入与输入框完全相同的引用文本。
|
|
66
67
|
- 0.3.3 — 编辑态补上「引用选中」:编辑某条时也能把聊天里选中的文字加进去,和草稿区一致。
|
|
67
68
|
- 0.3.2 — 编辑态也能加图:点「编辑」后,在编辑框里粘贴/拖入图片同样生效,编辑项里也有「+ 图片」。
|
|
68
69
|
- 0.3.1 — 粘贴更稳:剪贴板只给 `items` 不给 `files` 的截图也能接住;补「+ 图片」选文件入口;未存下的草稿按会话暂存到 localStorage。
|
package/client.js
CHANGED
|
@@ -73,6 +73,16 @@ window.__ModuleLoader__.load({
|
|
|
73
73
|
'action.saveEdit': '保存',
|
|
74
74
|
'action.quote': '引用选中',
|
|
75
75
|
'action.image': '加图片',
|
|
76
|
+
'action.feishu': '飞书引用',
|
|
77
|
+
'feishu.placeholder': '搜索飞书文档 / 云盘 / 群 / 消息 / 联系人',
|
|
78
|
+
'feishu.empty': '没有搜到结果',
|
|
79
|
+
'feishu.loading': '搜索中…',
|
|
80
|
+
'feishu.unavailable': '飞书引用不可用(需要安装 feishu-ref 插件)',
|
|
81
|
+
'feishu.meta.docs': '文档',
|
|
82
|
+
'feishu.meta.files': '云盘',
|
|
83
|
+
'feishu.meta.chats': '群聊',
|
|
84
|
+
'feishu.meta.messages': '消息',
|
|
85
|
+
'feishu.meta.contacts': '联系人',
|
|
76
86
|
'action.removeAttachment': '移除',
|
|
77
87
|
'quote.hint': '先在聊天里选中一段文字,再点「引用选中」;推送时它会还原成真正的引用块。',
|
|
78
88
|
'quote.empty': '先在聊天里选中一段文字',
|
|
@@ -113,6 +123,16 @@ window.__ModuleLoader__.load({
|
|
|
113
123
|
'action.saveEdit': 'Save',
|
|
114
124
|
'action.quote': 'Quote selection',
|
|
115
125
|
'action.image': 'Add image',
|
|
126
|
+
'action.feishu': 'Feishu ref',
|
|
127
|
+
'feishu.placeholder': 'Search Feishu docs / drive / chats / messages / people',
|
|
128
|
+
'feishu.empty': 'No results',
|
|
129
|
+
'feishu.loading': 'Searching…',
|
|
130
|
+
'feishu.unavailable': 'Feishu references need the feishu-ref plugin',
|
|
131
|
+
'feishu.meta.docs': 'Docs',
|
|
132
|
+
'feishu.meta.files': 'Drive',
|
|
133
|
+
'feishu.meta.chats': 'Chats',
|
|
134
|
+
'feishu.meta.messages': 'Messages',
|
|
135
|
+
'feishu.meta.contacts': 'People',
|
|
116
136
|
'action.removeAttachment': 'Remove',
|
|
117
137
|
'quote.hint': 'Select text in the chat first, then press Quote selection; pushing rebuilds it as a real quote block.',
|
|
118
138
|
'quote.empty': 'Select text in the chat first',
|
|
@@ -232,6 +252,24 @@ window.__ModuleLoader__.load({
|
|
|
232
252
|
return payload.queue || { items: [] }
|
|
233
253
|
}
|
|
234
254
|
|
|
255
|
+
/**
|
|
256
|
+
* The exact text feishu-ref would insert into the composer, so a reference
|
|
257
|
+
* taken here is identical to one taken from the composer's own panel.
|
|
258
|
+
*/
|
|
259
|
+
function feishuText(item) {
|
|
260
|
+
if (!item) return ''
|
|
261
|
+
if (item.type === 'message') {
|
|
262
|
+
const label = [item.chatName, item.sender].filter(Boolean).join(' · ') || '飞书消息'
|
|
263
|
+
const link = item.url ? '[' + label + '](' + item.url + ')' : label
|
|
264
|
+
return item.messageId ? link + '(message_id: ' + item.messageId + ') ' : link + ' '
|
|
265
|
+
}
|
|
266
|
+
if (item.type === 'contact') {
|
|
267
|
+
const link = item.url ? '[' + item.title + '](' + item.url + ')' : item.title
|
|
268
|
+
return item.openId ? link + '(open_id: ' + item.openId + ') ' : link + ' '
|
|
269
|
+
}
|
|
270
|
+
return '[' + item.title + '](' + item.url + ') '
|
|
271
|
+
}
|
|
272
|
+
|
|
235
273
|
/** Rows written by earlier versions carry a single 'text' field. */
|
|
236
274
|
function segmentsOfItem(item) {
|
|
237
275
|
if (item && Array.isArray(item.segments) && item.segments.length > 0) return item.segments
|
|
@@ -326,6 +364,15 @@ window.__ModuleLoader__.load({
|
|
|
326
364
|
'.dsh-pending-queue-edit{box-sizing:border-box;width:100%;min-height:52px;resize:vertical;border-radius:var(--dsw-radius-sm,8px);',
|
|
327
365
|
' border:0.5px solid var(--dsw-alias-border-l3,#ffffff1a);background:transparent;color:inherit;font:inherit;padding:6px 8px;margin:2px 0}',
|
|
328
366
|
'.dsh-pending-queue-notice{flex:none;margin:0 12px 6px;font-size:11.5px;color:var(--dsw-alias-label-tertiary,#9a9aa2)}',
|
|
367
|
+
'.dsh-pending-queue-feishu{margin:8px 0 0;border:0.5px solid var(--dsw-alias-border-l3,#ffffff1a);border-radius:var(--dsw-radius-sm,8px);overflow:hidden}',
|
|
368
|
+
'.dsh-pending-queue-feishuInput{box-sizing:border-box;width:100%;border:0;outline:0;background:transparent;color:inherit;font:inherit;padding:8px 10px;border-bottom:0.5px solid var(--dsw-alias-border-l3,#ffffff14)}',
|
|
369
|
+
'.dsh-pending-queue-feishuBody{max-height:220px;overflow:auto}',
|
|
370
|
+
'.dsh-pending-queue-feishuHint{padding:8px 10px;font-size:11.5px;color:var(--dsw-alias-label-tertiary,#9a9aa2)}',
|
|
371
|
+
'.dsh-pending-queue-feishuGroup{padding:6px 10px 2px;font-size:11px;color:var(--dsw-alias-label-tertiary,#9a9aa2)}',
|
|
372
|
+
'.dsh-pending-queue-feishuRow{all:unset;box-sizing:border-box;display:flex;flex-direction:column;gap:1px;width:100%;padding:5px 10px;cursor:pointer}',
|
|
373
|
+
'.dsh-pending-queue-feishuRow:hover{background:var(--dsw-alias-interactive-bg-hover,#ffffff14)}',
|
|
374
|
+
'.dsh-pending-queue-feishuTitle{font-size:12.5px;color:var(--dsw-alias-label-primary,#e8e8ea);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
375
|
+
'.dsh-pending-queue-feishuMeta{font-size:10.5px;color:var(--dsw-alias-label-tertiary,#9a9aa2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
329
376
|
].join('\n')
|
|
330
377
|
|
|
331
378
|
/* -------------------------------- component ------------------------------- */
|
|
@@ -341,6 +388,7 @@ window.__ModuleLoader__.load({
|
|
|
341
388
|
const [draft, setDraft] = useState('')
|
|
342
389
|
const [quotes, setQuotes] = useState([])
|
|
343
390
|
const [images, setImages] = useState([])
|
|
391
|
+
const [feishu, setFeishu] = useState({ open: false, q: '', loading: false, error: '', result: null })
|
|
344
392
|
const [editing, setEditing] = useState(null)
|
|
345
393
|
const [busy, setBusy] = useState('')
|
|
346
394
|
const [notice, setNotice] = useState('')
|
|
@@ -666,6 +714,48 @@ window.__ModuleLoader__.load({
|
|
|
666
714
|
setError('')
|
|
667
715
|
}, [t])
|
|
668
716
|
|
|
717
|
+
/** Debounced search against the feishu-ref plugin's own route. */
|
|
718
|
+
useEffect(() => {
|
|
719
|
+
if (!feishu.open) return undefined
|
|
720
|
+
const query = feishu.q.trim()
|
|
721
|
+
if (query === '') {
|
|
722
|
+
setFeishu((current) => ({ ...current, result: null, error: '', loading: false }))
|
|
723
|
+
return undefined
|
|
724
|
+
}
|
|
725
|
+
let cancelled = false
|
|
726
|
+
const timer = setTimeout(async () => {
|
|
727
|
+
setFeishu((current) => ({ ...current, loading: true, error: '' }))
|
|
728
|
+
try {
|
|
729
|
+
const response = await fetch('/plugins/feishu-ref/search', {
|
|
730
|
+
method: 'POST',
|
|
731
|
+
headers: { 'content-type': 'application/json' },
|
|
732
|
+
body: JSON.stringify({ q: query }),
|
|
733
|
+
})
|
|
734
|
+
const payload = await readJson(response)
|
|
735
|
+
if (!response.ok || payload.ok !== true) throw new Error(payload.message || ('HTTP ' + response.status))
|
|
736
|
+
if (cancelled || !live.current) return
|
|
737
|
+
setFeishu((current) => ({ ...current, loading: false, result: payload, error: '' }))
|
|
738
|
+
} catch {
|
|
739
|
+
if (cancelled || !live.current) return
|
|
740
|
+
setFeishu((current) => ({ ...current, loading: false, result: null, error: t('feishu.unavailable') }))
|
|
741
|
+
}
|
|
742
|
+
}, 350)
|
|
743
|
+
return () => {
|
|
744
|
+
cancelled = true
|
|
745
|
+
clearTimeout(timer)
|
|
746
|
+
}
|
|
747
|
+
}, [feishu.open, feishu.q, t])
|
|
748
|
+
|
|
749
|
+
/** Append a Feishu reference as ordinary text, same string the composer inserts. */
|
|
750
|
+
const pickFeishu = useCallback((item) => {
|
|
751
|
+
const text = feishuText(item)
|
|
752
|
+
if (text === '') return
|
|
753
|
+
const next = draft.trim() === '' ? text : draft.replace(/\s+$/, '') + '\n' + text
|
|
754
|
+
setDraft(next)
|
|
755
|
+
persist({ draft: next, quotes, images })
|
|
756
|
+
setFeishu({ open: false, q: '', loading: false, error: '', result: null })
|
|
757
|
+
}, [draft, persist, quotes, images])
|
|
758
|
+
|
|
669
759
|
const openPicker = useCallback((target) => {
|
|
670
760
|
pickerTarget.current = target
|
|
671
761
|
if (fileInput.current) fileInput.current.click()
|
|
@@ -721,6 +811,37 @@ window.__ModuleLoader__.load({
|
|
|
721
811
|
})
|
|
722
812
|
}
|
|
723
813
|
|
|
814
|
+
function renderFeishuResults() {
|
|
815
|
+
const result = feishu.result
|
|
816
|
+
if (!result) return h('div', { key: 'hint', className: ROOT + '-feishuHint' }, t('feishu.placeholder'))
|
|
817
|
+
const groups = [
|
|
818
|
+
['docs', result.docs],
|
|
819
|
+
['files', result.files],
|
|
820
|
+
['chats', result.chats],
|
|
821
|
+
['messages', result.messages],
|
|
822
|
+
['contacts', result.contacts],
|
|
823
|
+
].filter(([, list]) => Array.isArray(list) && list.length > 0)
|
|
824
|
+
if (groups.length === 0) return h('div', { key: 'empty', className: ROOT + '-feishuHint' }, t('feishu.empty'))
|
|
825
|
+
const rows = []
|
|
826
|
+
for (const [key, list] of groups) {
|
|
827
|
+
rows.push(h('div', { key: 'g' + key, className: ROOT + '-feishuGroup' }, t('feishu.meta.' + key)))
|
|
828
|
+
for (const item of list.slice(0, 4)) {
|
|
829
|
+
const label = item.title || item.url || ''
|
|
830
|
+
rows.push(h('button', {
|
|
831
|
+
key: key + ':' + (item.url || label),
|
|
832
|
+
type: 'button',
|
|
833
|
+
className: ROOT + '-feishuRow',
|
|
834
|
+
title: feishuText(item),
|
|
835
|
+
onClick: () => pickFeishu(item),
|
|
836
|
+
}, [
|
|
837
|
+
h('span', { key: 't', className: ROOT + '-feishuTitle' }, label),
|
|
838
|
+
item.url ? h('span', { key: 'u', className: ROOT + '-feishuMeta' }, String(item.url).slice(0, 56)) : null,
|
|
839
|
+
]))
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return rows
|
|
843
|
+
}
|
|
844
|
+
|
|
724
845
|
function renderRow(item, index) {
|
|
725
846
|
const isEditing = editing !== null && editing.id === item.id
|
|
726
847
|
const isSent = item.sentAt !== null && item.sentAt !== undefined
|
|
@@ -913,6 +1034,29 @@ window.__ModuleLoader__.load({
|
|
|
913
1034
|
}, '×'),
|
|
914
1035
|
])))
|
|
915
1036
|
: null,
|
|
1037
|
+
feishu.open
|
|
1038
|
+
? h('div', { key: 'feishu', className: ROOT + '-feishu' }, [
|
|
1039
|
+
h('input', {
|
|
1040
|
+
key: 'q',
|
|
1041
|
+
className: ROOT + '-feishuInput',
|
|
1042
|
+
autoFocus: true,
|
|
1043
|
+
value: feishu.q,
|
|
1044
|
+
placeholder: t('feishu.placeholder'),
|
|
1045
|
+
onChange: (event) => setFeishu((current) => ({ ...current, q: event.target.value })),
|
|
1046
|
+
onKeyDown: (event) => {
|
|
1047
|
+
if (event.key !== 'Escape') return
|
|
1048
|
+
event.preventDefault()
|
|
1049
|
+
setFeishu({ open: false, q: '', loading: false, error: '', result: null })
|
|
1050
|
+
},
|
|
1051
|
+
}),
|
|
1052
|
+
h('div', { key: 'body', className: ROOT + '-feishuBody' },
|
|
1053
|
+
feishu.loading
|
|
1054
|
+
? [h('div', { key: 'l', className: ROOT + '-feishuHint' }, t('feishu.loading'))]
|
|
1055
|
+
: feishu.error !== ''
|
|
1056
|
+
? [h('div', { key: 'e', className: ROOT + '-feishuHint' }, feishu.error)]
|
|
1057
|
+
: renderFeishuResults()),
|
|
1058
|
+
])
|
|
1059
|
+
: null,
|
|
916
1060
|
h('div', { key: 'foot', className: ROOT + '-composeFoot' }, [
|
|
917
1061
|
h('span', { key: 'hint', className: ROOT + '-hint' }, images.length > 0
|
|
918
1062
|
? t('image.hint')
|
|
@@ -931,6 +1075,12 @@ window.__ModuleLoader__.load({
|
|
|
931
1075
|
else void uploadImage(picked)
|
|
932
1076
|
},
|
|
933
1077
|
}),
|
|
1078
|
+
h('button', {
|
|
1079
|
+
key: 'feishu', type: 'button', className: ROOT + '-ghost',
|
|
1080
|
+
onClick: () => setFeishu((current) => ({
|
|
1081
|
+
open: !current.open, q: current.open ? '' : current.q, loading: false, error: '', result: null,
|
|
1082
|
+
})),
|
|
1083
|
+
}, t('action.feishu')),
|
|
934
1084
|
h('button', { key: 'image', type: 'button', className: ROOT + '-ghost', onClick: () => { if (fileInput.current) fileInput.current.click() } }, t('action.image')),
|
|
935
1085
|
h('button', { key: 'quote', type: 'button', className: ROOT + '-ghost', onClick: addQuote }, t('action.quote')),
|
|
936
1086
|
h('button', {
|
|
@@ -1012,8 +1162,7 @@ window.__ModuleLoader__.load({
|
|
|
1012
1162
|
}, QueueBody)))
|
|
1013
1163
|
disposers.push(ctx.slots.inject('sidebar.right.pane.tab.title', () => ctx.slots.register({
|
|
1014
1164
|
name: 'sidebar.right.pane.tab.title',
|
|
1015
|
-
key: PKG,
|
|
1016
|
-
locale: NS,
|
|
1165
|
+
key: PKG, locale: NS,
|
|
1017
1166
|
}, QueueTitle)))
|
|
1018
1167
|
|
|
1019
1168
|
return () => {
|
|
@@ -1029,4 +1178,4 @@ window.__ModuleLoader__.load({
|
|
|
1029
1178
|
},
|
|
1030
1179
|
}
|
|
1031
1180
|
},
|
|
1032
|
-
})
|
|
1181
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyra_wang/dsh-pending-queue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Right-sidebar draft queue for DeepSeek Harness: jot ideas down, quote chat text, attach images, then push one into the session when the previous task is finished.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|