@lyra_wang/dsh-pending-queue 0.3.2 → 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 +2 -0
- package/client.js +176 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,8 @@ 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`),选中文档 / 云盘 / 群 / 消息 / 联系人后,插入与输入框完全相同的引用文本。
|
|
67
|
+
- 0.3.3 — 编辑态补上「引用选中」:编辑某条时也能把聊天里选中的文字加进去,和草稿区一致。
|
|
66
68
|
- 0.3.2 — 编辑态也能加图:点「编辑」后,在编辑框里粘贴/拖入图片同样生效,编辑项里也有「+ 图片」。
|
|
67
69
|
- 0.3.1 — 粘贴更稳:剪贴板只给 `items` 不给 `files` 的截图也能接住;补「+ 图片」选文件入口;未存下的草稿按会话暂存到 localStorage。
|
|
68
70
|
- 0.3.0 — 图片:面板可粘贴/拖入图片,存本机、条目带缩略图,推送时按“路径 + read_image 提示”进对话;删除行时清理不再被引用的图片文件。
|
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('')
|
|
@@ -646,6 +694,68 @@ window.__ModuleLoader__.load({
|
|
|
646
694
|
}))
|
|
647
695
|
}, [uploadFile])
|
|
648
696
|
|
|
697
|
+
/** Edit-mode quote: the selection joins the row being edited. */
|
|
698
|
+
const addEditingQuote = useCallback(() => {
|
|
699
|
+
let live = ''
|
|
700
|
+
try {
|
|
701
|
+
live = String(window.getSelection() || '')
|
|
702
|
+
} catch {
|
|
703
|
+
live = ''
|
|
704
|
+
}
|
|
705
|
+
const text = (live.trim() !== '' ? live : lastChatSelection).trim()
|
|
706
|
+
if (text === '') {
|
|
707
|
+
setError(t('quote.empty'))
|
|
708
|
+
return
|
|
709
|
+
}
|
|
710
|
+
setEditing((current) => current === null ? current : ({
|
|
711
|
+
id: current.id,
|
|
712
|
+
segments: [...current.segments, { type: 'quote', text }],
|
|
713
|
+
}))
|
|
714
|
+
setError('')
|
|
715
|
+
}, [t])
|
|
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
|
+
|
|
649
759
|
const openPicker = useCallback((target) => {
|
|
650
760
|
pickerTarget.current = target
|
|
651
761
|
if (fileInput.current) fileInput.current.click()
|
|
@@ -701,6 +811,37 @@ window.__ModuleLoader__.load({
|
|
|
701
811
|
})
|
|
702
812
|
}
|
|
703
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
|
+
|
|
704
845
|
function renderRow(item, index) {
|
|
705
846
|
const isEditing = editing !== null && editing.id === item.id
|
|
706
847
|
const isSent = item.sentAt !== null && item.sentAt !== undefined
|
|
@@ -793,6 +934,10 @@ window.__ModuleLoader__.load({
|
|
|
793
934
|
})
|
|
794
935
|
}),
|
|
795
936
|
h('div', { key: 'acts', className: ROOT + '-acts' }, [
|
|
937
|
+
h('button', {
|
|
938
|
+
key: 'quote', type: 'button', className: ROOT + '-act',
|
|
939
|
+
onClick: addEditingQuote,
|
|
940
|
+
}, t('action.quote')),
|
|
796
941
|
h('button', {
|
|
797
942
|
key: 'image', type: 'button', className: ROOT + '-act',
|
|
798
943
|
onClick: () => openPicker('edit'),
|
|
@@ -889,6 +1034,29 @@ window.__ModuleLoader__.load({
|
|
|
889
1034
|
}, '×'),
|
|
890
1035
|
])))
|
|
891
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,
|
|
892
1060
|
h('div', { key: 'foot', className: ROOT + '-composeFoot' }, [
|
|
893
1061
|
h('span', { key: 'hint', className: ROOT + '-hint' }, images.length > 0
|
|
894
1062
|
? t('image.hint')
|
|
@@ -907,6 +1075,12 @@ window.__ModuleLoader__.load({
|
|
|
907
1075
|
else void uploadImage(picked)
|
|
908
1076
|
},
|
|
909
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')),
|
|
910
1084
|
h('button', { key: 'image', type: 'button', className: ROOT + '-ghost', onClick: () => { if (fileInput.current) fileInput.current.click() } }, t('action.image')),
|
|
911
1085
|
h('button', { key: 'quote', type: 'button', className: ROOT + '-ghost', onClick: addQuote }, t('action.quote')),
|
|
912
1086
|
h('button', {
|
|
@@ -988,8 +1162,7 @@ window.__ModuleLoader__.load({
|
|
|
988
1162
|
}, QueueBody)))
|
|
989
1163
|
disposers.push(ctx.slots.inject('sidebar.right.pane.tab.title', () => ctx.slots.register({
|
|
990
1164
|
name: 'sidebar.right.pane.tab.title',
|
|
991
|
-
key: PKG,
|
|
992
|
-
locale: NS,
|
|
1165
|
+
key: PKG, locale: NS,
|
|
993
1166
|
}, QueueTitle)))
|
|
994
1167
|
|
|
995
1168
|
return () => {
|
|
@@ -1005,4 +1178,4 @@ window.__ModuleLoader__.load({
|
|
|
1005
1178
|
},
|
|
1006
1179
|
}
|
|
1007
1180
|
},
|
|
1008
|
-
})
|
|
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",
|