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
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
// 整行可点开任务(div role=button,键盘可达);行内多选框 / 操作按钮
|
|
10
10
|
// stopPropagation,点它们不触发开任务。拖拽视觉类复用 rp-proj-row
|
|
11
11
|
// 的 dragging / drop-before / drop-after(styles-v2/dag.css)。
|
|
12
|
-
import type
|
|
12
|
+
import { useState, type DragEvent as ReactDragEvent, type ReactNode } from 'react';
|
|
13
13
|
import { Icon } from '../icons.jsx';
|
|
14
14
|
import StatusTag from '../status-tag/index.jsx';
|
|
15
15
|
import { taskLabel } from '../sidebar/model.js';
|
|
16
|
-
import type
|
|
16
|
+
import { contextOf, type SearchContext } from '../../modules/board/task-search.js';
|
|
17
17
|
import type { LocalTask } from '../../types.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -68,6 +68,8 @@ export interface TaskRowProps {
|
|
|
68
68
|
ops?: ReactNode;
|
|
69
69
|
/** 搜索命中上下文(#248:命中行前后各 10 行;搜索未激活或无正文命中时为 null) */
|
|
70
70
|
searchCtx?: SearchContext | null;
|
|
71
|
+
/** 当前搜索串(#192:展开全文时重算命中高亮用;不传则展开纯原文不高亮) */
|
|
72
|
+
searchQuery?: string;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/** 短时间戳:MM-DD HH:MM(放不下原样截 16 字)。 */
|
|
@@ -115,7 +117,10 @@ export default function TaskRow({
|
|
|
115
117
|
history = false,
|
|
116
118
|
ops = null,
|
|
117
119
|
searchCtx = null,
|
|
120
|
+
searchQuery = '',
|
|
118
121
|
}: TaskRowProps) {
|
|
122
|
+
// #192:搜索上下文的「展开全文 / 收起」——纯 UI 态,每行自己持有
|
|
123
|
+
const [ctxExpanded, setCtxExpanded] = useState(false);
|
|
119
124
|
const rowCls =
|
|
120
125
|
'rp-proj-row'
|
|
121
126
|
+ (dragVisual?.dragging ? ' dragging' : '')
|
|
@@ -227,25 +232,49 @@ export default function TaskRow({
|
|
|
227
232
|
) : null}
|
|
228
233
|
</div>
|
|
229
234
|
{searchCtx ? (
|
|
230
|
-
<div
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
e
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
<span
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
235
|
+
<div className="rp-proj-task-ctx">
|
|
236
|
+
{/* #192:上下文头部——左侧说明,右侧「展开全文 / 收起」按钮(点击不开任务) */}
|
|
237
|
+
<div className="ctx-head">
|
|
238
|
+
<span className="ctx-head-label">匹配上下文</span>
|
|
239
|
+
<button
|
|
240
|
+
type="button"
|
|
241
|
+
className={'ctx-expand' + (ctxExpanded ? ' is-open' : '')}
|
|
242
|
+
title={ctxExpanded ? '收起,只看命中附近' : '展开这条任务的完整原文'}
|
|
243
|
+
onClick={(e) => {
|
|
244
|
+
e.stopPropagation();
|
|
245
|
+
setCtxExpanded((v) => !v);
|
|
246
|
+
}}
|
|
247
|
+
onKeyDown={(e) => e.stopPropagation()}
|
|
248
|
+
>
|
|
249
|
+
<Icon name="chevron" size={11} />
|
|
250
|
+
<span>{ctxExpanded ? '收起' : '展开全文'}</span>
|
|
251
|
+
</button>
|
|
252
|
+
</div>
|
|
253
|
+
<div
|
|
254
|
+
className="ctx-lines"
|
|
255
|
+
role="button"
|
|
256
|
+
tabIndex={0}
|
|
257
|
+
title="打开这条任务"
|
|
258
|
+
onClick={() => onOpen?.(t)}
|
|
259
|
+
onKeyDown={(e) => {
|
|
260
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
onOpen?.(t);
|
|
263
|
+
}
|
|
264
|
+
}}
|
|
265
|
+
>
|
|
266
|
+
{(() => {
|
|
267
|
+
const shown = ctxExpanded
|
|
268
|
+
? (contextOf(t, searchQuery, Number.MAX_SAFE_INTEGER) || searchCtx)
|
|
269
|
+
: searchCtx;
|
|
270
|
+
return shown.lines.map((l, i) => (
|
|
271
|
+
<div key={i} className={'ctx-line' + (i === shown.hitIndex ? ' hit' : '')}>
|
|
272
|
+
<span className="ctx-no">{shown.hitLineNo - shown.hitIndex + i}</span>
|
|
273
|
+
<span className="ctx-tx">{l || '\u00a0'}</span>
|
|
274
|
+
</div>
|
|
275
|
+
));
|
|
276
|
+
})()}
|
|
277
|
+
</div>
|
|
249
278
|
</div>
|
|
250
279
|
) : null}
|
|
251
280
|
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// 参数填写页的一次性会话(#151):从「新建任务」下拉点带槽位的模板时建立,
|
|
2
|
+
// 路由只带 sessionId(#/templates/fill/<id>),上下文放这里,避免给 AppRoute 加
|
|
3
|
+
// 一堆一次性的 query 键。会话是内存态——这是中间页,刷新即丢是可接受的。
|
|
4
|
+
export interface FillSession {
|
|
5
|
+
templateId: string;
|
|
6
|
+
/** 可见域三把钥匙(用于主题级模板管理返回等,当前主要供展示) */
|
|
7
|
+
topic?: string;
|
|
8
|
+
group?: string;
|
|
9
|
+
repo?: string;
|
|
10
|
+
/** 新建落点:dirKey 开目录任务页;groupId 开组锚定页 */
|
|
11
|
+
dirKey?: string;
|
|
12
|
+
groupId?: string;
|
|
13
|
+
/** 任务正文 frontmatter 的归属(组任务路由用) */
|
|
14
|
+
board?: string;
|
|
15
|
+
project?: string;
|
|
16
|
+
/** 填完是否直接提交落库(false = 进编辑页保留草稿) */
|
|
17
|
+
submit?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let seq = 0;
|
|
21
|
+
const sessions = new Map<string, FillSession>();
|
|
22
|
+
|
|
23
|
+
export function putFillSession(session: FillSession): string {
|
|
24
|
+
seq += 1;
|
|
25
|
+
const id = `fill_${Date.now().toString(36)}_${seq}`;
|
|
26
|
+
sessions.set(id, { ...session });
|
|
27
|
+
return id;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getFillSession(id: unknown): FillSession | undefined {
|
|
31
|
+
return sessions.get(String(id || ''));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function dropFillSession(id: unknown): void {
|
|
35
|
+
sessions.delete(String(id || ''));
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// 「按模板新建任务」的统一入口(#151):模板正文里有 {{槽位}} 时先去参数填写
|
|
2
|
+
// 中间页,否则直接走原来的纯文本草稿路径。目录页与组页共用这一层,避免两版
|
|
3
|
+
// 下拉又漂移(用户明确要求「以 repo 那个为准」)。
|
|
4
|
+
import { putFillSession, type FillSession } from './fill-session.js';
|
|
5
|
+
import { templateSlots } from '../prompts/template-preview.js';
|
|
6
|
+
|
|
7
|
+
interface NavApp {
|
|
8
|
+
onNavigate?: (hash: string) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** 含有槽位 → 已转向参数页并返回 true;无槽位 → 调用方继续原来的新建路径。 */
|
|
12
|
+
export function startFillIfSlotted(
|
|
13
|
+
tpl: { id?: string; body?: unknown } | null | undefined,
|
|
14
|
+
ctx: Omit<FillSession, 'templateId'>,
|
|
15
|
+
app: NavApp,
|
|
16
|
+
): boolean {
|
|
17
|
+
const slots = templateSlots(tpl?.body);
|
|
18
|
+
if (!slots.length || !tpl?.id) return false;
|
|
19
|
+
const sessionId = putFillSession({ ...ctx, templateId: String(tpl.id) });
|
|
20
|
+
app.onNavigate?.(`#/templates/fill/${sessionId}`);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// 参数填写页 → 任务编辑器的一次性意图(#151)。
|
|
2
|
+
//
|
|
3
|
+
// 「直接提交」按钮需要:参数页渲染出纯文本草稿 → 开任务页 → 任务页自动触发提交
|
|
4
|
+
// 落库为待领取任务。App.openPage 的 config 只认 {dirKey|groupId, task},多带字段
|
|
5
|
+
// 会被丢掉(路由反向映射也只认这套键),所以不往 config 里塞 autoSubmit 标志,
|
|
6
|
+
// 改用一个以 docId 为键的一次性 intent:参数页 set,任务页 mount 时 take(取后即删)。
|
|
7
|
+
// StrictMode 双跑 / 重复挂载都只会消费一次。
|
|
8
|
+
export interface TaskIntent {
|
|
9
|
+
/** 进页后自动触发 submit() 落库为待领取任务 */
|
|
10
|
+
submit?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const pending = new Map<string, TaskIntent>();
|
|
14
|
+
|
|
15
|
+
const keyOf = (id: unknown): string => String(id || '');
|
|
16
|
+
|
|
17
|
+
export function setTaskIntent(id: unknown, intent: TaskIntent): void {
|
|
18
|
+
const k = keyOf(id);
|
|
19
|
+
if (k) pending.set(k, { ...intent });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 取走并清除(同一 docId 只消费一次)。 */
|
|
23
|
+
export function takeTaskIntent(id: unknown): TaskIntent | undefined {
|
|
24
|
+
const k = keyOf(id);
|
|
25
|
+
if (!k) return undefined;
|
|
26
|
+
const v = pending.get(k);
|
|
27
|
+
if (v) pending.delete(k);
|
|
28
|
+
return v;
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// 模板正文渲染(面板侧通用工具):{{槽位名}} → 槽位值(没值就留空)。
|
|
2
|
+
//
|
|
3
|
+
// 从旧 placeholders.ts 收缩而来(v6,方案 §7):占位符目录 / 段落标记 / 参数速查表
|
|
4
|
+
// 这些**手工副本**已删除——变量目录由 prompt.registry 的 fields 派生(声明是 UI
|
|
5
|
+
// 的唯一数据源),本文件只保留与字段目录无关的纯渲染函数。
|
|
6
|
+
/** 渲染模板正文:{{槽位名}} → 槽位值(没值就留空) */
|
|
7
|
+
export function renderTemplateBody(body: unknown, values?: Record<string, unknown> | null): string {
|
|
8
|
+
const vals: Record<string, unknown> = values && typeof values === 'object' ? values : {};
|
|
9
|
+
return String(body ?? '').replace(/\{\{\s*([^}{\s][^{}]*?)\s*\}\}/g, (all, name) => {
|
|
10
|
+
const key = String(name).trim();
|
|
11
|
+
const v = vals[key];
|
|
12
|
+
return v === undefined || v === null ? '' : String(v);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// 任务模板的**预览**渲染(面板侧,纯函数):与真正生成任务用的
|
|
2
|
+
// renderTemplateBody 只差「没值的槽位怎么显示」——
|
|
3
|
+
// 生成任务:没值 → 留空(任务正文里不能出现裸 {{槽位}})
|
|
4
|
+
// 预览: 没值 → 可见占位 〔槽位名〕,用户才知道哪里要填
|
|
5
|
+
//
|
|
6
|
+
// 两套语义分开,是因为它们的消费者不同:前者进交付正文,后者进设置页的预览框。
|
|
7
|
+
// 预览**不写任何存储**、不改变真相——模板正文(templates.json / sqlite)仍是唯一真源。
|
|
8
|
+
import { withFrontmatter } from '../../../../shared/frontmatter.js';
|
|
9
|
+
import { renderTemplateBody } from './render-template-body.js';
|
|
10
|
+
|
|
11
|
+
const SLOT_RE = /\{\{\s*([^}{\s][^{}]*?)\s*\}\}/g;
|
|
12
|
+
|
|
13
|
+
/** 模板正文里声明了哪些槽位(按首次出现顺序去重)。 */
|
|
14
|
+
export function templateSlots(body: unknown): string[] {
|
|
15
|
+
const seen = new Set<string>();
|
|
16
|
+
for (const m of String(body ?? '').matchAll(SLOT_RE)) {
|
|
17
|
+
const key = String(m[1] ?? '').trim();
|
|
18
|
+
if (key) seen.add(key);
|
|
19
|
+
}
|
|
20
|
+
return [...seen];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 预览渲染:{{槽位}} → 槽位值;没有值的槽位显示加粗占位〔槽位名〕。 */
|
|
24
|
+
export function renderTemplatePreview(
|
|
25
|
+
body: unknown,
|
|
26
|
+
values?: Record<string, unknown> | null,
|
|
27
|
+
): string {
|
|
28
|
+
const vals: Record<string, unknown> = values && typeof values === 'object' ? values : {};
|
|
29
|
+
return String(body ?? '').replace(SLOT_RE, (_all, name) => {
|
|
30
|
+
const key = String(name ?? '').trim();
|
|
31
|
+
const v = vals[key];
|
|
32
|
+
const filled = v !== undefined && v !== null && String(v).trim() !== '';
|
|
33
|
+
return filled ? String(v) : `**〔${key}〕**`;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 由模板生成的**任务正文**(#151):槽位按「没值留空」渲染成**纯文本**,
|
|
39
|
+
* 不再把模板身份写进 frontmatter —— 槽位概念的生命周期只到「任务内容生成前」,
|
|
40
|
+
* 下落到文本层(编辑器里的「模板/插槽」只读块)已被移除。
|
|
41
|
+
*
|
|
42
|
+
* 这是「模板 → 任务」的唯一入口(新建任务 / 参数页填写后 / 组页新建都走它):
|
|
43
|
+
* extra 是归属字段(board / project…),不传就是纯正文。
|
|
44
|
+
*
|
|
45
|
+
* 参数页填好的值可经 valuesOverride 传入(覆盖模板自带默认值)。
|
|
46
|
+
*/
|
|
47
|
+
export function templateDraftBody(
|
|
48
|
+
tpl: {
|
|
49
|
+
id?: string;
|
|
50
|
+
body?: unknown;
|
|
51
|
+
values?: Record<string, unknown> | null;
|
|
52
|
+
},
|
|
53
|
+
/** 同时要写的其它归属字段(board / project…) */
|
|
54
|
+
extra: Record<string, unknown> = {},
|
|
55
|
+
/** 参数页填写后的槽位值(覆盖 tpl.values);不传用模板默认值 */
|
|
56
|
+
valuesOverride?: Record<string, unknown> | null,
|
|
57
|
+
): string {
|
|
58
|
+
const values = valuesOverride !== undefined ? valuesOverride : tpl.values;
|
|
59
|
+
const body = renderTemplateBody(tpl.body, values);
|
|
60
|
+
const fields: Record<string, unknown> = { ...extra };
|
|
61
|
+
return Object.keys(fields).length ? withFrontmatter(body, fields) : body;
|
|
62
|
+
}
|
|
@@ -16,6 +16,8 @@ import DagEditor from '../../components/task-panel/dag-editor.jsx';
|
|
|
16
16
|
import { findOpenPanel, openPanel } from '../../workspace.js';
|
|
17
17
|
import { openTemplateEditor } from '../../panels.jsx';
|
|
18
18
|
import { docIdOf, nextDraftId, saveDoc, scopeOf } from '../../modules/md/doc-store.js';
|
|
19
|
+
import { templateDraftBody } from '../../modules/prompts/template-preview.js';
|
|
20
|
+
import { startFillIfSlotted } from '../../modules/md/new-task-from-template.js';
|
|
19
21
|
import { putManageSession } from '../../modules/md/manage-session.js';
|
|
20
22
|
import { useTemplatesFor } from '../../modules/md/use-templates.js';
|
|
21
23
|
import TaskPage from '../../components/task-panel/task-page.jsx';
|
|
@@ -185,14 +187,20 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
|
|
|
185
187
|
? menuTemplates.map((t: PromptTemplate) => ({
|
|
186
188
|
label: (t.id === tpl?.defaultId ? '✓ ' : '') + t.name,
|
|
187
189
|
icon: 'list',
|
|
188
|
-
|
|
190
|
+
// #191:带 {{槽位}} → 先去参数填写页;无槽位 → 纯文本草稿直进编辑器
|
|
191
|
+
onClick: () => {
|
|
192
|
+
if (startFillIfSlotted(t, { topic: topicKeyHere, dirKey: dirKey || '' }, app)) return;
|
|
193
|
+
newDraft(templateDraftBody(t));
|
|
194
|
+
},
|
|
189
195
|
}))
|
|
190
196
|
: [{
|
|
191
197
|
label: '按默认模板新建一页',
|
|
192
198
|
icon: 'list',
|
|
193
199
|
onClick: () => {
|
|
194
200
|
const p = tpl ? tpl.defaultPick() : null;
|
|
195
|
-
|
|
201
|
+
const full = (tpl?.templates || []).find((t) => t.id === (p?.id || tpl?.defaultId));
|
|
202
|
+
if (full && startFillIfSlotted(full as any, { topic: topicKeyHere, dirKey: dirKey || '' }, app)) return;
|
|
203
|
+
newDraft(p && p.id ? templateDraftBody(p) : (p ? p.body : ''));
|
|
196
204
|
},
|
|
197
205
|
}]),
|
|
198
206
|
'sep',
|
|
@@ -258,7 +266,9 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
|
|
|
258
266
|
tplMenuItems={tplMenuItems}
|
|
259
267
|
onNew={() => {
|
|
260
268
|
const p = tpl ? tpl.defaultPick() : null;
|
|
261
|
-
|
|
269
|
+
const full = (tpl?.templates || []).find((t) => t.id === (p?.id || tpl?.defaultId));
|
|
270
|
+
if (full && startFillIfSlotted(full, { topic: topicKeyHere, dirKey: dirKey || '' }, app)) return;
|
|
271
|
+
newDraft(p && p.id ? templateDraftBody(p) : (p ? p.body : ''));
|
|
262
272
|
}}
|
|
263
273
|
onOpenRow={(r) => openTask(r.task.id)}
|
|
264
274
|
onImportFile={(f) => void importMd(f)}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// 旁路(beside)三件套(#259 从任务页主体抽出,行数门禁):打开来源原文 / 关闭自己 /
|
|
2
|
+
// 面包屑「预览原文」。都只是 openBesideMain / deleteTab 的薄封装,状态零自有。
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import type { Model } from 'flexlayout-react';
|
|
5
|
+
import { Actions } from 'flexlayout-react';
|
|
6
|
+
import { openBesideMain } from '../../workspace.js';
|
|
7
|
+
import type { ParentRef } from './task-utils.js';
|
|
8
|
+
|
|
9
|
+
export interface BesideOpsArgs {
|
|
10
|
+
parentRef: ParentRef | null;
|
|
11
|
+
model: Model | null;
|
|
12
|
+
appModel: Model | null;
|
|
13
|
+
toast: (msg: string) => void;
|
|
14
|
+
isDraft: boolean;
|
|
15
|
+
task: string;
|
|
16
|
+
topicKey: string;
|
|
17
|
+
tabId?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function useBesideOps(args: BesideOpsArgs) {
|
|
21
|
+
const { parentRef, model, appModel, toast, isDraft, task, topicKey, tabId } = args;
|
|
22
|
+
|
|
23
|
+
const openParentBeside = useCallback(() => {
|
|
24
|
+
if (!parentRef) {
|
|
25
|
+
toast('这条任务没有可定位的原文');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const m = model || appModel;
|
|
29
|
+
if (!m) return;
|
|
30
|
+
openBesideMain(m, {
|
|
31
|
+
component: 'page',
|
|
32
|
+
name: parentRef.name || `原文 ${parentRef.task}`,
|
|
33
|
+
config: { dirKey: parentRef.dirKey, task: String(parentRef.task) },
|
|
34
|
+
});
|
|
35
|
+
}, [parentRef, model, appModel, toast]);
|
|
36
|
+
|
|
37
|
+
const closeBesideSelf = useCallback(() => {
|
|
38
|
+
const m = model || appModel;
|
|
39
|
+
if (!m || !tabId) return;
|
|
40
|
+
m.doAction(Actions.deleteTab(tabId));
|
|
41
|
+
}, [model, appModel, tabId]);
|
|
42
|
+
|
|
43
|
+
// 面包屑任务段的「预览原文」:评论任务跳它的来源原文;普通任务把自己的原文
|
|
44
|
+
// 旁路打开(openBesideMain 会先收掉旧旁路,同一时刻只有一块)。草稿没有原文。
|
|
45
|
+
const previewOriginal = useCallback(() => {
|
|
46
|
+
if (isDraft) {
|
|
47
|
+
toast('草稿还没有原文');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (parentRef) {
|
|
51
|
+
openParentBeside();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const m = model || appModel;
|
|
55
|
+
if (!m) return;
|
|
56
|
+
openBesideMain(m, {
|
|
57
|
+
component: 'page',
|
|
58
|
+
name: `原文 #${task}`,
|
|
59
|
+
config: { dirKey: topicKey, task: String(task) },
|
|
60
|
+
});
|
|
61
|
+
}, [isDraft, parentRef, openParentBeside, model, appModel, toast, task, topicKey]);
|
|
62
|
+
|
|
63
|
+
return { openParentBeside, closeBesideSelf, previewOriginal };
|
|
64
|
+
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import VscCrumbs from '../../components/layout/vsc-crumbs.jsx';
|
|
10
10
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
11
|
import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
|
|
12
|
-
import { Actions } from 'flexlayout-react';
|
|
13
12
|
import type { Model } from 'flexlayout-react';
|
|
14
13
|
import { getTaskAttachments, previewTask } from './api.js';
|
|
15
14
|
import { useToast } from '../../components/toast/index.jsx';
|
|
@@ -23,7 +22,6 @@ import { openComposer } from '../../components/md/composer/composer-launch.js';
|
|
|
23
22
|
import ShortcutSheet from '../../components/md/shell/shortcut-sheet.jsx';
|
|
24
23
|
import { TaskChainModal as TaskChainModalRaw } from '../../components/md/standalone/task-chain.jsx';
|
|
25
24
|
import { useApp } from '../../app-context.jsx';
|
|
26
|
-
import { openBesideMain } from '../../workspace.js';
|
|
27
25
|
import { persistAtt } from '../../components/md/attachments/attachments.js';
|
|
28
26
|
import type { Attachment } from '../../components/md/attachments/attach-common.js';
|
|
29
27
|
import type { AttachAreaHandle } from '../../components/md/attachments/attach-area.jsx';
|
|
@@ -32,8 +30,9 @@ import {
|
|
|
32
30
|
liveBodyBlocks,
|
|
33
31
|
titleFromMd,
|
|
34
32
|
stripTitleHeading,
|
|
35
|
-
withFrontmatter,
|
|
36
33
|
} from '../../modules/md/md-parse.js';
|
|
34
|
+
import { templateDraftBody } from '../../modules/prompts/template-preview.js';
|
|
35
|
+
import { useAutoSubmit } from './use-auto-submit.js';
|
|
37
36
|
import {
|
|
38
37
|
docIdOf,
|
|
39
38
|
getDoc,
|
|
@@ -51,6 +50,7 @@ import { useAck } from './task-ack.js';
|
|
|
51
50
|
import { useTaskActions } from './task-actions.js';
|
|
52
51
|
import { useFeedback } from './task-feedback.js';
|
|
53
52
|
import { useDerivedCtx } from './task-derived-ctx.js';
|
|
53
|
+
import { useBesideOps } from './task-beside.js';
|
|
54
54
|
import { PreviewModal } from './task-preview-modal.jsx';
|
|
55
55
|
import { DockPanel } from './task-dock-panel.jsx';
|
|
56
56
|
import { StatusBar } from './task-status-bar.jsx';
|
|
@@ -213,7 +213,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
213
213
|
getDoc(id, {
|
|
214
214
|
title: '',
|
|
215
215
|
body: tpl
|
|
216
|
-
?
|
|
216
|
+
? templateDraftBody(tpl.defaultPick(), groupAnchored ? { board: groupId } : {})
|
|
217
217
|
: '',
|
|
218
218
|
});
|
|
219
219
|
} else if (taskRow) getDoc(id, { title: titleFromMd(taskRow.text), body: taskRow.text });
|
|
@@ -229,6 +229,9 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
229
229
|
});
|
|
230
230
|
const { composeText, submit, importMd, delTask, canComplete, canCancel, closeTask, canPlan, togglePlan, addFiles, newTask, cloneCur, forkCur, openProgress, openAttachPanel } = actions;
|
|
231
231
|
|
|
232
|
+
// #191「直接提交」:参数页留下的一次性意图 → doc 就绪后自动 submit(详见 hook)
|
|
233
|
+
useAutoSubmit(id, doc, isDraft, submit);
|
|
234
|
+
|
|
232
235
|
const feedback = useFeedback({
|
|
233
236
|
doc, isDraft, task, taskRow, topicKey, topic, dirKey,
|
|
234
237
|
groupAnchored, groupId, app, model: model || null, tabId, refreshLocal,
|
|
@@ -342,25 +345,10 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
342
345
|
placeSelMenu('task', text, last.right - 60, last.bottom + 8, blockRange ? { blockRange } : {});
|
|
343
346
|
};
|
|
344
347
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
const m = model || app.model;
|
|
351
|
-
if (!m) return;
|
|
352
|
-
openBesideMain(m, {
|
|
353
|
-
component: 'page',
|
|
354
|
-
name: parentRef.name || `原文 ${parentRef.task}`,
|
|
355
|
-
config: { dirKey: parentRef.dirKey, task: String(parentRef.task) },
|
|
356
|
-
});
|
|
357
|
-
}, [parentRef, model, app.model, toast]);
|
|
358
|
-
|
|
359
|
-
const closeBesideSelf = useCallback(() => {
|
|
360
|
-
const m = model || app.model;
|
|
361
|
-
if (!m || !tabId) return;
|
|
362
|
-
m.doAction(Actions.deleteTab(tabId));
|
|
363
|
-
}, [model, app.model, tabId]);
|
|
348
|
+
// 旁路三件套(打开来源原文 / 关闭自己 / 面包屑预览原文)抽到 task-beside.ts(行数门禁)
|
|
349
|
+
const { openParentBeside, closeBesideSelf, previewOriginal } = useBesideOps({
|
|
350
|
+
parentRef, model: model ?? null, appModel: app.model ?? null, toast, isDraft, task, topicKey, tabId,
|
|
351
|
+
});
|
|
364
352
|
|
|
365
353
|
const pickAtt = (accept: string) => {
|
|
366
354
|
if (fileAttRef.current) fileAttRef.current.accept = accept;
|
|
@@ -410,7 +398,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
410
398
|
{/* #254:顶条换 VS Code 式面包屑(命名空间 > 组/目录 > 任务;点段弹同级、
|
|
411
399
|
悬浮出复制钮)。不再显示标题行——原 mdw-path 的两个信号
|
|
412
400
|
(未保存 / 目录已不存在)下沉到这一行保留。 */}
|
|
413
|
-
<VscCrumbs />
|
|
401
|
+
<VscCrumbs onPreview={previewOriginal} />
|
|
414
402
|
{dirty ? <span className="mdw-top-note">未保存</span> : null}
|
|
415
403
|
{topic?.cwdExists === false && (
|
|
416
404
|
<span
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 参数填写页「直接提交」的一次性意图(#151 / #191)。
|
|
2
|
+
//
|
|
3
|
+
// 参数页渲染出纯文本草稿 → 种进 doc-store → 开到任务编辑页 → 留一个一次性 intent;
|
|
4
|
+
// 本 hook 在编辑页 mount 时取走意图,等 doc 就绪后自动 submit 一次(落库为待领取任务)。
|
|
5
|
+
// 取后即删:StrictMode 双跑 / 重复挂载只会消费一次,不会双提交。
|
|
6
|
+
import { useEffect, useRef } from 'react';
|
|
7
|
+
import type { DocState } from './task-utils.js';
|
|
8
|
+
import { takeTaskIntent } from '../../modules/md/task-intent.js';
|
|
9
|
+
|
|
10
|
+
export function useAutoSubmit(id: string, doc: DocState | null, isDraft: boolean, submit: () => unknown): void {
|
|
11
|
+
const autoSubmitRef = useRef(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (takeTaskIntent(id)?.submit) autoSubmitRef.current = true;
|
|
14
|
+
}, [id]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!autoSubmitRef.current || !doc || !isDraft) return;
|
|
17
|
+
autoSubmitRef.current = false;
|
|
18
|
+
submit();
|
|
19
|
+
}, [doc, isDraft, submit]);
|
|
20
|
+
}
|
|
@@ -37,7 +37,9 @@ import { openTemplateEditor } from '../../panels.jsx';
|
|
|
37
37
|
import GetLoopMembersMenu from '../../components/repos/get-loop-members.js';
|
|
38
38
|
import GetLoopModal from '../../components/repos/get-loop-modal.js';
|
|
39
39
|
import { docIdOf, nextDraftId, saveDoc, scopeOf } from '../../modules/md/doc-store.js';
|
|
40
|
-
import { parseFrontmatter
|
|
40
|
+
import { parseFrontmatter } from '../../modules/md/md-parse.js';
|
|
41
|
+
import { templateDraftBody } from '../../modules/prompts/template-preview.js';
|
|
42
|
+
import { startFillIfSlotted } from '../../modules/md/new-task-from-template.js';
|
|
41
43
|
import { sortTasksForDisplay } from '../../modules/board/board-view.js';
|
|
42
44
|
import { putManageSession } from '../../modules/md/manage-session.js';
|
|
43
45
|
import { useTemplates, useTemplatesFor } from '../../modules/md/use-templates.js';
|
|
@@ -238,9 +240,23 @@ export default function GroupView({ dirKey, rows, repoData, model }: {
|
|
|
238
240
|
|
|
239
241
|
// 组里建任务:草稿预写 frontmatter(board + 默认归属项目),提交时编辑页的工具区
|
|
240
242
|
// 可改归属项目(限本组成员),按它路由进对应项目的队列。
|
|
241
|
-
const createTask = (pick?: { id?: string; body?: unknown } | null) => {
|
|
243
|
+
const createTask = (pick?: { id?: string; body?: unknown; values?: Record<string, unknown> | null } | null) => {
|
|
242
244
|
if (!board) return;
|
|
243
245
|
if (!sel) return toast('这个组还没有成员——先「添加成员」,再建任务');
|
|
246
|
+
// #191:带 {{槽位}} 的模板先去参数页(携带组 + 项目上下文);无槽位走原草稿路径。
|
|
247
|
+
const chosen = pick || (tpl?.templates || []).find((t) => t.id === tpl.defaultId) || null;
|
|
248
|
+
if (chosen && startFillIfSlotted(
|
|
249
|
+
chosen as any,
|
|
250
|
+
{
|
|
251
|
+
topic: sel.topicKey || '',
|
|
252
|
+
group: board.key || '',
|
|
253
|
+
repo: sel.key || '',
|
|
254
|
+
groupId: board.id,
|
|
255
|
+
board: board.id,
|
|
256
|
+
project: sel.key,
|
|
257
|
+
},
|
|
258
|
+
app,
|
|
259
|
+
)) return;
|
|
244
260
|
const id = nextDraftId();
|
|
245
261
|
// 草稿 doc 种在**组 scope**:从 #/group/<id>?task=draft-N 打开寻得回同一份(#86)
|
|
246
262
|
const docId = docIdOf(scopeOf(board.id), id);
|
|
@@ -248,7 +264,7 @@ export default function GroupView({ dirKey, rows, repoData, model }: {
|
|
|
248
264
|
const extra = { board: board.id, project: sel.key };
|
|
249
265
|
saveDoc(docId, {
|
|
250
266
|
title: '',
|
|
251
|
-
body:
|
|
267
|
+
body: pick ? templateDraftBody(pick, extra) : templateDraftBody(tpl.defaultPick(), extra),
|
|
252
268
|
});
|
|
253
269
|
app.openPage?.({ groupId: board.id, task: id, name: '新任务' });
|
|
254
270
|
};
|