nx-kv 0.68.0 → 0.68.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.
- package/CHANGELOG.md +60 -0
- package/package.json +1 -1
- package/src/core/db/seed-templates.ts +10 -50
- package/src/web/frontend/App.tsx +12 -0
- package/src/web/frontend/components/layout/vsc-crumbs.css +16 -9
- package/src/web/frontend/components/layout/vsc-crumbs.tsx +47 -25
- package/src/web/frontend/components/popup/index.tsx +4 -1
- package/src/web/frontend/components/popup/style.css +2 -0
- package/src/web/frontend/components/sidebar/index.tsx +4 -2
- package/src/web/frontend/components/sidebar/ns-dialogs.tsx +9 -2
- package/src/web/frontend/components/sidebar/ns-manage-modal.tsx +80 -23
- package/src/web/frontend/components/sidebar/use-ns.ts +11 -1
- package/src/web/frontend/components/task-panel/task-page.tsx +1 -0
- package/src/web/frontend/components/task-panel/task-row.tsx +50 -21
- package/src/web/frontend/modules/md/fill-session.ts +36 -0
- package/src/web/frontend/modules/md/new-task-from-template.ts +22 -0
- package/src/web/frontend/modules/md/task-intent.ts +29 -0
- package/src/web/frontend/modules/prompts/render-template-body.ts +14 -0
- package/src/web/frontend/modules/prompts/template-preview.ts +62 -0
- package/src/web/frontend/page/dir/index.tsx +13 -3
- package/src/web/frontend/page/dir/task-beside.ts +64 -0
- package/src/web/frontend/page/dir/task.tsx +12 -24
- package/src/web/frontend/page/dir/use-auto-submit.ts +20 -0
- package/src/web/frontend/page/group/index.tsx +19 -3
- package/src/web/frontend/page/templates/fill.tsx +128 -0
- package/src/web/frontend/page/templates/index.tsx +6 -0
- package/src/web/frontend/page/templates/manage.tsx +7 -33
- package/src/web/frontend/page/templates/style.css +32 -5
- package/src/web/frontend/page/templates/template-list.tsx +48 -68
- package/src/web/frontend/routes/templates.ts +10 -0
- package/src/web/frontend/styles-v2/dag.css +22 -1
- package/src/web/frontend/styles-v2/sidebar.css +15 -0
- package/src/web/public/assets/app-context-KCsdqNTq.js +1 -0
- package/src/web/public/assets/{bar-C-XvccT_.js → bar-DEY9q8mI.js} +1 -1
- package/src/web/public/assets/{button-Cs6w2CDi.js → button-BRGGaUcY.js} +1 -1
- package/src/web/public/assets/{composer-launch-DocQvHKh.js → composer-launch-DEHhs8k_.js} +1 -1
- package/src/web/public/assets/{composer-panel-BYxKIE03.js → composer-panel-Btmv_9MI.js} +1 -1
- package/src/web/public/assets/{dag-EGY58BeS.js → dag-CD7N_yfu.js} +1 -1
- package/src/web/public/assets/dir-B0nwSQhy.js +1 -0
- package/src/web/public/assets/{doc-CKbuO1Gj.js → doc-R8KHVCxp.js} +1 -1
- package/src/web/public/assets/group-B-f_aoow.js +1 -0
- package/src/web/public/assets/index-Bs5BehN8.js +3 -0
- package/src/web/public/assets/{index-BruTRXSA.css → index-GyxCJY9y.css} +1 -1
- package/src/web/public/assets/manage-session-CuaL7QqQ.js +1 -0
- package/src/web/public/assets/{md-history-sxG54jJ_.js → md-history-BR2jLhFQ.js} +1 -1
- package/src/web/public/assets/{member-picker-CHX0nS0O.js → member-picker-BJ-Ucm-9.js} +1 -1
- package/src/web/public/assets/{popup-dBtYqEM1.js → popup-BdVXUaJk.js} +1 -1
- package/src/web/public/assets/{popup-BAvk7J7u.css → popup-CHK8uSG4.css} +1 -1
- package/src/web/public/assets/{progress-CPQSMxLp.js → progress-CLSIX544.js} +1 -1
- package/src/web/public/assets/{refs-Bzf1kVpx.js → refs-Cb9pmVsb.js} +1 -1
- package/src/web/public/assets/{reopen-text-B2d9SZi0.js → reopen-text-C3dnqygC.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-geOSTx9x.js → repo-form-modal-awEPCcJK.js} +1 -1
- package/src/web/public/assets/{repos-BbKWW4no.js → repos-CIgKjolu.js} +1 -1
- package/src/web/public/assets/{route-crumb-CqDySF_k.js → route-crumb-DvXzznKm.js} +1 -1
- package/src/web/public/assets/{settings-iqLRF9ip.js → settings-BD9rXOpy.js} +1 -1
- package/src/web/public/assets/task-CJyFbImw.js +14 -0
- package/src/web/public/assets/task-intent-CX5DZccN.js +1 -0
- package/src/web/public/assets/{task-Dcd2eA8B.css → task-j7fMfJUp.css} +1 -1
- package/src/web/public/assets/task-ops-CsiArYZB.js +2 -0
- package/src/web/public/assets/template-preview-CjQ-ucPt.js +1 -0
- package/src/web/public/assets/templates-BC-bPIfY.js +10 -0
- package/src/web/public/assets/templates-DiEKBY-m.css +1 -0
- package/src/web/public/assets/{tool-bar-DpfJRjFG.js → tool-bar-CAMqYt5j.js} +1 -1
- package/src/web/public/assets/{use-rail-drag-DcUzHeV_.js → use-rail-drag-C3GpkThI.js} +1 -1
- package/src/web/public/index.html +12 -12
- package/src/web/frontend/page/templates/scope-chips.tsx +0 -237
- package/src/web/public/assets/app-context-CngKv8Tc.js +0 -1
- package/src/web/public/assets/dir-BjMCzD3e.js +0 -1
- package/src/web/public/assets/group-Bh5tkQR3.js +0 -1
- package/src/web/public/assets/index-cyRcywoY.js +0 -3
- package/src/web/public/assets/manage-session-CS8UvmUd.js +0 -1
- package/src/web/public/assets/task-BeaiJyO3.js +0 -14
- package/src/web/public/assets/task-ops-BKVm1WHw.js +0 -2
- package/src/web/public/assets/templates-B32TlcGk.js +0 -10
- package/src/web/public/assets/templates-CwYDIBYn.css +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// 参数填写中间页(#151):从「新建任务」下拉点带 {{槽位}} 的模板时先到这里。
|
|
2
|
+
//
|
|
3
|
+
// 槽位只活到「任务正文生成前」——这一页把模板正文渲染成**纯文本**草稿,
|
|
4
|
+
// 不再往任务里写 template: frontmatter、编辑器零槽位概念。两个出口:
|
|
5
|
+
// · 直接提交:进任务页后自动 submit() 落库为待领取任务;
|
|
6
|
+
// · 进入编辑页:进任务页保留草稿(不落库)。
|
|
7
|
+
// 所有参数都是可选长编辑框,留空按空串填充。
|
|
8
|
+
import { useMemo, useState } from 'react';
|
|
9
|
+
import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
|
|
10
|
+
import { popRoute } from '../../components/layout/route-history.js';
|
|
11
|
+
import { Button } from '../../components/button/index.jsx';
|
|
12
|
+
import { Icon } from '../../components/icons.jsx';
|
|
13
|
+
import { useApp } from '../../app-context.jsx';
|
|
14
|
+
import { useToast } from '../../components/toast/index.jsx';
|
|
15
|
+
import { docIdOf, nextDraftId, saveDoc, scopeOf } from '../../modules/md/doc-store.js';
|
|
16
|
+
import { titleFromMd } from '../../modules/md/md-parse.js';
|
|
17
|
+
import { getFillSession, dropFillSession } from '../../modules/md/fill-session.js';
|
|
18
|
+
import { setTaskIntent } from '../../modules/md/task-intent.js';
|
|
19
|
+
import { templateDraftBody, templateSlots } from '../../modules/prompts/template-preview.js';
|
|
20
|
+
import './style.css';
|
|
21
|
+
|
|
22
|
+
interface FillPanelProps {
|
|
23
|
+
config?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function TemplateFillPanel({ config }: FillPanelProps) {
|
|
27
|
+
const app = useApp();
|
|
28
|
+
const toast = useToast();
|
|
29
|
+
const session = useMemo(() => getFillSession(config?.id), [config?.id]);
|
|
30
|
+
const tmpl = useMemo(
|
|
31
|
+
() => (app.tpl?.templates || []).find((t) => t.id === (session || {})?.templateId) || null,
|
|
32
|
+
[app.tpl?.templates, session],
|
|
33
|
+
);
|
|
34
|
+
const slots = useMemo(() => (tmpl ? templateSlots(tmpl.body) : []), [tmpl]);
|
|
35
|
+
const [values, setValues] = useState<Record<string, string>>(() => {
|
|
36
|
+
const out: Record<string, string> = {};
|
|
37
|
+
for (const s of slots) out[s] = String((tmpl?.values || {})[s] ?? '');
|
|
38
|
+
return out;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (!session || !tmpl) {
|
|
42
|
+
return (
|
|
43
|
+
<div className="rp-page tpl-fill-page">
|
|
44
|
+
<RouteBreadcrumb />
|
|
45
|
+
<div className="pad muted">参数会话已失效——请从「新建任务」下拉重新选择模板。</div>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const setValue = (key: string, val: string) => setValues((m) => ({ ...m, [key]: val }));
|
|
51
|
+
|
|
52
|
+
/** 渲染正文 → 种草稿 → 开任务页。submit=true 时留一次性 intent 触发自动提交。 */
|
|
53
|
+
const proceed = (submit: boolean) => {
|
|
54
|
+
const extra: Record<string, unknown> = {};
|
|
55
|
+
if (session.board) extra.board = session.board;
|
|
56
|
+
if (session.project) extra.project = session.project;
|
|
57
|
+
const body = templateDraftBody(
|
|
58
|
+
{ id: tmpl.id, body: tmpl.body, values: tmpl.values },
|
|
59
|
+
extra,
|
|
60
|
+
values,
|
|
61
|
+
);
|
|
62
|
+
const task = nextDraftId();
|
|
63
|
+
const rootKey = session.groupId || session.dirKey || '';
|
|
64
|
+
const docId = docIdOf(scopeOf(rootKey), task);
|
|
65
|
+
// 标题从渲染后的正文首行反推(模板常以 `# {{标题}}` 开头)——否则编辑页显示「无标题」
|
|
66
|
+
saveDoc(docId, { title: titleFromMd(body, ''), body });
|
|
67
|
+
// intent key 必须与任务页取用侧一致:task.tsx 用 docIdOf(scope, task) 取,
|
|
68
|
+
// 若存裸 task id 就永远取不到——「直接提交」会退化成「进入编辑页」(#156 的坑)。
|
|
69
|
+
if (submit) setTaskIntent(docId, { submit: true });
|
|
70
|
+
dropFillSession(config?.id);
|
|
71
|
+
const spec = session.groupId
|
|
72
|
+
? { groupId: session.groupId, task, name: '新任务' }
|
|
73
|
+
: { dirKey: session.dirKey, task, name: '新任务' };
|
|
74
|
+
app.openPage?.(spec);
|
|
75
|
+
toast(submit ? '正在提交任务…' : '已进入草稿编辑');
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className="rp-page tpl-fill-page">
|
|
80
|
+
<RouteBreadcrumb />
|
|
81
|
+
<div className="page-head">
|
|
82
|
+
<div className="title-block">
|
|
83
|
+
<h2><Icon name="list" size={16} /> 填写模板参数</h2>
|
|
84
|
+
<p className="muted tpl-head-note">
|
|
85
|
+
「{tmpl.name}」· 全部可选,留空即为空白。生成的是纯文本任务,编辑页不会再出现槽位框。
|
|
86
|
+
</p>
|
|
87
|
+
</div>
|
|
88
|
+
<div className="acts">
|
|
89
|
+
<Button
|
|
90
|
+
variant="secondary"
|
|
91
|
+
small
|
|
92
|
+
onClick={() => app.onNavigate?.(popRoute() || '#/templates')}
|
|
93
|
+
>
|
|
94
|
+
<Icon name="back" size={13} /> 返回
|
|
95
|
+
</Button>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div className="tpl-fill-body">
|
|
100
|
+
{slots.length === 0 ? (
|
|
101
|
+
<div className="muted tpl-fill-empty">这条模板没有参数槽位,可直接进入任务编辑。</div>
|
|
102
|
+
) : (
|
|
103
|
+
slots.map((key) => (
|
|
104
|
+
<label key={key} className="tpl-fill-field">
|
|
105
|
+
<span className="tpl-fill-label">{key}</span>
|
|
106
|
+
<textarea
|
|
107
|
+
className="tpl-fill-input"
|
|
108
|
+
value={values[key] ?? ''}
|
|
109
|
+
placeholder={`填写「${key}」(可留空)`}
|
|
110
|
+
onChange={(e) => setValue(key, e.target.value)}
|
|
111
|
+
rows={4}
|
|
112
|
+
/>
|
|
113
|
+
</label>
|
|
114
|
+
))
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<div className="tpl-fill-foot">
|
|
119
|
+
<Button variant="secondary" onClick={() => proceed(false)}>
|
|
120
|
+
<Icon name="edit" size={13} /> 进入编辑页(草稿)
|
|
121
|
+
</Button>
|
|
122
|
+
<Button variant="primary" onClick={() => proceed(true)}>
|
|
123
|
+
<Icon name="check" size={13} /> 直接提交
|
|
124
|
+
</Button>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -14,6 +14,7 @@ import { clearHistory, pushHistory, redoHistory, undoHistory } from '../../modul
|
|
|
14
14
|
import { popRoute } from '../../components/layout/route-history.js';
|
|
15
15
|
import TemplateListPanel from './template-list.jsx';
|
|
16
16
|
import TemplateManagePanel from './manage.jsx';
|
|
17
|
+
import TemplateFillPanel from './fill.jsx';
|
|
17
18
|
import '../../modules/md/style.css';
|
|
18
19
|
import './style.css';
|
|
19
20
|
|
|
@@ -194,6 +195,11 @@ export default function TemplatePanel({ config, model, tabId }: TemplatePanelPro
|
|
|
194
195
|
return <TemplateManagePanel config={cfg} />;
|
|
195
196
|
}
|
|
196
197
|
|
|
198
|
+
// #151/#191:参数填写中间页(带 {{槽位}} 的模板先填值,再生成纯文本草稿)
|
|
199
|
+
if (mode === 'fill') {
|
|
200
|
+
return <TemplateFillPanel config={cfg} />;
|
|
201
|
+
}
|
|
202
|
+
|
|
197
203
|
// #142:关闭/创建后回到来处面板,不要 deleteTab 把 maincontent 拆空。
|
|
198
204
|
const leaveEditor = () => {
|
|
199
205
|
const prev = popRoute();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// 主题级任务模板管理(#151
|
|
2
|
-
// topic
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// 主题级任务模板管理(#151 / #191):从「新建任务」下拉的「管理模板…」进来,
|
|
2
|
+
// 只管这个 topic 下可见的模板。#191 起可见范围不再手动配置——按 topic 维度列出
|
|
3
|
+
// 本主题模板,支持 filter / 拖拽改顺序(template.reorder)/ 编辑 / 设默认 / 删除。
|
|
4
|
+
// 参考自定义工具栏的编排面板,但更贴数据列表:一行一条,信息密度优先。
|
|
5
5
|
import { useMemo, useState } from 'react';
|
|
6
6
|
import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
|
|
7
7
|
import { Button } from '../../components/button/index.jsx';
|
|
@@ -13,7 +13,6 @@ import { filterByKeyword } from '../../modules/list-filter.js';
|
|
|
13
13
|
import { useTemplatesFor } from '../../modules/md/use-templates.js';
|
|
14
14
|
import { getManageSession } from '../../modules/md/manage-session.js';
|
|
15
15
|
import type { PromptTemplate, TemplatesApi } from '../../types.js';
|
|
16
|
-
import ScopeChips from './scope-chips.jsx';
|
|
17
16
|
import './style.css';
|
|
18
17
|
|
|
19
18
|
interface ManagePanelProps {
|
|
@@ -33,15 +32,10 @@ export default function TemplateManagePanel({ config }: ManagePanelProps) {
|
|
|
33
32
|
const [q, setQ] = useState('');
|
|
34
33
|
const [dragId, setDragId] = useState<string | null>(null);
|
|
35
34
|
const [overId, setOverId] = useState<string | null>(null);
|
|
36
|
-
const [scopeOpenId, setScopeOpenId] = useState<string | null>(null);
|
|
37
35
|
const [busy, setBusy] = useState(false);
|
|
38
36
|
|
|
39
37
|
const rows = scoped.templates || [];
|
|
40
|
-
const shown = filterByKeyword(rows, q, (t) => [
|
|
41
|
-
t.name,
|
|
42
|
-
t.body,
|
|
43
|
-
(t.scope || []).join(' '),
|
|
44
|
-
]);
|
|
38
|
+
const shown = filterByKeyword(rows, q, (t) => [t.name, t.body]);
|
|
45
39
|
|
|
46
40
|
const act = async (fn: () => Promise<unknown>, ok?: string) => {
|
|
47
41
|
if (busy) return;
|
|
@@ -91,7 +85,7 @@ export default function TemplateManagePanel({ config }: ManagePanelProps) {
|
|
|
91
85
|
<div className="title-block">
|
|
92
86
|
<h2><Icon name="gear" size={16} /> 管理模板 · {label}</h2>
|
|
93
87
|
<p className="muted tpl-head-note">
|
|
94
|
-
|
|
88
|
+
这里管理本主题的模板:拖动左侧把手调整顺序,编辑正文 / 设默认 / 删除。搜索框会同步隐藏不匹配的行。
|
|
95
89
|
</p>
|
|
96
90
|
</div>
|
|
97
91
|
<div className="acts">
|
|
@@ -105,7 +99,7 @@ export default function TemplateManagePanel({ config }: ManagePanelProps) {
|
|
|
105
99
|
<ListSearch
|
|
106
100
|
value={q}
|
|
107
101
|
onChange={setQ}
|
|
108
|
-
placeholder="搜索名称 /
|
|
102
|
+
placeholder="搜索名称 / 正文…"
|
|
109
103
|
title="过滤本主题模板"
|
|
110
104
|
count={shown.length}
|
|
111
105
|
className="wide"
|
|
@@ -151,19 +145,8 @@ export default function TemplateManagePanel({ config }: ManagePanelProps) {
|
|
|
151
145
|
{isDefault && <span className="tpl-badge">默认</span>}
|
|
152
146
|
{t.builtin && <span className="tpl-badge soft">内置</span>}
|
|
153
147
|
</div>
|
|
154
|
-
{(t.scope || []).length > 0 && !scopeOpenId && (
|
|
155
|
-
<div className="tpl-mng-scope-sum muted">可见:{(t.scope || []).join(' / ')}</div>
|
|
156
|
-
)}
|
|
157
148
|
</div>
|
|
158
149
|
<div className="tpl-mng-acts">
|
|
159
|
-
<button
|
|
160
|
-
type="button"
|
|
161
|
-
className="iconbtn"
|
|
162
|
-
title="可见范围"
|
|
163
|
-
onClick={() => setScopeOpenId(scopeOpenId === t.id ? null : t.id)}
|
|
164
|
-
>
|
|
165
|
-
<Icon name="globe" size={14} />
|
|
166
|
-
</button>
|
|
167
150
|
<button
|
|
168
151
|
type="button"
|
|
169
152
|
className="iconbtn"
|
|
@@ -195,15 +178,6 @@ export default function TemplateManagePanel({ config }: ManagePanelProps) {
|
|
|
195
178
|
</button>
|
|
196
179
|
)}
|
|
197
180
|
</div>
|
|
198
|
-
{scopeOpenId === t.id && (
|
|
199
|
-
<div className="tpl-mng-scope">
|
|
200
|
-
<ScopeChips
|
|
201
|
-
scope={t.scope}
|
|
202
|
-
originTopic={(t as unknown as { originTopic?: string }).originTopic}
|
|
203
|
-
onChange={(next: string[]) => tpl!.update(t.id, { scope: next })}
|
|
204
|
-
/>
|
|
205
|
-
</div>
|
|
206
|
-
)}
|
|
207
181
|
</div>
|
|
208
182
|
);
|
|
209
183
|
})}
|
|
@@ -21,12 +21,24 @@
|
|
|
21
21
|
.tpl-badge.soft{background:var(--soft,#F1F0EC);color:var(--mid,#8A8578);border-color:var(--line,#E4E2DC)}
|
|
22
22
|
/* 全局 .grow 有 max-width:340px(推右会停在半路)——卡片里要真推到右缘 */
|
|
23
23
|
.tpl-card-grow{flex:1 1 auto;min-width:0;max-width:none}
|
|
24
|
-
.tpl-card-acts{display:flex;align-items:
|
|
24
|
+
.tpl-card-acts{display:flex;align-items:flex-start;gap:10px;flex-wrap:wrap;justify-content:flex-end}
|
|
25
|
+
/* #191:右侧操作按钮改成「上图标 + 下小文字」——比纯图标更易扫读 */
|
|
26
|
+
.tpl-act{
|
|
27
|
+
display:inline-flex;flex-direction:column;align-items:center;gap:3px;
|
|
28
|
+
min-width:46px;padding:5px 6px;border:1px solid transparent;border-radius:8px;
|
|
29
|
+
background:transparent;color:var(--mid,#8A8578);cursor:pointer;line-height:1;
|
|
30
|
+
transition:background .14s ease,color .14s ease,border-color .14s ease;
|
|
31
|
+
}
|
|
32
|
+
.tpl-act span{font-size:10.5px;white-space:nowrap}
|
|
33
|
+
.tpl-act:hover:not(:disabled){
|
|
34
|
+
background:var(--soft,#F1F0EC);color:var(--ink,#222);border-color:var(--line,#E4E2DC);
|
|
35
|
+
}
|
|
36
|
+
.tpl-act.is-on{background:var(--mdw-accent-soft,#E8F2EE);color:var(--mdw-accent,#2F6F5E)}
|
|
37
|
+
.tpl-act:disabled{opacity:.45;cursor:not-allowed}
|
|
25
38
|
.tpl-card-sum{
|
|
26
39
|
font-size:11.5px;color:var(--ink-2,#4B515A);line-height:1.6;
|
|
27
40
|
overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
|
|
28
41
|
}
|
|
29
|
-
.tpl-card-scope{padding-top:6px;border-top:1px dashed var(--line,#E4E2DC)}
|
|
30
42
|
.tpl-preview{
|
|
31
43
|
display:flex;flex-direction:column;gap:6px;margin-top:2px;
|
|
32
44
|
padding:9px 11px;border:1px dashed var(--line,#E4E2DC);border-radius:8px;
|
|
@@ -40,6 +52,24 @@
|
|
|
40
52
|
background:var(--soft,#F1F0EC);border:1px solid var(--line,#E4E2DC);
|
|
41
53
|
}
|
|
42
54
|
|
|
55
|
+
/* ── #191 参数填写中间页(ef449ea 曾连样式一起删,本轮恢复) ───────── */
|
|
56
|
+
.tpl-fill-page{gap:12px}
|
|
57
|
+
.tpl-fill-page .page-head h2{display:flex;align-items:center;gap:7px}
|
|
58
|
+
.tpl-fill-body{
|
|
59
|
+
display:flex;flex-direction:column;gap:14px;min-width:0;max-width:720px;
|
|
60
|
+
padding:14px;border:1px solid var(--line,#E4E2DC);border-radius:10px;background:var(--paper,#fff);
|
|
61
|
+
}
|
|
62
|
+
.tpl-fill-field{display:flex;flex-direction:column;gap:6px;min-width:0}
|
|
63
|
+
.tpl-fill-label{font-size:12px;font-weight:600;color:var(--ink-2,#4B515A)}
|
|
64
|
+
.tpl-fill-input{
|
|
65
|
+
width:100%;resize:vertical;min-height:84px;padding:8px 10px;box-sizing:border-box;
|
|
66
|
+
font:400 12.5px/1.6 inherit;color:var(--ink,#222);background:var(--paper,#fff);
|
|
67
|
+
border:1px solid var(--line,#E4E2DC);border-radius:8px;
|
|
68
|
+
}
|
|
69
|
+
.tpl-fill-input:focus{outline:none;border-color:var(--mdw-accent-line,#B7D4C8)}
|
|
70
|
+
.tpl-fill-empty{padding:8px 0}
|
|
71
|
+
.tpl-fill-foot{display:flex;gap:8px;justify-content:flex-end;max-width:720px}
|
|
72
|
+
|
|
43
73
|
/* ── #151 主题级模板管理页 ─────────────────────────────────────────── */
|
|
44
74
|
.tpl-mng-page{gap:12px}
|
|
45
75
|
.tpl-mng-page .page-head h2{display:flex;align-items:center;gap:7px}
|
|
@@ -56,10 +86,7 @@
|
|
|
56
86
|
.tpl-mng-main{min-width:0}
|
|
57
87
|
.tpl-mng-line{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}
|
|
58
88
|
.tpl-mng-name{font-size:12.5px;font-weight:600;color:var(--ink,#222)}
|
|
59
|
-
.tpl-mng-scope-sum{font-size:10.5px;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
60
89
|
.tpl-mng-acts{display:flex;align-items:center;gap:2px}
|
|
61
|
-
.tpl-mng-scope{grid-column:1/-1;padding-top:8px;border-top:1px dashed var(--line,#E4E2DC)}
|
|
62
|
-
|
|
63
90
|
/* #151 图标化:图标按钮的轻状态 */
|
|
64
91
|
.tpl-card .iconbtn.is-on{background:var(--mdw-accent-soft,#E8F2EE);color:var(--mdw-accent,#2F6F5E)}
|
|
65
92
|
.tpl-page .page-head h2,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// 任务模板列表(#217:从「设置 → 任务模板」搬到侧边栏入口,在主内容区显示)。
|
|
2
2
|
//
|
|
3
|
-
// #
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// #191 重构:任务模板只负责「按模板初始化 task 草稿」,与提示词模板无关。
|
|
4
|
+
// - 可见范围配置整体下线(无 scope 按钮 / ScopeChips)——全部模板直接显示;
|
|
5
|
+
// - filter 头部固定在顶部(不再随模板数条件出现);
|
|
6
|
+
// - 右侧操作按钮改成「上图标 + 下小文字」,一眼看懂每个按钮做什么。
|
|
7
|
+
// 数据面不变:/api/templates(App 层 useTemplates 已持有一份)。
|
|
6
8
|
import { useState } from 'react';
|
|
7
9
|
import { useApp } from '../../app-context.jsx';
|
|
8
10
|
import { Button } from '../../components/button/index.jsx';
|
|
@@ -13,7 +15,6 @@ import { renderMarkdownHtml } from '../../modules/md/md-parse.js';
|
|
|
13
15
|
import { ListSearch } from '../../components/list-search.jsx';
|
|
14
16
|
import { filterByKeyword } from '../../modules/list-filter.js';
|
|
15
17
|
import type { PromptTemplate, TemplatesApi } from '../../types.js';
|
|
16
|
-
import ScopeChips from './scope-chips.jsx';
|
|
17
18
|
import './style.css';
|
|
18
19
|
|
|
19
20
|
/** 正文摘要:前两行可读内容(剥掉 markdown 标记)。 */
|
|
@@ -37,7 +38,6 @@ export default function TemplateListPanel() {
|
|
|
37
38
|
const tpl = app.tpl as TemplatesApi | undefined;
|
|
38
39
|
const toast = useToast();
|
|
39
40
|
const { dialog, node: dialogNode } = useDialog();
|
|
40
|
-
const [scopeOpenId, setScopeOpenId] = useState<string | null>(null);
|
|
41
41
|
const [previewId, setPreviewId] = useState<string | null>(null);
|
|
42
42
|
const [busy, setBusy] = useState(false);
|
|
43
43
|
const [q, setQ] = useState('');
|
|
@@ -56,7 +56,7 @@ export default function TemplateListPanel() {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const templates = tpl.templates || [];
|
|
59
|
-
const shownTemplates = filterByKeyword(templates, q, (t) => [t.name, summaryOf(t.body)
|
|
59
|
+
const shownTemplates = filterByKeyword(templates, q, (t) => [t.name, summaryOf(t.body)]);
|
|
60
60
|
|
|
61
61
|
const act = async (fn: () => Promise<unknown>, ok?: string) => {
|
|
62
62
|
if (busy) return;
|
|
@@ -77,6 +77,25 @@ export default function TemplateListPanel() {
|
|
|
77
77
|
await act(() => tpl.remove(t.id), `已删除「${t.name}」`);
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
/** 上图标 + 下小文字的单个操作按钮。 */
|
|
81
|
+
const actBtn = (
|
|
82
|
+
icon: string,
|
|
83
|
+
label: string,
|
|
84
|
+
onClick: () => void,
|
|
85
|
+
opts: { disabled?: boolean; on?: boolean } = {},
|
|
86
|
+
) => (
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
className={'tpl-act' + (opts.on ? ' is-on' : '')}
|
|
90
|
+
title={label}
|
|
91
|
+
disabled={busy || opts.disabled}
|
|
92
|
+
onClick={onClick}
|
|
93
|
+
>
|
|
94
|
+
<Icon name={icon} size={16} />
|
|
95
|
+
<span>{label}</span>
|
|
96
|
+
</button>
|
|
97
|
+
);
|
|
98
|
+
|
|
80
99
|
return (
|
|
81
100
|
<div className="rp-page tpl-page">
|
|
82
101
|
{dialogNode}
|
|
@@ -92,24 +111,23 @@ export default function TemplateListPanel() {
|
|
|
92
111
|
</div>
|
|
93
112
|
</div>
|
|
94
113
|
|
|
114
|
+
{/* #191:filter 头部固定在顶部(不再条件出现) */}
|
|
115
|
+
<div className="tpl-search">
|
|
116
|
+
<ListSearch
|
|
117
|
+
value={q}
|
|
118
|
+
onChange={setQ}
|
|
119
|
+
placeholder="搜索名称 / 正文…"
|
|
120
|
+
title="过滤任务模板"
|
|
121
|
+
count={shownTemplates.length}
|
|
122
|
+
className="wide"
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
95
126
|
{!templates.length && <div className="muted" style={{ padding: '8px 2px' }}>还没有模板(内置默认模板加载中…)。</div>}
|
|
96
|
-
{templates.length > 1 ? (
|
|
97
|
-
<div className="tpl-search">
|
|
98
|
-
<ListSearch
|
|
99
|
-
value={q}
|
|
100
|
-
onChange={setQ}
|
|
101
|
-
placeholder="搜索名称 / 正文 / 可见范围…"
|
|
102
|
-
title="过滤任务模板"
|
|
103
|
-
count={shownTemplates.length}
|
|
104
|
-
className="wide"
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
107
|
-
) : null}
|
|
108
127
|
|
|
109
128
|
<div className="tpl-list">
|
|
110
129
|
{shownTemplates.map((t) => {
|
|
111
130
|
const isDefault = t.id === tpl.defaultId;
|
|
112
|
-
const scopeOpen = scopeOpenId === t.id;
|
|
113
131
|
const previewOpen = previewId === t.id;
|
|
114
132
|
return (
|
|
115
133
|
<div key={t.id} className={'tpl-card' + (isDefault ? ' is-default' : '')}>
|
|
@@ -119,61 +137,23 @@ export default function TemplateListPanel() {
|
|
|
119
137
|
{t.builtin && <span className="tpl-badge soft">内置</span>}
|
|
120
138
|
<span className="grow tpl-card-grow" />
|
|
121
139
|
<div className="tpl-card-acts">
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
>
|
|
128
|
-
<Icon name="monitor" size={14} />
|
|
129
|
-
</button>
|
|
130
|
-
<button
|
|
131
|
-
type="button"
|
|
132
|
-
className={'iconbtn' + (scopeOpen ? ' is-on' : '')}
|
|
133
|
-
title="可见范围"
|
|
134
|
-
disabled={busy}
|
|
135
|
-
onClick={() => setScopeOpenId(scopeOpen ? null : t.id)}
|
|
136
|
-
>
|
|
137
|
-
<Icon name="globe" size={14} />
|
|
138
|
-
</button>
|
|
139
|
-
<button
|
|
140
|
-
type="button"
|
|
141
|
-
className="iconbtn"
|
|
142
|
-
title="编辑"
|
|
143
|
-
disabled={busy}
|
|
144
|
-
onClick={() => go(`#/templates/edit/${encodeURIComponent(t.id)}`)}
|
|
145
|
-
>
|
|
146
|
-
<Icon name="edit" size={14} />
|
|
147
|
-
</button>
|
|
148
|
-
{!isDefault && (
|
|
149
|
-
<button
|
|
150
|
-
type="button"
|
|
151
|
-
className="iconbtn"
|
|
152
|
-
title="设为默认"
|
|
153
|
-
disabled={busy}
|
|
154
|
-
onClick={() => act(() => tpl.setDefault(t.id), `默认模板已设为「${t.name}」`)}
|
|
155
|
-
>
|
|
156
|
-
<Icon name="star" size={14} />
|
|
157
|
-
</button>
|
|
140
|
+
{actBtn(
|
|
141
|
+
'monitor',
|
|
142
|
+
previewOpen ? '收起' : '预览',
|
|
143
|
+
() => setPreviewId(previewOpen ? null : t.id),
|
|
144
|
+
{ on: previewOpen },
|
|
158
145
|
)}
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
{actBtn('edit', '编辑', () => go(`#/templates/edit/${encodeURIComponent(t.id)}`))}
|
|
147
|
+
{!isDefault && actBtn(
|
|
148
|
+
'star',
|
|
149
|
+
'设为默认',
|
|
150
|
+
() => act(() => tpl.setDefault(t.id), `默认模板已设为「${t.name}」`),
|
|
163
151
|
)}
|
|
152
|
+
{!t.builtin && actBtn('trash', '删除', () => removeTpl(t))}
|
|
164
153
|
</div>
|
|
165
154
|
</div>
|
|
166
155
|
<div className="tpl-card-sum">{summaryOf(t.body) || '(空模板)'}</div>
|
|
167
156
|
|
|
168
|
-
{scopeOpen && (
|
|
169
|
-
<div className="tpl-card-scope">
|
|
170
|
-
<ScopeChips
|
|
171
|
-
scope={t.scope}
|
|
172
|
-
originTopic={(t as unknown as { originTopic?: string }).originTopic}
|
|
173
|
-
onChange={(next: string[]) => tpl.update(t.id, { scope: next })}
|
|
174
|
-
/>
|
|
175
|
-
</div>
|
|
176
|
-
)}
|
|
177
157
|
{previewOpen && (
|
|
178
158
|
<div className="tpl-preview">
|
|
179
159
|
<div
|
|
@@ -26,6 +26,13 @@ export const templatesPage = definePage({
|
|
|
26
26
|
name: '管理模板',
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
// #151/#191:参数填写中间页(sessionId 只在内存里)
|
|
30
|
+
if (route.mode === 'fill' && route.id) {
|
|
31
|
+
return {
|
|
32
|
+
panel: { component: 'templates', config: { mode: 'fill', id: String(route.id) } },
|
|
33
|
+
name: '填写模板参数',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
29
36
|
if (route.mode === 'new') {
|
|
30
37
|
const scope = String(route.scope || '')
|
|
31
38
|
.split(',')
|
|
@@ -60,6 +67,9 @@ export const templatesPage = definePage({
|
|
|
60
67
|
if (mode === 'manage' && cfg.id) {
|
|
61
68
|
return `#/templates/manage/${encodeURIComponent(cfg.id)}`;
|
|
62
69
|
}
|
|
70
|
+
if (mode === 'fill' && cfg.id) {
|
|
71
|
+
return `#/templates/fill/${encodeURIComponent(cfg.id)}`;
|
|
72
|
+
}
|
|
63
73
|
if (mode === 'new') {
|
|
64
74
|
const parts: string[] = [];
|
|
65
75
|
if (cfg.topic) parts.push(`topic=${encodeURIComponent(cfg.topic)}`);
|
|
@@ -143,13 +143,34 @@
|
|
|
143
143
|
.rp-proj-row .rowmenu-btn { width: 22px; height: 22px; }
|
|
144
144
|
/* #248 搜索命中上下文:命中行前后各 10 行,占满行容器第二行 */
|
|
145
145
|
.rp-proj-task-ctx {
|
|
146
|
-
flex-basis: 100%; min-width: 0;
|
|
146
|
+
flex-basis: 100%; min-width: 0;
|
|
147
147
|
margin: 0 0 4px 22px; padding: 4px 6px;
|
|
148
148
|
background: var(--paper, #fff); border: 1px solid var(--soft-2, #DDD9D2);
|
|
149
149
|
border-radius: var(--r5, 6px);
|
|
150
150
|
font: 10.5px/1.45 ui-monospace, Consolas, monospace;
|
|
151
151
|
overflow: hidden;
|
|
152
152
|
}
|
|
153
|
+
/* #192:上下文头部 + 展开全文按钮 */
|
|
154
|
+
.rp-proj-task-ctx .ctx-head {
|
|
155
|
+
display: flex; align-items: center; justify-content: space-between; gap: 8px;
|
|
156
|
+
padding: 1px 2px 4px; border-bottom: 1px dashed var(--line, #E4E2DC);
|
|
157
|
+
font-family: inherit;
|
|
158
|
+
}
|
|
159
|
+
.rp-proj-task-ctx .ctx-head-label { color: var(--faint, #A9AEB4); font-size: 10px; letter-spacing: .02em; }
|
|
160
|
+
.rp-proj-task-ctx .ctx-expand {
|
|
161
|
+
display: inline-flex; align-items: center; gap: 3px;
|
|
162
|
+
padding: 2px 6px; border: 1px solid transparent; border-radius: 5px;
|
|
163
|
+
background: transparent; color: var(--mid, #838A93); cursor: pointer;
|
|
164
|
+
font: 400 10.5px/1.3 inherit; transition: background .14s, color .14s;
|
|
165
|
+
}
|
|
166
|
+
.rp-proj-task-ctx .ctx-expand:hover { background: var(--soft, #F1F0EC); color: var(--ink, #16181C); }
|
|
167
|
+
.rp-proj-task-ctx .ctx-expand svg { transition: transform .15s; }
|
|
168
|
+
.rp-proj-task-ctx .ctx-expand.is-open svg { transform: rotate(90deg); }
|
|
169
|
+
.rp-proj-task-ctx .ctx-lines {
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
/* 收起态 = ±10 行窗口,本就有限;展开态 = 全文,给个滚动上限别撑爆列表 */
|
|
172
|
+
max-height: 360px; overflow: auto;
|
|
173
|
+
}
|
|
153
174
|
.rp-proj-task-ctx .ctx-line { display: flex; gap: 6px; min-width: 0; color: var(--mid, #838A93); white-space: pre-wrap; word-break: break-all; }
|
|
154
175
|
.rp-proj-task-ctx .ctx-line.hit { color: var(--ink, #16181C); background: var(--mdw-accent-soft); border-radius: 3px; }
|
|
155
176
|
.rp-proj-task-ctx .ctx-no { flex: none; width: 3ch; text-align: right; color: var(--faint, #A9AEB4); user-select: none; }
|
|
@@ -148,6 +148,21 @@
|
|
|
148
148
|
.ns-manage-name:hover { color: var(--mdw-accent, #2F6F5E); }
|
|
149
149
|
.ns-manage-count { margin-left: 8px; font-weight: 400; font-size: 11px; color: var(--faint, #8A8F98); }
|
|
150
150
|
.ns-manage-acts { flex: none; display: inline-flex; gap: 4px; }
|
|
151
|
+
/* #256 管理弹窗增补:顶部搜索分区 + 行内展开成员清单(增删具体项目) */
|
|
152
|
+
.ns-manage-search { display: block; margin: 2px 0 8px; }
|
|
153
|
+
.ns-manage-search input { width: 100%; height: 28px; padding: 0 10px; font: inherit; font-size: 12.5px;
|
|
154
|
+
border: 1px solid var(--soft-2, #E5E3DE); border-radius: 7px; background: var(--paper, #fff); color: inherit; }
|
|
155
|
+
.ns-manage-search input:focus-visible { outline: none; border-color: var(--mdw-accent, #2F6F5E); }
|
|
156
|
+
.ns-manage-cell { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
|
|
157
|
+
.ns-manage-items { display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
|
|
158
|
+
padding: 6px 8px 8px 14px; border-top: 1px dashed var(--line, #E7E5E0); }
|
|
159
|
+
.ns-manage-item { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; }
|
|
160
|
+
.ns-manage-item-name { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-2, #4B515A);
|
|
161
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
162
|
+
.ns-manage-item-del { flex: none; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px;
|
|
163
|
+
background: none; cursor: pointer; color: var(--mid, #838A93);
|
|
164
|
+
display: inline-flex; align-items: center; justify-content: center; }
|
|
165
|
+
.ns-manage-item-del:hover { background: rgba(179, 38, 30, 0.08); color: var(--danger, #B3261E); }
|
|
151
166
|
.trow .tw { width: 14px; flex: none; display: inline-flex; justify-content: center; color: var(--faint); transition: transform 0.15s; }
|
|
152
167
|
/* chevron 现在是「展开/收起」按钮(点行是去看内容)——给它指针与反馈 */
|
|
153
168
|
.trow .tw[role="button"] { cursor: pointer; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as e,h as t}from"./popup-BdVXUaJk.js";var n=t(e(),1),r=(0,n.createContext)({});function i(){return(0,n.useContext)(r)}export{i as n,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r}from"./popup-
|
|
1
|
+
import{a as e,d as t,f as n,h as r}from"./popup-BdVXUaJk.js";import{N as i,a,c as o,l as s,o as c,s as l}from"./tool-bar-CAMqYt5j.js";var u=r(n(),1),d=i(),f=t();function p({kind:t,renderers:n={},actions:r={},titles:i={},disabled:p={},labels:m={},className:h=``}){let{layout:g,setLayout:_}=c(t),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(null),[S,C]=(0,u.useState)(!1),w=(0,u.useRef)(null),T=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;w.current?.contains(t)||T.current?.contains(t)||y(!1)},t=e=>{e.key===`Escape`&&y(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[v]);let E=g.filter(e=>s(t,e)),D=g.filter(e=>l(t,e)),O=e=>m[e]||o(t,e).label||e,k=(n,a={})=>{let s=o(t,n);return(0,f.jsxs)(`button`,{type:`button`,className:a.primary?`btn small primary`:`btn small ghost`,title:i[n]||O(n),disabled:!!p[n],onClick:e=>r[n]&&r[n](e),children:[s.icon?(0,f.jsx)(e,{name:s.icon}):null,O(n)]},n)},A=r=>{if(r===`more`)return(0,f.jsxs)(`button`,{ref:w,type:`button`,className:`btn small ghost`+(v?` is-open`:``),title:i.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":v,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();x({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),y(e=>!e)},children:[(0,f.jsx)(e,{name:`dots`}),O(`more`),` ▾`]},`more`);let a=n[r];return a?(0,f.jsx)(`span`,{className:`ta-slot`,children:a({open:v})},r):k(r,{primary:o(t,r).section===`primary`})};return(0,f.jsxs)(`div`,{className:`ta-bar`+(h?` ${h}`:``),children:[E.map(e=>A(e.id)),v&&b&&(0,d.createPortal)((0,f.jsxs)(`div`,{ref:T,className:`ta-more-menu`,role:`menu`,style:{top:b.top,right:b.right},children:[D.length===0&&(0,f.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),D.map(n=>{let a=o(t,n.id);return(0,f.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!p[n.id],title:i[n.id]||O(n.id),onClick:e=>{y(!1);let t=r[n.id];t&&t(e)},children:[a.icon?(0,f.jsx)(e,{name:a.icon}):null,O(n.id)]},n.id)}),(0,f.jsx)(`div`,{className:`ta-more-sep`}),(0,f.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{y(!1),C(!0)},children:[(0,f.jsx)(e,{name:`gear`}),`自定义工具栏…`]})]}),document.body),S&&(0,d.createPortal)((0,f.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>C(!1),children:(0,f.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,f.jsx)(a,{kind:t,layout:g,setLayout:_,onClose:()=>C(!1)})})}),document.body)]})}export{p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t}from"./popup-
|
|
1
|
+
import{d as e,f as t}from"./popup-BdVXUaJk.js";t();var n=e(),r={primary:``,secondary:`ghost`};function i({variant:e=`secondary`,danger:t=!1,small:i=!1,className:a=``,type:o=`button`,children:s,...c}){let l=[`btn`],u=r[e]??`ghost`;return u&&l.push(u),t&&l.push(`danger`),i&&l.push(`small`),a&&l.push(a),(0,n.jsx)(`button`,{type:o,className:l.join(` `),...c,children:s})}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t}from"./popup-
|
|
1
|
+
import{a as e,d as t}from"./popup-BdVXUaJk.js";import{_ as n,f as r}from"./tool-bar-CAMqYt5j.js";import{h as i}from"./md-history-BR2jLhFQ.js";var a=t();function o({attachments:t,onRemove:n}){return t?.length?(0,a.jsxs)(`div`,{className:`mdw-attach`,children:[(0,a.jsx)(`div`,{className:`lab`,children:`附件 / 图片`}),(0,a.jsx)(`div`,{className:`list`,children:t.map(t=>(0,a.jsxs)(`div`,{className:`att`,children:[t.type===`image`&&t.url?(0,a.jsx)(`img`,{src:t.url,alt:``}):(0,a.jsx)(`div`,{className:`ico`,children:(0,a.jsx)(e,{name:`list`,size:14,title:void 0})}),(0,a.jsxs)(`div`,{className:`meta`,children:[(0,a.jsx)(`div`,{className:`n`,children:t.name}),(0,a.jsx)(`div`,{className:`s`,children:t.size})]}),(0,a.jsx)(`button`,{type:`button`,className:`x`,"aria-label":`移除`,onClick:()=>n(t.id),children:`×`})]},t.id))})]}):null}var s=`nx-kv-md-attachments-v1`;function c(){try{return JSON.parse(localStorage.getItem(s)||`{}`)||{}}catch{return{}}}function l(e){try{localStorage.setItem(s,JSON.stringify(e))}catch{}}function u(e,t){let n=c();n[e]=t,l(n)}function d(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function f(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=n,r.readAsDataURL(e)})}async function p(e){let t=[],n=[];for(let r of[...e]){let e=`a`+Date.now()+Math.random().toString(16).slice(2,6),i=/^image\//.test(r.type),a={id:e,name:r.name,type:i?`image`:`file`,size:d(r.size)};i&&(a.url=await f(r),n.push(`\n\n`)),t.push(a)}return{items:t,imageInserts:n,fileInserts:[]}}async function m(e){let t=[...e||[]];if(!t.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await i(t),n=[],r=[],a=[];for(let t of e){let e=t.fileId||t.id,i=!!t.isImage;n.push({id:e,name:t.name,type:i?`image`:`file`,size:d(Number(t.size)||0),url:`/api/file/content/${e}`});let o=t.markdown||{},s=i?o.image||``:o.file||`[${t.name}](${e})`;(i?r:a).push(`\n${s}\n`)}return{items:n,imageInserts:r,fileInserts:a}}catch{return p(e||[])}}var h=new Map;function g(e,t={}){if(!e)return null;let{mode:i=`comment`,quote:a=``,prevQuote:o=``,taskLabel:s=``,taskTitle:c=``,src:l=null,onSubmit:u=null,onFiles:d=null}=t,f=`cmp`+Date.now().toString(36)+Math.random().toString(36).slice(2,8),p=n(e);return h.set(f,{onSubmit:u,onFiles:d,prev:p}),r(e,{component:`compose`,name:i===`feedback`?`反馈`:`评论`,config:{token:f,mode:i,quote:a,prevQuote:o,taskLabel:s,taskTitle:c,src:l},location:`center`}),f}function _(e,t){let i=h.get(t);if(h.delete(t),!i||!i.prev||!e)return null;let a=n(e);return a&&a.component!==`compose`?null:r(e,i.prev)}function v(e){return h.get(e)||null}export{u as a,m as i,g as n,o,_ as r,v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,l as i}from"./popup-
|
|
1
|
+
import{a as e,d as t,f as n,h as r,l as i}from"./popup-BdVXUaJk.js";import{u as a}from"./tool-bar-CAMqYt5j.js";import{n as o}from"./app-context-KCsdqNTq.js";import"./task-status-Cjsm0xF7.js";import{C as s,a as c,i as l,n as u,r as d,t as f}from"./md-history-BR2jLhFQ.js";import"./index-Bs5BehN8.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-DEHhs8k_.js";var g=r(n(),1),_=t(),v=96;function y({token:t,mode:n=`comment`,quote:r=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=o(),w=i(),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)([]),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=n===`feedback`,N=(0,g.useRef)(new Map),P=`compose-`+t,F=()=>{f(N.current,P),ee(C.model,t)},I=(e,t=`op`)=>{u(N.current,P,{title:``,body:T},t),E(e)},L=()=>{let e=l(N.current,P,{title:``,body:T});e&&E(e.body)},R=()=>{let e=d(N.current,P,{title:``,body:T});e&&E(e.body)},z=async()=>{let e=String(T||``).trim();if(!e&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(t);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:e,attachments:D,inserts:``}),F()}catch(e){w(String(e.message||e))}finally{A(!1)}},B=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await p(e),i=[...n,...r].join(``);i&&E(e=>s(e,i,{}).body),t.length&&O(e=>[...e,...t])},V=(0,g.useRef)(null),[H,U]=(0,g.useState)(()=>localStorage.getItem(`nxkv.cmpDockOpen`)!==`0`),[W,G]=(0,g.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.cmpDockH`));return Number.isFinite(e)&&e>=v?e:176}),K=(0,g.useRef)(W);K.current=W;let[q,J]=(0,g.useState)(!1),Y=(0,g.useRef)(176);(0,g.useEffect)(()=>{localStorage.setItem(`nxkv.cmpDockOpen`,H?`1`:`0`)},[H]);let X=()=>{if(q){G(Y.current),J(!1);return}Y.current=W;let e=document.querySelector(`.cmp`)?.clientHeight||window.innerHeight;G(Math.max(v,Math.round(e*.62))),J(!0)},Z=e=>{if(!H)return;e.preventDefault(),J(!1);let t=e.clientY,n=K.current,r=e=>Math.max(v,Math.min(Math.round(e),Math.round((document.querySelector(`.cmp`)?.clientHeight||window.innerHeight)*.62))),i=e=>{K.current=r(n-(e.clientY-t)),G(K.current)},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.cmpDockH`,String(K.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},Q=()=>{let e=C.model;e&&S&&S.task&&a(e,{component:`page`,name:S.name||`原文`,config:{dirKey:S.dirKey,task:String(S.task)}})},$=!!(S&&S.task);return(0,_.jsxs)(`div`,{className:`cmp`,children:[(0,_.jsxs)(`div`,{className:`cmp-head`,children:[(0,_.jsx)(`span`,{className:`cmp-tag`+(M?` is-fb`:``),children:M?`反馈`:`评论`}),(0,_.jsx)(`div`,{className:`cmp-ctx`,children:M?(0,_.jsxs)(`span`,{className:`cmp-ctx-line`,title:x||``,children:[`反馈 `,b||``,` 的任务`,x?` · ${x}`:``]}):(0,_.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,_.jsx)(`span`,{className:`grow`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:F,disabled:k,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:z,disabled:k,children:M?`提交反馈`:`提交评论`})]}),M?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:y||`(这条任务还没有可引用的上轮总结)`}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:y||`(这条任务还没有可引用的上轮总结)`})]}):r?(0,_.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,_.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,$&&(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:Q,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),$?(0,_.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:Q,title:`点击在右侧并排显示原文,方便对照`,children:r}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:r})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(c,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+t,editorApiRef:j,onFiles:B,onSave:z,onUndo:L,onRedo:R,hideTitle:!0})}),H&&(0,_.jsxs)(`div`,{className:`mdw-dock`,style:{height:`${W}px`},children:[(0,_.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:Z,onDoubleClick:X}),(0,_.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,_.jsx)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:(0,_.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":`true`,className:`mdw-dock-tab is-on`,onClick:()=>U(!0),children:[`附件`,D.length?(0,_.jsx)(`span`,{className:`mdw-dock-tab-num`,children:D.length}):null]})}),(0,_.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,title:`添加附件`,"aria-label":`添加附件`,onClick:()=>V.current?.click(),children:(0,_.jsx)(e,{name:`plus`,title:void 0})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(e,{name:q?`collapse`:`expand`,title:void 0})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>U(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,_.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,_.jsx)(`div`,{className:`mdw-dock-body`,children:D.length?(0,_.jsx)(m,{attachments:D,onRemove:e=>O(t=>t.filter(t=>t.id!==e))}):(0,_.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有附件——粘贴 / 拖图片进正文即附件,或点右上「+」添加文件。`})})]}),(0,_.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${H?` is-on`:``}`,onClick:()=>U(e=>!e),title:`附件(点击展开/收起信息面板)`,children:[(0,_.jsx)(e,{name:`list`,title:void 0}),(0,_.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),D.length?(0,_.jsx)(`span`,{className:`mdw-sbar-num`,children:D.length}):null]}),(0,_.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${H?` is-open`:``}`,onClick:()=>U(e=>!e),title:H?`收起信息面板`:`展开信息面板`,"aria-expanded":H,"aria-label":H?`收起信息面板`:`展开信息面板`,children:(0,_.jsx)(e,{name:`chevron`,title:void 0})})]}),(0,_.jsx)(`input`,{ref:V,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&B(t)}})]})}export{y as default};
|