nx-kv 0.69.0 → 0.69.1
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 +22 -0
- package/package.json +1 -1
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v16-data.ts +0 -1
- package/src/core/db/migrations/v18.sql +24 -0
- package/src/core/db/version.ts +3 -1
- package/src/modules/localtask/actions/localtask-add.ts +4 -4
- package/src/modules/localtask/actions/localtask-boardtasks.ts +1 -1
- package/src/modules/localtask/lifecycle/topics.ts +3 -1
- package/src/web/frontend/api/cli-tree.json +1 -1
- package/src/web/frontend/api/client.generated.ts +1 -1
- package/src/web/frontend/components/md/attachments/attach-modal.tsx +1 -1
- package/src/web/frontend/components/md/hooks/use-live-preview.ts +1 -1
- package/src/web/frontend/components/md/model/divider/index.ts +0 -3
- package/src/web/frontend/components/md/panes/md-panes-helpers.ts +1 -3
- package/src/web/frontend/modules/md/styles/editor.css +0 -26
- package/src/web/public/assets/{composer-launch-BL344XZg.js → composer-launch-C20VCKMu.js} +1 -1
- package/src/web/public/assets/{composer-panel-D0ojgf7z.js → composer-panel-C3ET4SBT.js} +1 -1
- package/src/web/public/assets/{dag-BY0lf-Nl.js → dag-xQRISqLX.js} +1 -1
- package/src/web/public/assets/{dir-BNHyviHQ.js → dir-B-UPu7OY.js} +1 -1
- package/src/web/public/assets/{doc-wmc4swmo.js → doc-zDLeR8PE.js} +1 -1
- package/src/web/public/assets/{group-BSQ9_Gjs.js → group-Hh-NL_sa.js} +1 -1
- package/src/web/public/assets/{index-DHLeXl42.css → index-DXJxcKIU.css} +1 -1
- package/src/web/public/assets/{index-D2P-v30u.js → index-Di6ErKBG.js} +3 -3
- package/src/web/public/assets/{md-history-D0bYVPZY.js → md-history-B7TamGno.js} +1 -3
- package/src/web/public/assets/{refs-Cf4ZbAra.js → refs-C6rZJhnb.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-BahZhXq3.js → repo-form-modal-DpwLdBYp.js} +1 -1
- package/src/web/public/assets/{repos-C2cZtRFo.js → repos-BjVw1SQ2.js} +1 -1
- package/src/web/public/assets/{settings-C_VmzG7F.js → settings-C1NfJqNk.js} +1 -1
- package/src/web/public/assets/{task-C4Sqe4vT.js → task-Ddr-iU14.js} +1 -1
- package/src/web/public/assets/{task-ops-SFagO-OC.js → task-ops-s9kkuLcK.js} +1 -1
- package/src/web/public/assets/{templates-B8jnGSAl.js → templates-BnEJVU91.js} +3 -3
- package/src/web/public/assets/{use-rail-drag-CtZxisjE.js → use-rail-drag-4iK6t5ab.js} +1 -1
- package/src/web/public/index.html +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
本文件对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.69.1] - 2026-11-25 frontmatter 残留清零 + v18 幽灵队列修复
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **frontmatter 残留彻底清零**:契约文案(localtask add 的 summary/describe 还在教
|
|
10
|
+
「正文 frontmatter」)、编辑器 blockKind 的 fm 分支与 .mdw-fm/.kind-fm 死样式、
|
|
11
|
+
board-target 的 fields 死代码全部移除——frontmatter 一词只剩迁移内联、SKILL 解析
|
|
12
|
+
与「已删除」说明注释。
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **v18 迁移:恢复「带待领任务的软删队列」**(幽灵队列)——存量数据里 pending 任务
|
|
17
|
+
挂在软删队列上,任何 cwd 都领不到(生产库 4 条)。v18 恢复这类队列(不删任务);
|
|
18
|
+
只挂 done 的软删队列与组队列不恢复。
|
|
19
|
+
- prune 的旧模型分支(无 cwd 主题)补 pending 守卫——此前带活任务也会被清成幽灵。
|
|
20
|
+
|
|
21
|
+
### Verification
|
|
22
|
+
|
|
23
|
+
- 全量单测 1171/1171(新增 v18 迁移测试:pending 恢复 / done 不动 / 组队列不恢复);
|
|
24
|
+
lint / typecheck / build 全绿;生产库 v17→v18 真升级成功(幽灵队列 4→0,
|
|
25
|
+
pending 27→31——4 条幽灵任务重新可见可领)。
|
|
26
|
+
|
|
5
27
|
## [0.69.0] - 2026-11-25 任务归属落库(schema v16/v17)+ frontmatter 彻底删除 + 队列自动持有
|
|
6
28
|
|
|
7
29
|
本轮主线:**任务归属从正文 frontmatter 搬进库内关联**(用户验收 #197 的彻底化),
|
package/package.json
CHANGED
|
@@ -70,6 +70,7 @@ export const DIRECT_EDGES: MigrationStep[] = [
|
|
|
70
70
|
{ from: 14, to: 15, file: 'v15.sql', title: "附件新增 repo 类型(参考仓库指针,不复制字节;重建 attachments 扩 CHECK)" },
|
|
71
71
|
{ from: 15, to: 16, file: 'v16.sql', title: '任务归属落库第一步(tasks.repo_key + topics.group_key,删 frontmatter #197)', apply: migrateAssignmentsToColumns },
|
|
72
72
|
{ from: 16, to: 17, file: 'v17.sql', title: '任务归属规范成两条 topic 关联(repo_topic_id + group_topic_id #197)', apply: migrateTopicLinks },
|
|
73
|
+
{ from: 17, to: 18, file: 'v18.sql', title: '恢复带待领任务的软删队列(幽灵队列修复 #200)' },
|
|
73
74
|
];
|
|
74
75
|
|
|
75
76
|
// 人读版本说明(docs/decisions 是决策的唯一权威位置,里面对应一份 date 化的 .md)
|
|
@@ -91,6 +92,7 @@ export const VERSION_NOTES = {
|
|
|
91
92
|
15: 'docs/decisions/versions/2026-11-23-v15.md',
|
|
92
93
|
16: 'docs/decisions/versions/2026-11-24-v16.md',
|
|
93
94
|
17: 'docs/decisions/versions/2026-11-24-v17.md',
|
|
95
|
+
18: 'docs/decisions/versions/2026-11-25-v18.md',
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
const keyOf = (from: number, to: number): string => `${from}->${to}`;
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
// 本步骤已在 2026-11-24 应用到本机库(user_version=16),**逻辑不可再改**;
|
|
11
11
|
// 更彻底的归属规范(repo_topic_id / group_topic_id 两条关联)在 v17 做。
|
|
12
12
|
import { matchRepoKey, autoRepoKey } from '../repo-match.js';
|
|
13
|
-
// frontmatter 读/剥收拢到 core/task-frontmatter(#200);core 不能依赖 shared,同名别名承接
|
|
14
13
|
// ── 一次性迁移用的最小 frontmatter 读/剥(#197 起任务正文不再有 --- 头)──
|
|
15
14
|
// 这段逻辑**冻结在本文件**:迁移/导入是处理历史数据的唯一入口,跑完即退役;
|
|
16
15
|
// 运行时(服务层/前端)已无任何 frontmatter 读/剥(shared/frontmatter.ts 已删除)。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- v18(#200 续):修复「活任务挂在软删队列上」的存量幽灵队列。
|
|
2
|
+
--
|
|
3
|
+
-- 背景:历史版本里 prune(旧模型分支)/ 直接删除曾把带待领任务的队列软删
|
|
4
|
+
-- (tasks 保留),任务变成「任何 cwd 都领不到」的幽灵。#197 起队列必须绑
|
|
5
|
+
-- 真实仓库、任务必须可寻址——这类存量与口径冲突。
|
|
6
|
+
--
|
|
7
|
+
-- 处理口径:**恢复队列,不删任务**(数据最安全——任务内容自包含,目录虽然
|
|
8
|
+
-- 可能已不存在,agent 仍可按 cwd 显式领取;UI 的 cwdExists=false 幽灵标志
|
|
9
|
+
-- 本来就有,用户可以自行决定清掉或留着)。
|
|
10
|
+
-- · 待领(status='pending')→ 必须恢复:这是没跑完的活。
|
|
11
|
+
-- · done / cancelled → 不动:已完成的任务挂在死队列里只是历史记录,恢复
|
|
12
|
+
-- 反而让幽灵队列重新出现在侧栏。
|
|
13
|
+
-- @decision docs/decisions/versions/2026-11-25-v18.md
|
|
14
|
+
UPDATE topics
|
|
15
|
+
SET deleted_at = NULL,
|
|
16
|
+
updated_at = CAST(strftime('%s','now') AS INTEGER) * 1000
|
|
17
|
+
WHERE deleted_at IS NOT NULL
|
|
18
|
+
AND cwd <> '' -- 组队列(cwd 空)不恢复:组任务走 group_topic_id 关联寻址,不依赖目录队列可见性
|
|
19
|
+
AND EXISTS (
|
|
20
|
+
SELECT 1 FROM tasks
|
|
21
|
+
WHERE tasks.repo_topic_id = topics.id
|
|
22
|
+
AND tasks.deleted_at IS NULL
|
|
23
|
+
AND tasks.status = 'pending'
|
|
24
|
+
);
|
package/src/core/db/version.ts
CHANGED
|
@@ -47,7 +47,9 @@
|
|
|
47
47
|
// topics.group_key 启用(组任务拆 (cwd, group_key) 独立队列),删哨兵仓库 #197。
|
|
48
48
|
// v17(2026-11-24):归属规范成两条 topic 关联——tasks.repo_topic_id(必填,编号/领取按它)
|
|
49
49
|
// + tasks.group_topic_id(可空,组归属);丢弃 repo_key,组队列换成 group:<组key> 形态 #197。
|
|
50
|
-
|
|
50
|
+
// v18(2026-11-25):恢复带待领任务的软删队列(幽灵队列——活任务挂软删队列任何 cwd
|
|
51
|
+
// 都领不到);prune 的旧模型分支同步补 pending 守卫 #200。
|
|
52
|
+
export const CURRENT_SCHEMA_VERSION = 18;
|
|
51
53
|
|
|
52
54
|
/**
|
|
53
55
|
* 运行时最低 Node 版本。
|
|
@@ -42,8 +42,8 @@ const input = z.object({
|
|
|
42
42
|
file: z.string().optional().describe("从本机文件读任务正文(- 表示标准输入)——长文本/多行不必靠引号硬拼"),
|
|
43
43
|
cwd: z.string().optional().describe("工作目录(作为主题;默认当前目录)。归属由 --project 决定:给了 --project 就用它推导落点,这里再给且不一致会报错"),
|
|
44
44
|
summary: z.string().optional().describe("顺带刷新该主题的当前现状(可选)"),
|
|
45
|
-
board: z.string().optional().describe("工作组(看板)id / key /
|
|
46
|
-
project: z.string().optional().describe("归属项目(仓库 key / 名称 /
|
|
45
|
+
board: z.string().optional().describe("工作组(看板)id / key / 名称:给任务建立组队列关联(#197 起是库内 topics.group_topic_id,不再写正文),该任务才会出现在组面板里;必须同时给 --project 指明归属项目"),
|
|
46
|
+
project: z.string().optional().describe("归属项目(仓库 key / 名称 / 路径):任务挂在哪个项目上,落点目录由它推导,归属仓库落库(tasks.repo_topic_id 关联);配 --board 时必须是该组成员"),
|
|
47
47
|
duration: z.string().optional().describe("时间目标时长(2h / 90m / 5小时):领取即计时,未到点不许标完成"),
|
|
48
48
|
'goal-prompt': z.string().optional().describe("时间目标的附加要求(随 check 指令一起固化,可省)"),
|
|
49
49
|
goalPrompt: z.string().optional().describe("同 --goal-prompt(驼峰写法)"),
|
|
@@ -61,7 +61,7 @@ export class LocaltaskAddAction extends ActionBase<typeof input> {
|
|
|
61
61
|
id: 'localtask.add',
|
|
62
62
|
cli: ['localtask', 'add'],
|
|
63
63
|
http: ['POST', '/api/localtasks'],
|
|
64
|
-
summary: '
|
|
64
|
+
summary: '向某主题(工作目录)的队列回填一条任务(正文可多行 markdown;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务落库归属(组队列 + 仓库队列两条 topic 关联,正文不写任何头),并落进该项目的队列',
|
|
65
65
|
args: ['text'],
|
|
66
66
|
input,
|
|
67
67
|
output: addView,
|
|
@@ -76,7 +76,7 @@ export class LocaltaskAddAction extends ActionBase<typeof input> {
|
|
|
76
76
|
if (!body.trim()) throw badInput('任务正文为空:给 "<正文>" 或 --file <文件>');
|
|
77
77
|
|
|
78
78
|
// 派任务编排已迁 localtask/add.ts(派任务编排归 localtask 域;命令名不变)。
|
|
79
|
-
// 落点判定(--board/--project
|
|
79
|
+
// 落点判定(--board/--project 严格口径)只此一份实现,
|
|
80
80
|
// CLI、HTTP、面板提交同走这一条链路。
|
|
81
81
|
const { submitTask } = await (import('../lifecycle/add.js') as any);
|
|
82
82
|
const rawBlock: any = ctx.blockBy ?? ctx['block-by'];
|
|
@@ -49,7 +49,7 @@ const taskRow = z.object({
|
|
|
49
49
|
const output = z.object({
|
|
50
50
|
boards: z.array(
|
|
51
51
|
z.object({
|
|
52
|
-
id: z.string().describe('看板 id
|
|
52
|
+
id: z.string().describe('看板 id(组队列 topic 的 group_key,组页建任务时落库关联的就是它)'),
|
|
53
53
|
key: z.string().describe('看板键(board/xxx)'),
|
|
54
54
|
name: z.string().describe('看板名称'),
|
|
55
55
|
pending: z.int().describe('本组待领取数(= side bar 徽标口径)'),
|
|
@@ -106,7 +106,9 @@ export async function pruneTopics({
|
|
|
106
106
|
if (!deleteGuard(t, { force: false, key: t.key, scope: 'prune' }).ok) continue;
|
|
107
107
|
const tasks = t.tasks;
|
|
108
108
|
const hasPending = tasks.some(isPending);
|
|
109
|
-
|
|
109
|
+
// #200:旧模型无目录分支同样不许带活任务——带 pending 的队列清了就是幽灵
|
|
110
|
+
//(活任务挂软删队列,任何 cwd 都领不到)。存量由 v18 迁移恢复。
|
|
111
|
+
const isLegacy = !t.cwd && !hasPending;
|
|
110
112
|
const isEmpty = tasks.length === 0;
|
|
111
113
|
const isFinished = allFinished && tasks.length > 0 && !hasPending;
|
|
112
114
|
const cwdGone = missingDir && !!t.cwd && !hasPending && !existsSync(String(t.cwd));
|
|
@@ -1163,7 +1163,7 @@
|
|
|
1163
1163
|
"action": {
|
|
1164
1164
|
"id": "localtask.add",
|
|
1165
1165
|
"module": "localtask",
|
|
1166
|
-
"summary": "
|
|
1166
|
+
"summary": "向某主题(工作目录)的队列回填一条任务(正文可多行 markdown;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务落库归属(组队列 + 仓库队列两条 topic 关联,正文不写任何头),并落进该项目的队列",
|
|
1167
1167
|
"usage": "localtask add",
|
|
1168
1168
|
"http": "POST /api/localtasks"
|
|
1169
1169
|
},
|
|
@@ -297,7 +297,7 @@ export interface ApiClient {
|
|
|
297
297
|
docRemove(input: z.input<InstanceType<typeof RepoDocRemoveAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoDocRemoveAction>['run']>>>;
|
|
298
298
|
/** 取仓库完整知识:项目介绍 + 所属组(介绍/组内描述/绑定文档)+ 参考仓库(--md 拼成单篇 markdown;缺省当前目录) */
|
|
299
299
|
knowledge(input?: z.input<InstanceType<typeof RepoKnowledgeAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof RepoKnowledgeAction>['run']>>>;
|
|
300
|
-
/**
|
|
300
|
+
/** 向某主题(工作目录)的队列回填一条任务(正文可多行 markdown;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务落库归属(组队列 + 仓库队列两条 topic 关联,正文不写任何头),并落进该项目的队列 */
|
|
301
301
|
localtaskAdd(input?: z.input<InstanceType<typeof LocaltaskAddAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAddAction>['run']>>>;
|
|
302
302
|
/** 改一条附件绑定的说明(desc):--attachment <资源 id> --note <说明>(只动说明,角色/位置不变) */
|
|
303
303
|
attachNote(input: z.input<InstanceType<typeof LocaltaskAttachNoteAction>['_input']>): Promise<Awaited<ReturnType<InstanceType<typeof LocaltaskAttachNoteAction>['run']>>>;
|
|
@@ -337,7 +337,7 @@ export default function AttachModal({
|
|
|
337
337
|
|
|
338
338
|
const taskList = useMemo(() => {
|
|
339
339
|
// #183:任务搜索与 topic 页共用 modules/board/task-search.ts 的同一份引擎
|
|
340
|
-
// (空格分词 AND /
|
|
340
|
+
// (空格分词 AND / 通配 / 编号前缀),弹窗不再自己写 includes。
|
|
341
341
|
const pool = taskOptions.filter((t) => String(t.id) !== String(hostId));
|
|
342
342
|
return filterTasks(pool, taskSearch).slice(0, 12);
|
|
343
343
|
}, [taskOptions, taskSearch, hostId]);
|
|
@@ -225,7 +225,7 @@ export function useLivePreview({
|
|
|
225
225
|
const ingestFiles = (files: File[] | null | undefined, ta: HTMLTextAreaElement | null) => {
|
|
226
226
|
if (!files?.length || !onFiles) return;
|
|
227
227
|
// 实时预览的光标是**块内**偏移,绝不能当全文 insertAt——否则会插进
|
|
228
|
-
//
|
|
228
|
+
// 附件片段插进正文头部区会落在段落缝隙里(任务 #15 验收根因)。
|
|
229
229
|
onFiles(files, {
|
|
230
230
|
mode: 'live',
|
|
231
231
|
focusIndex: focus,
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
// 分隔线语法:独占一行的 3 个以上 `-` / `*` / `_`(可夹空格)→ `<hr>`。
|
|
2
|
-
//
|
|
3
|
-
// 不匹配 `- ` 列表(需要三个以上且整行只有分隔符)。frontmatter 在渲染前已被
|
|
4
|
-
// stripFrontmatter 剥掉,正文里的 `---` 一律按 thematic break 处理。
|
|
5
2
|
import type { BlockMatch, BlockRule } from '../types.js';
|
|
6
3
|
|
|
7
4
|
export const dividerSyntax: BlockRule = {
|
|
@@ -99,11 +99,9 @@ export function blockHtml(text: string, attachments?: Attachment[] | null) {
|
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
/** 块类型 →
|
|
102
|
+
/** 块类型 → 编辑态字号贴近渲染(避免「输入框感」)。#197 FM 块已不存在,fm 分支删除。 */
|
|
103
103
|
export function blockKind(text: string) {
|
|
104
104
|
const t = String(text || '');
|
|
105
|
-
// frontmatter 块:预览态渲染成属性卡(renderMarkdownHtml),编辑态等宽小字
|
|
106
|
-
if (/^---\s*$/.test(t.split('\n', 1)[0] || '') && t.includes('\n')) return 'fm';
|
|
107
105
|
// 数学公式块($$ 起头):编辑态用衬线/等宽近似公式观感
|
|
108
106
|
if (/^\s*\$\$/.test(t)) return 'math';
|
|
109
107
|
// 表格块:首行含管道且第二行是分隔行
|
|
@@ -187,32 +187,6 @@
|
|
|
187
187
|
border-left:2px solid var(--line,#E4E2DC)!important;
|
|
188
188
|
color:var(--ink-2,#4B515A);
|
|
189
189
|
}
|
|
190
|
-
/* frontmatter 块的编辑态:等宽小字,盒型对齐属性卡(视图↔编辑只有内容差,
|
|
191
|
-
卡片是 3 行键值、源码是 4 行 yaml——这一类天生差一行,其余各类严格等高) */
|
|
192
|
-
.mdw-lp-block.kind-fm textarea.mdw-lp-src{
|
|
193
|
-
font-family:ui-monospace,Consolas,monospace;font-size:11.5px;line-height:1.6;
|
|
194
|
-
padding:9px 12px!important;
|
|
195
|
-
border:1px solid var(--line,#E4E2DC)!important;border-radius:8px;
|
|
196
|
-
background:var(--canvas,#F5F4F1)!important;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/* frontmatter 属性卡:任务头部的结构化字段(board/project/介绍引用)单独成卡,
|
|
200
|
-
不与首行内容混排。live 预览块与阅读视图同一份渲染(md-parse frontmatterHtml)。 */
|
|
201
|
-
.mdw-fm{
|
|
202
|
-
display:flex;flex-direction:column;gap:3px;
|
|
203
|
-
margin:0 0 10px;padding:9px 12px;
|
|
204
|
-
background:var(--canvas,#F5F4F1);
|
|
205
|
-
border:1px solid var(--line,#E4E2DC);
|
|
206
|
-
border-radius:8px;
|
|
207
|
-
font-family:ui-monospace,Consolas,monospace;
|
|
208
|
-
font-size:11.5px;line-height:1.6;
|
|
209
|
-
}
|
|
210
|
-
.mdw-fm-row{display:flex;gap:8px;align-items:baseline;min-width:0}
|
|
211
|
-
.mdw-fm-k{flex:none;color:var(--mid,#838A93)}
|
|
212
|
-
.mdw-fm-k::after{content:':'}
|
|
213
|
-
.mdw-fm-v{min-width:0;overflow-wrap:anywhere;color:var(--ink-2,#4B515A)}
|
|
214
|
-
/* 阅读视图与模板预览同款(.mdw-preview 是阅读态容器) */
|
|
215
|
-
.mdw-preview .mdw-fm{margin-top:2px}
|
|
216
190
|
.mdw-lp-view{user-select:text;overflow-wrap:anywhere;word-break:break-word}
|
|
217
191
|
/* live 预览:块内元素的 margin 归零——间距统一由块容器承担(与编辑态 textarea
|
|
218
192
|
的零垂直 padding 对称),否则视图态(元素 margin)与编辑态(textarea padding)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t}from"./popup-DLfU1TXG.js";import{_ as n,f as r}from"./tool-bar-NHeX0Kmo.js";import{y as i}from"./md-history-
|
|
1
|
+
import{a as e,d as t}from"./popup-DLfU1TXG.js";import{_ as n,f as r}from"./tool-bar-NHeX0Kmo.js";import{y as i}from"./md-history-B7TamGno.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-DLfU1TXG.js";import{u as a}from"./tool-bar-NHeX0Kmo.js";import{n as o}from"./app-context-DPFYOrgE.js";import"./md-parse-BjzYV8n7.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./md-history-
|
|
1
|
+
import{a as e,d as t,f as n,h as r,l as i}from"./popup-DLfU1TXG.js";import{u as a}from"./tool-bar-NHeX0Kmo.js";import{n as o}from"./app-context-DPFYOrgE.js";import"./md-parse-BjzYV8n7.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./md-history-B7TamGno.js";import"./index-Di6ErKBG.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-C20VCKMu.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`)=>{l(N.current,P,{title:``,body:T},t),E(e)},L=()=>{let e=c(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=>u(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)(s,{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,n as o,u as s}from"./popup-DLfU1TXG.js";import{n as c}from"./app-context-DPFYOrgE.js";import{r as l}from"./md-parse-BjzYV8n7.js";import{n as u}from"./board-view-jt8QixVg.js";import{w as d}from"./index-D2P-v30u.js";import{t as f}from"./graph-BTEfvFz6.js";var p=r(n(),1);function m(e){return!(!e||e.deletedAt||e.migratedTo)}function h(e){return m(e)&&e?.status===`pending`}function g(e){return l(e.text)||d(e)||`#${e.id}`}function _(e,t){return`${e}:${Number(t)}`}function v(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return{kind:`local`,id:Math.trunc(e)};let t=String(e??``).trim();if(!t)return null;let n=/^([A-Za-z0-9_-]+):(\d+)$/.exec(t),r=n?.[1],i=n?.[2];if(r&&i)return{kind:`foreign`,key:r,id:Number(i)};if(/^\d+$/.test(t)){let e=Number(t);if(e>0)return{kind:`local`,id:e}}return null}function y(e,t){let n=v(e);return n?n.kind===`foreign`?_(n.key,n.id):_(t,n.id):null}function ee(e,t){return e.topicKey===t?Number(e.id):_(e.topicKey,e.id)}function te(e){return s(`/api/localtasks/item`,{method:`PATCH`,body:e})}function b(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e){let e=r.get(t.topicKey);e?e.push(t):r.set(t.topicKey,[t])}let i=new Map,a=0;for(let[,e]of r)e.forEach((e,t)=>{let r=a+Math.floor(t/n),o=t%n;i.set(e.nodeKey,{x:56+r*320,y:28+o*94})}),a+=Math.ceil(e.length/n);return i}var x=e=>`nx-kv-dag-pos:${e}`;function ne(e){try{let t=JSON.parse(localStorage.getItem(x(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))if(Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])){let t=Number(r[0]),i=Number(r[1]);n.set(e,{x:t,y:i})}return n}catch{return new Map}}function re(e){try{localStorage.removeItem(x(e))}catch{}}function S(e,t){try{let n={};for(let[e,r]of t)r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&(n[e]=[Math.round(r.x),Math.round(r.y)]);return localStorage.setItem(x(e),JSON.stringify(n)),!0}catch{return!1}}function ie(e,t,n,r){let i=Math.max(48,Math.abs(n-e)*.5);return`M ${e} ${t} C ${e+i} ${t}, ${n-i} ${r}, ${n} ${r}`}function C(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function ae(e,t,n,r){let i=t.get(n)||{x:0,y:0};return{x:i.x+280,y:i.y+r(n)/2}}function oe(e,t,n,r){let i=[];for(let a of e){let e=t.get(a.nodeKey);if(!e)continue;let o=r(a.nodeKey);for(let s of a.blockBy||[]){let c=y(s,a.topicKey);if(!c||!n.has(c))continue;let l=t.get(c);if(!l)continue;let u=r(c),d=e.x>l.x+280-8;i.push({from:c,to:a.nodeKey,x1:d?l.x+280:l.x,y1:l.y+u/2,x2:d?e.x:e.x+280,y2:e.y+o/2})}}return i}function se({canvasRef:e,modeRef:t,posRef:n,nodesRef:r,byNodeKeyRef:i,scopeKeyRef:a,userMovedRef:o,commitRef:s,toastRef:c,setPos:l,setDragId:u,setLinking:d}){let f=(t,i)=>{let a=e.current;if(!a)return null;let{x:o,y:s}=C(a,t,i),c=r.current;for(let e=c.length-1;e>=0;e--){let t=c[e];if(!t)continue;let r=t.nodeKey,i=n.current.get(r);if(!i)continue;let l=a.querySelector(`[data-node-id="${CSS.escape(r)}"]`),u=l instanceof HTMLElement?l.offsetHeight:64;if(o>=i.x-10&&o<=i.x+280+28&&s>=i.y-6&&s<=i.y+u+6)return r}return null},m=e=>{if(!e||e.kind!==`link`){d(null);return}d({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},h=()=>{t.current=null,u(null),d(null)};return(0,p.useEffect)(()=>{let r=n=>{let r=t.current;if(!r)return;let i=e.current;if(!i)return;let a=C(i,n.clientX,n.clientY);if(r.kind===`drag`){let e=Math.max(8,a.x-r.ox),t=Math.max(8,a.y-r.oy);l(n=>{let i=new Map(n);return i.set(r.id,{x:e,y:t}),i});return}if(r.kind===`link`){let e=f(n.clientX,n.clientY),i=e&&e!==r.sourceId?e:null,o=Math.hypot(a.x-r.sx,a.y-r.sy),s=r.dragged||o>=6,c={...r,cx:a.x,cy:a.y,overId:i,dragged:s};t.current=c,m(c)}},u=async e=>{let r=t.current;if(r){if(r.kind===`drag`){o.current.add(r.id),S(a.current,n.current),h();return}if(r.kind===`link`){let t=r.overId||f(e.clientX,e.clientY),n=r.sourceId;if(t&&t!==n){h(),await s.current(n,t);return}if(r.dragged){h();return}let a=i.current.get(n);c.current(`已选 #${a?.id??n},再点目标画出有向边`)}}},d=e=>{e.key===`Escape`&&h()};return window.addEventListener(`pointermove`,r),window.addEventListener(`mousemove`,r),window.addEventListener(`pointerup`,u),window.addEventListener(`mouseup`,u),window.addEventListener(`pointercancel`,h),window.addEventListener(`keydown`,d),()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`mousemove`,r),window.removeEventListener(`pointerup`,u),window.removeEventListener(`mouseup`,u),window.removeEventListener(`pointercancel`,h),window.removeEventListener(`keydown`,d)}},[]),{publishLink:m,clearMode:h}}var w=t();function ce({title:e,count:t,linkArmed:n,srcLabel:r,groupMode:i,queues:a,filterKey:o,onFilter:s,onReset:c}){return(0,w.jsxs)(`div`,{className:`dagp-head`,children:[(0,w.jsx)(`span`,{className:`dagp-title`,children:e}),(0,w.jsxs)(`span`,{className:`dagp-count`,children:[t,` 个待领取节点`]}),(0,w.jsx)(`span`,{className:`dagp-hint`,children:n?`连线中:再点目标完成 #${r} → 目标(Esc 取消)`:i?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),i&&a.length>0&&(0,w.jsxs)(`span`,{className:`dagp-queues`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(o===``?` on`:``),onClick:()=>s(``),children:[`全部`,(0,w.jsx)(`i`,{children:a.reduce((e,t)=>e+t.total,0)})]}),a.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===o?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>s(e.key),children:[e.name,(0,w.jsx)(`i`,{children:e.count})]},e.key))]}),(0,w.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:c,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]})}function le({n:t,p:n,byNodeKey:r,groupMode:i,dragId:a,linking:o,linkArmed:s,onStartDrag:c,onStartLink:l,onOpenTask:u,onToggleGate:d,onAddTimegoal:f,onRemoveDep:p,onOpsMenu:m}){let h=(t.blockBy||[]).map(e=>({token:e,key:y(e,t.topicKey)})).filter(e=>e.key&&r.has(e.key)),_=o&&o.overId===t.nodeKey,v=o&&o.sourceId===t.nodeKey;return(0,w.jsxs)(`div`,{"data-node-id":t.nodeKey,className:`dagp-node`+(a===t.nodeKey?` dragging`:``)+(_?` over`:``)+(v?` linking-src`:``)+(t.blocksFollowing?` gate`:``)+(s&&!v?` link-target`:``),style:{transform:`translate(${n.x}px, ${n.y}px)`,width:280},onPointerDown:e=>c(e,t),children:[(0,w.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,w.jsxs)(`div`,{className:`dagp-body`,children:[(0,w.jsxs)(`div`,{className:`dagp-top`,children:[(0,w.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,t.id]}),i&&(0,w.jsx)(`span`,{className:`dagp-chip proj`,children:t.projectName}),t.blocksFollowing&&(0,w.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),t.ready===!1&&(0,w.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),t.timegoal?.duration&&(0,w.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,t.timegoal.duration]}),(0,w.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:e=>{e.stopPropagation();let n=[{label:`打开任务`,onClick:()=>u(t)},{label:t.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>d(t)},{label:t.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>f(t)}],r=e.currentTarget.getBoundingClientRect();m({x:r.left,y:r.bottom,items:n})},children:(0,w.jsx)(e,{name:`dots`,size:13,title:void 0})})]}),(0,w.jsx)(`div`,{className:`dagp-name`,title:t.text,onDoubleClick:e=>{e.stopPropagation(),u(t)},children:g(t)}),h.length>0&&(0,w.jsx)(`div`,{className:`dagp-deps`,children:h.map(({token:e,key:n})=>{let i=n?r.get(n):void 0,a=!!i&&i.topicKey!==t.topicKey;return(0,w.jsxs)(`span`,{className:`dagp-chip dep`,title:a&&i?`跨项目 #${i.id}@${i.projectName} → #${t.id}`:`#${i?.id} → #${t.id}`,children:[`← #`,i?.id,a?`@${i.projectName}`:``,(0,w.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),p(t,e)},children:`×`})]},String(e))})})]}),(0,w.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${t.id} 开始连线`,onPointerDown:e=>l(e,t)})]})}function T({dirKey:e,groupId:t}){let n=c(),r=a(),{dialog:s,node:l}=i(),d=n.rows||[],m=n.refreshLocal,g=(0,p.useId)().replace(/:/g,``),x=n.repoData&&n.repoData.boards||[],S=(0,p.useMemo)(()=>x.find(e=>e.id===t||e.key===t)||null,[x,t]),T=!!S,ue=(0,p.useMemo)(()=>{if(!S)return[];let e=[];for(let t of S.repos||[]){let n=d.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[S.id,S.key,S.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!h(e))return!1;let t=String(e.boardMark||e.boardKey||``);return t&&r.includes(t)});i.length&&e.push({key:n.key,name:t.name||t.key,cwd:n.cwd,count:i.length,total:i.length})}return e},[S,d]),[E,de]=(0,p.useState)(``);(0,p.useEffect)(()=>{T||de(``)},[T,t]);let D=(0,p.useMemo)(()=>T?null:d.find(t=>t.key===e)||null,[T,d,e]),O=(0,p.useMemo)(()=>{if(T&&S){let e=[S.id,S.key,S.name].filter(Boolean),t=[];for(let n of S.repos||[]){let r=d.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(E&&r.key!==E))for(let i of r.tasks||[]){if(!h(i))continue;let a=String(i.boardMark||i.boardKey||``);a&&e.includes(a)&&t.push({...i,topicKey:r.key,topicCwd:r.cwd,projectName:n.name||n.key,nodeKey:_(r.key,i.id)})}}return t}return D?(D.tasks||[]).filter(e=>h(e)&&!u(e)).map(e=>({...e,topicKey:D.key,topicCwd:D.cwd,projectName:D.name||D.key,nodeKey:_(D.key,e.id)})):[]},[T,S,d,E,D]),k=(0,p.useMemo)(()=>new Map(O.map(e=>[e.nodeKey,e])),[O]),A=(0,p.useRef)(k);A.current=k;let j=(0,p.useRef)(O);j.current=O;let M=(0,p.useRef)(null),[N,P]=(0,p.useState)(()=>new Map),F=(0,p.useRef)(N);F.current=N;let[fe,pe]=(0,p.useState)(0);(0,p.useEffect)(()=>{let e=M.current;if(!e)return;let t=()=>pe(e.clientHeight||0);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]);let I=Math.max(3,Math.floor(((fe||720)-56)/94)||8),L=T?`g:${S?.id||t||``}`:`d:${e||``}`,R=(0,p.useRef)(L);R.current=L;let z=(0,p.useMemo)(()=>ne(L),[L]),B=(0,p.useRef)(L),V=(0,p.useRef)(new Set);(0,p.useEffect)(()=>{let e=B.current!==L;B.current=L,P(t=>{let n=new Map,r=b(O,{perCol:I});for(let i of O){let a=z.get(i.nodeKey)||(!e&&V.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:56,y:28};n.set(i.nodeKey,a)}return n})},[O,I,z,L]);let H=(0,p.useRef)(null),[U,W]=(0,p.useState)(null),[G,me]=(0,p.useState)(null),[K,he]=(0,p.useState)(null),[ge,_e]=(0,p.useState)(!1),q=(0,p.useRef)(!1);q.current=ge;let J=(0,p.useRef)(async()=>!1),Y=(0,p.useRef)(r);Y.current=r;let X=async(e,t,n)=>{_e(!0);try{let i={...t};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`)),await te({cwd:e.topicCwd,id:Number(e.id),...i}),n&&r(n),m&&await m()}catch(e){r(String(e.message||e))}finally{_e(!1)}},{publishLink:ve,clearMode:Z}=se({canvasRef:M,modeRef:H,posRef:F,nodesRef:j,byNodeKeyRef:A,scopeKeyRef:R,userMovedRef:V,commitRef:J,toastRef:Y,setPos:P,setDragId:W,setLinking:me});J.current=async(e,t)=>{if(!t||t===e)return!1;let n=A.current.get(e),r=A.current.get(t);if(!n||!r||!h(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ee(n,r.topicKey),a=[...r.blockBy||[]];if(a.some(e=>{let t=v(e),n=v(i);return!t||!n||t.kind!==n.kind?!1:(t.kind===`local`&&n.kind===`local`||t.kind===`foreign`&&n.kind===`foreign`&&t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(f(e=>{let t=A.current.get(String(e));if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=y(e,t.topicKey);r&&A.current.has(r)&&n.push(r)}return n},e,t))return Y.current(`会形成环,已取消`),!1;let o=n.topicKey!==r.topicKey;return await X(r,{blockBy:[...a,i]},o?`#${n.id}@${n.projectName} → #${r.id}@${r.projectName}`:`#${n.id} → #${r.id}`),!0};let ye=(e,t)=>{if(q.current||e.button!==0||e.target instanceof Element&&e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=H.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!h(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(H.current||!h(t))return;e.preventDefault();let r=M.current;if(!r)return;let i=F.current.get(t.nodeKey)||{x:0,y:0},a=C(r,e.clientX,e.clientY);H.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},W(t.nodeKey)},be=(e,t)=>{if(q.current||!h(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),H.current?.kind===`link`&&H.current.sourceId===t.nodeKey){Z();return}let n=ae(M.current,F.current,t.nodeKey,Ee),r=M.current,i=r?C(r,e.clientX,e.clientY):{x:n.x,y:n.y},a={kind:`link`,sourceId:t.nodeKey,x1:n.x,y1:n.y,cx:i.x,cy:i.y,overId:null,dragged:!1,sx:i.x,sy:i.y};H.current=a,ve(a)},xe=e=>{H.current&&H.current.kind===`link`&&(e.target instanceof Element&&e.target.closest(`.dagp-node`)||Z())},Se=async(e,t)=>{let n=[...e.blockBy||[]].filter(e=>{let n=v(e),r=v(t);return!n||!r?String(e)!==String(t):n.kind===r.kind?n.kind===`local`&&r.kind===`local`?n.id!==r.id:n.kind===`foreign`&&r.kind===`foreign`?n.key!==r.key||n.id!==r.id:!0:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},Ce=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),we=async e=>{let t=await s({title:`时间目标 · #${e.id}`,input:!0,placeholder:`如 2h / 90m`,value:e.timegoal?.duration||``});if(t==null)return;let n=String(t).trim();if(!n){await X(e,{clearGoal:!0},`#${e.id} 已清除时间目标`);return}await X(e,{duration:n},`#${e.id} 时间目标 ${n}`)},Te=e=>{n.openPage&&(t?n.openPage({groupId:t,task:String(e.id),name:`#${e.id}`}):n.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},Ee=e=>{let t=M.current?.querySelector(`[data-node-id="${CSS.escape(e)}"]`);return t instanceof HTMLElement?t.offsetHeight:64},De=(0,p.useMemo)(()=>oe(O,N,k,Ee),[O,N,k,U,G]),Q=(0,p.useMemo)(()=>{let e=480,t=240;for(let n of O){let r=N.get(n.nodeKey);r&&(e=Math.max(e,r.x+280+100),t=Math.max(t,r.y+140))}return G&&(e=Math.max(e,G.cx+40),t=Math.max(t,G.cy+40)),{w:e,h:t}},[O,N,G]),Oe=T?S?.name||`组编排`:D?.name||e||`编排`,ke=()=>{re(R.current),V.current.clear(),P(b(O,{perCol:I})),r(`已恢复默认布局`)},$=!!G,Ae=G?k.get(G.sourceId)?.id??G.sourceId:``;return(0,w.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(U==null?``:` is-dragging`),children:[(0,w.jsx)(ce,{title:Oe,count:O.length,linkArmed:$,srcLabel:Ae,groupMode:T,queues:ue,filterKey:E,onFilter:de,onReset:ke}),(0,w.jsxs)(`div`,{className:`dagp-canvas`,ref:M,onPointerDown:xe,children:[(0,w.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`marker`,{id:`dagp-arrow-${g}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,w.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),De.map(e=>(0,w.jsx)(`path`,{className:`dagp-edge`,d:ie(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${g})`},`${e.from}->${e.to}`)),G&&(0,w.jsx)(`path`,{className:`dagp-edge preview`,d:ie(G.x,G.y,G.cx,G.cy),markerEnd:`url(#dagp-arrow-${g})`})]}),(0,w.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:O.map(e=>(0,w.jsx)(le,{n:e,p:N.get(e.nodeKey)||{x:56,y:28},byNodeKey:k,groupMode:T,dragId:U,linking:G,linkArmed:$,onStartDrag:ye,onStartLink:be,onOpenTask:Te,onToggleGate:Ce,onAddTimegoal:we,onRemoveDep:Se,onOpsMenu:he},e.nodeKey))}),!O.length&&(0,w.jsx)(`div`,{className:`dagp-empty`,children:T?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,w.jsx)(o,{x:K.x,y:K.y,items:K.items,onClose:()=>he(null)}),l]})}export{T as default};
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a,n as o,u as s}from"./popup-DLfU1TXG.js";import{n as c}from"./app-context-DPFYOrgE.js";import{r as l}from"./md-parse-BjzYV8n7.js";import{n as u}from"./board-view-jt8QixVg.js";import{w as d}from"./index-Di6ErKBG.js";import{t as f}from"./graph-BTEfvFz6.js";var p=r(n(),1);function m(e){return!(!e||e.deletedAt||e.migratedTo)}function h(e){return m(e)&&e?.status===`pending`}function g(e){return l(e.text)||d(e)||`#${e.id}`}function _(e,t){return`${e}:${Number(t)}`}function v(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return{kind:`local`,id:Math.trunc(e)};let t=String(e??``).trim();if(!t)return null;let n=/^([A-Za-z0-9_-]+):(\d+)$/.exec(t),r=n?.[1],i=n?.[2];if(r&&i)return{kind:`foreign`,key:r,id:Number(i)};if(/^\d+$/.test(t)){let e=Number(t);if(e>0)return{kind:`local`,id:e}}return null}function y(e,t){let n=v(e);return n?n.kind===`foreign`?_(n.key,n.id):_(t,n.id):null}function ee(e,t){return e.topicKey===t?Number(e.id):_(e.topicKey,e.id)}function te(e){return s(`/api/localtasks/item`,{method:`PATCH`,body:e})}function b(e,t={}){let n=Math.max(3,Number(t.perCol)||8),r=new Map;for(let t of e){let e=r.get(t.topicKey);e?e.push(t):r.set(t.topicKey,[t])}let i=new Map,a=0;for(let[,e]of r)e.forEach((e,t)=>{let r=a+Math.floor(t/n),o=t%n;i.set(e.nodeKey,{x:56+r*320,y:28+o*94})}),a+=Math.ceil(e.length/n);return i}var x=e=>`nx-kv-dag-pos:${e}`;function ne(e){try{let t=JSON.parse(localStorage.getItem(x(e))||`{}`),n=new Map;for(let[e,r]of Object.entries(t||{}))if(Array.isArray(r)&&Number.isFinite(r[0])&&Number.isFinite(r[1])){let t=Number(r[0]),i=Number(r[1]);n.set(e,{x:t,y:i})}return n}catch{return new Map}}function re(e){try{localStorage.removeItem(x(e))}catch{}}function S(e,t){try{let n={};for(let[e,r]of t)r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&(n[e]=[Math.round(r.x),Math.round(r.y)]);return localStorage.setItem(x(e),JSON.stringify(n)),!0}catch{return!1}}function ie(e,t,n,r){let i=Math.max(48,Math.abs(n-e)*.5);return`M ${e} ${t} C ${e+i} ${t}, ${n-i} ${r}, ${n} ${r}`}function C(e,t,n){let r=e.getBoundingClientRect();return{x:t-r.left+e.scrollLeft,y:n-r.top+e.scrollTop}}function ae(e,t,n,r){let i=t.get(n)||{x:0,y:0};return{x:i.x+280,y:i.y+r(n)/2}}function oe(e,t,n,r){let i=[];for(let a of e){let e=t.get(a.nodeKey);if(!e)continue;let o=r(a.nodeKey);for(let s of a.blockBy||[]){let c=y(s,a.topicKey);if(!c||!n.has(c))continue;let l=t.get(c);if(!l)continue;let u=r(c),d=e.x>l.x+280-8;i.push({from:c,to:a.nodeKey,x1:d?l.x+280:l.x,y1:l.y+u/2,x2:d?e.x:e.x+280,y2:e.y+o/2})}}return i}function se({canvasRef:e,modeRef:t,posRef:n,nodesRef:r,byNodeKeyRef:i,scopeKeyRef:a,userMovedRef:o,commitRef:s,toastRef:c,setPos:l,setDragId:u,setLinking:d}){let f=(t,i)=>{let a=e.current;if(!a)return null;let{x:o,y:s}=C(a,t,i),c=r.current;for(let e=c.length-1;e>=0;e--){let t=c[e];if(!t)continue;let r=t.nodeKey,i=n.current.get(r);if(!i)continue;let l=a.querySelector(`[data-node-id="${CSS.escape(r)}"]`),u=l instanceof HTMLElement?l.offsetHeight:64;if(o>=i.x-10&&o<=i.x+280+28&&s>=i.y-6&&s<=i.y+u+6)return r}return null},m=e=>{if(!e||e.kind!==`link`){d(null);return}d({sourceId:e.sourceId,x:e.x1,y:e.y1,cx:e.cx,cy:e.cy,overId:e.overId,dragged:!!e.dragged})},h=()=>{t.current=null,u(null),d(null)};return(0,p.useEffect)(()=>{let r=n=>{let r=t.current;if(!r)return;let i=e.current;if(!i)return;let a=C(i,n.clientX,n.clientY);if(r.kind===`drag`){let e=Math.max(8,a.x-r.ox),t=Math.max(8,a.y-r.oy);l(n=>{let i=new Map(n);return i.set(r.id,{x:e,y:t}),i});return}if(r.kind===`link`){let e=f(n.clientX,n.clientY),i=e&&e!==r.sourceId?e:null,o=Math.hypot(a.x-r.sx,a.y-r.sy),s=r.dragged||o>=6,c={...r,cx:a.x,cy:a.y,overId:i,dragged:s};t.current=c,m(c)}},u=async e=>{let r=t.current;if(r){if(r.kind===`drag`){o.current.add(r.id),S(a.current,n.current),h();return}if(r.kind===`link`){let t=r.overId||f(e.clientX,e.clientY),n=r.sourceId;if(t&&t!==n){h(),await s.current(n,t);return}if(r.dragged){h();return}let a=i.current.get(n);c.current(`已选 #${a?.id??n},再点目标画出有向边`)}}},d=e=>{e.key===`Escape`&&h()};return window.addEventListener(`pointermove`,r),window.addEventListener(`mousemove`,r),window.addEventListener(`pointerup`,u),window.addEventListener(`mouseup`,u),window.addEventListener(`pointercancel`,h),window.addEventListener(`keydown`,d),()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`mousemove`,r),window.removeEventListener(`pointerup`,u),window.removeEventListener(`mouseup`,u),window.removeEventListener(`pointercancel`,h),window.removeEventListener(`keydown`,d)}},[]),{publishLink:m,clearMode:h}}var w=t();function ce({title:e,count:t,linkArmed:n,srcLabel:r,groupMode:i,queues:a,filterKey:o,onFilter:s,onReset:c}){return(0,w.jsxs)(`div`,{className:`dagp-head`,children:[(0,w.jsx)(`span`,{className:`dagp-title`,children:e}),(0,w.jsxs)(`span`,{className:`dagp-count`,children:[t,` 个待领取节点`]}),(0,w.jsx)(`span`,{className:`dagp-hint`,children:n?`连线中:再点目标完成 #${r} → 目标(Esc 取消)`:i?`组内全量任务;跨项目连线对 get 生效;未连线走各队列默认序`:`点右侧 ● 再点目标 = 有向顺序;未连线 = 无先后、走默认序`}),i&&a.length>0&&(0,w.jsxs)(`span`,{className:`dagp-queues`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(o===``?` on`:``),onClick:()=>s(``),children:[`全部`,(0,w.jsx)(`i`,{children:a.reduce((e,t)=>e+t.total,0)})]}),a.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`dagp-queue`+(e.key===o?` on`:``),title:`${e.name} · ${e.count}/${e.total}`,onClick:()=>s(e.key),children:[e.name,(0,w.jsx)(`i`,{children:e.count})]},e.key))]}),(0,w.jsx)(`button`,{type:`button`,className:`dagp-reset`,onClick:c,title:`清掉记住的摆位,按默认分栏重排`,children:`恢复默认布局`})]})}function le({n:t,p:n,byNodeKey:r,groupMode:i,dragId:a,linking:o,linkArmed:s,onStartDrag:c,onStartLink:l,onOpenTask:u,onToggleGate:d,onAddTimegoal:f,onRemoveDep:p,onOpsMenu:m}){let h=(t.blockBy||[]).map(e=>({token:e,key:y(e,t.topicKey)})).filter(e=>e.key&&r.has(e.key)),_=o&&o.overId===t.nodeKey,v=o&&o.sourceId===t.nodeKey;return(0,w.jsxs)(`div`,{"data-node-id":t.nodeKey,className:`dagp-node`+(a===t.nodeKey?` dragging`:``)+(_?` over`:``)+(v?` linking-src`:``)+(t.blocksFollowing?` gate`:``)+(s&&!v?` link-target`:``),style:{transform:`translate(${n.x}px, ${n.y}px)`,width:280},onPointerDown:e=>c(e,t),children:[(0,w.jsx)(`span`,{className:`dagp-port in`,title:`入:箭头指向我 = 我等对方`,"aria-hidden":`true`}),(0,w.jsxs)(`div`,{className:`dagp-body`,children:[(0,w.jsxs)(`div`,{className:`dagp-top`,children:[(0,w.jsxs)(`span`,{className:`dagp-no mono`,children:[`#`,t.id]}),i&&(0,w.jsx)(`span`,{className:`dagp-chip proj`,children:t.projectName}),t.blocksFollowing&&(0,w.jsx)(`span`,{className:`dagp-chip gate`,children:`闸门`}),t.ready===!1&&(0,w.jsx)(`span`,{className:`dagp-chip lock`,children:`锁定`}),t.timegoal?.duration&&(0,w.jsxs)(`span`,{className:`dagp-chip goal`,children:[`⏱ `,t.timegoal.duration]}),(0,w.jsx)(`button`,{type:`button`,className:`dagp-ops`,title:`节点操作`,"aria-label":`节点操作`,onClick:e=>{e.stopPropagation();let n=[{label:`打开任务`,onClick:()=>u(t)},{label:t.blocksFollowing?`取消闸门`:`设为闸门(挡住后续)`,onClick:()=>d(t)},{label:t.timegoal?.duration?`改时间目标`:`加时间目标(timegoal)`,onClick:()=>f(t)}],r=e.currentTarget.getBoundingClientRect();m({x:r.left,y:r.bottom,items:n})},children:(0,w.jsx)(e,{name:`dots`,size:13,title:void 0})})]}),(0,w.jsx)(`div`,{className:`dagp-name`,title:t.text,onDoubleClick:e=>{e.stopPropagation(),u(t)},children:g(t)}),h.length>0&&(0,w.jsx)(`div`,{className:`dagp-deps`,children:h.map(({token:e,key:n})=>{let i=n?r.get(n):void 0,a=!!i&&i.topicKey!==t.topicKey;return(0,w.jsxs)(`span`,{className:`dagp-chip dep`,title:a&&i?`跨项目 #${i.id}@${i.projectName} → #${t.id}`:`#${i?.id} → #${t.id}`,children:[`← #`,i?.id,a?`@${i.projectName}`:``,(0,w.jsx)(`i`,{role:`button`,"aria-label":`解除依赖`,onClick:n=>{n.stopPropagation(),p(t,e)},children:`×`})]},String(e))})})]}),(0,w.jsx)(`button`,{type:`button`,className:`dagp-port out`,title:`点一下再点目标,或按住拖到目标 = 有向顺序(可跨项目)`,"aria-label":`从 #${t.id} 开始连线`,onPointerDown:e=>l(e,t)})]})}function T({dirKey:e,groupId:t}){let n=c(),r=a(),{dialog:s,node:l}=i(),d=n.rows||[],m=n.refreshLocal,g=(0,p.useId)().replace(/:/g,``),x=n.repoData&&n.repoData.boards||[],S=(0,p.useMemo)(()=>x.find(e=>e.id===t||e.key===t)||null,[x,t]),T=!!S,ue=(0,p.useMemo)(()=>{if(!S)return[];let e=[];for(let t of S.repos||[]){let n=d.find(e=>e.repo&&e.repo.key===t.key);if(!n)continue;let r=[S.id,S.key,S.name].filter(Boolean),i=(n.tasks||[]).filter(e=>{if(!h(e))return!1;let t=String(e.boardMark||e.boardKey||``);return t&&r.includes(t)});i.length&&e.push({key:n.key,name:t.name||t.key,cwd:n.cwd,count:i.length,total:i.length})}return e},[S,d]),[E,de]=(0,p.useState)(``);(0,p.useEffect)(()=>{T||de(``)},[T,t]);let D=(0,p.useMemo)(()=>T?null:d.find(t=>t.key===e)||null,[T,d,e]),O=(0,p.useMemo)(()=>{if(T&&S){let e=[S.id,S.key,S.name].filter(Boolean),t=[];for(let n of S.repos||[]){let r=d.find(e=>e.repo&&e.repo.key===n.key);if(r&&!(E&&r.key!==E))for(let i of r.tasks||[]){if(!h(i))continue;let a=String(i.boardMark||i.boardKey||``);a&&e.includes(a)&&t.push({...i,topicKey:r.key,topicCwd:r.cwd,projectName:n.name||n.key,nodeKey:_(r.key,i.id)})}}return t}return D?(D.tasks||[]).filter(e=>h(e)&&!u(e)).map(e=>({...e,topicKey:D.key,topicCwd:D.cwd,projectName:D.name||D.key,nodeKey:_(D.key,e.id)})):[]},[T,S,d,E,D]),k=(0,p.useMemo)(()=>new Map(O.map(e=>[e.nodeKey,e])),[O]),A=(0,p.useRef)(k);A.current=k;let j=(0,p.useRef)(O);j.current=O;let M=(0,p.useRef)(null),[N,P]=(0,p.useState)(()=>new Map),F=(0,p.useRef)(N);F.current=N;let[fe,pe]=(0,p.useState)(0);(0,p.useEffect)(()=>{let e=M.current;if(!e)return;let t=()=>pe(e.clientHeight||0);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[]);let I=Math.max(3,Math.floor(((fe||720)-56)/94)||8),L=T?`g:${S?.id||t||``}`:`d:${e||``}`,R=(0,p.useRef)(L);R.current=L;let z=(0,p.useMemo)(()=>ne(L),[L]),B=(0,p.useRef)(L),V=(0,p.useRef)(new Set);(0,p.useEffect)(()=>{let e=B.current!==L;B.current=L,P(t=>{let n=new Map,r=b(O,{perCol:I});for(let i of O){let a=z.get(i.nodeKey)||(!e&&V.current.has(i.nodeKey)?t.get(i.nodeKey):null)||r.get(i.nodeKey)||{x:56,y:28};n.set(i.nodeKey,a)}return n})},[O,I,z,L]);let H=(0,p.useRef)(null),[U,W]=(0,p.useState)(null),[G,me]=(0,p.useState)(null),[K,he]=(0,p.useState)(null),[ge,_e]=(0,p.useState)(!1),q=(0,p.useRef)(!1);q.current=ge;let J=(0,p.useRef)(async()=>!1),Y=(0,p.useRef)(r);Y.current=r;let X=async(e,t,n)=>{_e(!0);try{let i={...t};Array.isArray(i.blockBy)&&(i.blockBy=i.blockBy.join(`,`)),await te({cwd:e.topicCwd,id:Number(e.id),...i}),n&&r(n),m&&await m()}catch(e){r(String(e.message||e))}finally{_e(!1)}},{publishLink:ve,clearMode:Z}=se({canvasRef:M,modeRef:H,posRef:F,nodesRef:j,byNodeKeyRef:A,scopeKeyRef:R,userMovedRef:V,commitRef:J,toastRef:Y,setPos:P,setDragId:W,setLinking:me});J.current=async(e,t)=>{if(!t||t===e)return!1;let n=A.current.get(e),r=A.current.get(t);if(!n||!r||!h(r))return Y.current(`只能连到待领取任务`),!1;if(r.blocksFollowing)return Y.current(`#${r.id} 是闸门,不能声明上游`),!1;let i=ee(n,r.topicKey),a=[...r.blockBy||[]];if(a.some(e=>{let t=v(e),n=v(i);return!t||!n||t.kind!==n.kind?!1:(t.kind===`local`&&n.kind===`local`||t.kind===`foreign`&&n.kind===`foreign`&&t.key===n.key)&&t.id===n.id}))return Y.current(`已有该有向边`),!1;if(f(e=>{let t=A.current.get(String(e));if(!t)return[];let n=[];for(let e of t.blockBy||[]){let r=y(e,t.topicKey);r&&A.current.has(r)&&n.push(r)}return n},e,t))return Y.current(`会形成环,已取消`),!1;let o=n.topicKey!==r.topicKey;return await X(r,{blockBy:[...a,i]},o?`#${n.id}@${n.projectName} → #${r.id}@${r.projectName}`:`#${n.id} → #${r.id}`),!0};let ye=(e,t)=>{if(q.current||e.button!==0||e.target instanceof Element&&e.target.closest(`.dagp-port, .dagp-ops, .dagp-chip, button, a`))return;let n=H.current;if(n&&n.kind===`link`){if(e.preventDefault(),e.stopPropagation(),t.nodeKey===n.sourceId){Z();return}if(!h(t)){Y.current(`只能连到待领取任务`);return}let r=n.sourceId;Z(),J.current(r,t.nodeKey);return}if(H.current||!h(t))return;e.preventDefault();let r=M.current;if(!r)return;let i=F.current.get(t.nodeKey)||{x:0,y:0},a=C(r,e.clientX,e.clientY);H.current={kind:`drag`,id:t.nodeKey,ox:a.x-i.x,oy:a.y-i.y},W(t.nodeKey)},be=(e,t)=>{if(q.current||!h(t)||e.button!==0)return;if(e.preventDefault(),e.stopPropagation(),H.current?.kind===`link`&&H.current.sourceId===t.nodeKey){Z();return}let n=ae(M.current,F.current,t.nodeKey,Ee),r=M.current,i=r?C(r,e.clientX,e.clientY):{x:n.x,y:n.y},a={kind:`link`,sourceId:t.nodeKey,x1:n.x,y1:n.y,cx:i.x,cy:i.y,overId:null,dragged:!1,sx:i.x,sy:i.y};H.current=a,ve(a)},xe=e=>{H.current&&H.current.kind===`link`&&(e.target instanceof Element&&e.target.closest(`.dagp-node`)||Z())},Se=async(e,t)=>{let n=[...e.blockBy||[]].filter(e=>{let n=v(e),r=v(t);return!n||!r?String(e)!==String(t):n.kind===r.kind?n.kind===`local`&&r.kind===`local`?n.id!==r.id:n.kind===`foreign`&&r.kind===`foreign`?n.key!==r.key||n.id!==r.id:!0:!0});await X(e,{blockBy:n},`已解除依赖 → #${e.id}`)},Ce=e=>X(e,{gate:!e.blocksFollowing},e.blocksFollowing?`#${e.id} 取消闸门`:`#${e.id} 设为闸门`),we=async e=>{let t=await s({title:`时间目标 · #${e.id}`,input:!0,placeholder:`如 2h / 90m`,value:e.timegoal?.duration||``});if(t==null)return;let n=String(t).trim();if(!n){await X(e,{clearGoal:!0},`#${e.id} 已清除时间目标`);return}await X(e,{duration:n},`#${e.id} 时间目标 ${n}`)},Te=e=>{n.openPage&&(t?n.openPage({groupId:t,task:String(e.id),name:`#${e.id}`}):n.openPage({dirKey:e.topicKey,task:String(e.id),name:`#${e.id}`}))},Ee=e=>{let t=M.current?.querySelector(`[data-node-id="${CSS.escape(e)}"]`);return t instanceof HTMLElement?t.offsetHeight:64},De=(0,p.useMemo)(()=>oe(O,N,k,Ee),[O,N,k,U,G]),Q=(0,p.useMemo)(()=>{let e=480,t=240;for(let n of O){let r=N.get(n.nodeKey);r&&(e=Math.max(e,r.x+280+100),t=Math.max(t,r.y+140))}return G&&(e=Math.max(e,G.cx+40),t=Math.max(t,G.cy+40)),{w:e,h:t}},[O,N,G]),Oe=T?S?.name||`组编排`:D?.name||e||`编排`,ke=()=>{re(R.current),V.current.clear(),P(b(O,{perCol:I})),r(`已恢复默认布局`)},$=!!G,Ae=G?k.get(G.sourceId)?.id??G.sourceId:``;return(0,w.jsxs)(`div`,{className:`dagp`+($?` is-linking`:``)+(U==null?``:` is-dragging`),children:[(0,w.jsx)(ce,{title:Oe,count:O.length,linkArmed:$,srcLabel:Ae,groupMode:T,queues:ue,filterKey:E,onFilter:de,onReset:ke}),(0,w.jsxs)(`div`,{className:`dagp-canvas`,ref:M,onPointerDown:xe,children:[(0,w.jsxs)(`svg`,{className:`dagp-edges`,width:Q.w,height:Q.h,style:{width:Q.w,height:Q.h},"aria-hidden":`true`,children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`marker`,{id:`dagp-arrow-${g}`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,w.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,fill:`var(--mdw-accent, #2F6F5E)`})})}),De.map(e=>(0,w.jsx)(`path`,{className:`dagp-edge`,d:ie(e.x1,e.y1,e.x2,e.y2),markerEnd:`url(#dagp-arrow-${g})`},`${e.from}->${e.to}`)),G&&(0,w.jsx)(`path`,{className:`dagp-edge preview`,d:ie(G.x,G.y,G.cx,G.cy),markerEnd:`url(#dagp-arrow-${g})`})]}),(0,w.jsx)(`div`,{className:`dagp-nodes`,style:{width:Q.w,height:Q.h},children:O.map(e=>(0,w.jsx)(le,{n:e,p:N.get(e.nodeKey)||{x:56,y:28},byNodeKey:k,groupMode:T,dragId:U,linking:G,linkArmed:$,onStartDrag:ye,onStartLink:be,onOpenTask:Te,onToggleGate:Ce,onAddTimegoal:we,onRemoveDep:Se,onOpsMenu:he},e.nodeKey))}),!O.length&&(0,w.jsx)(`div`,{className:`dagp-empty`,children:T?`本组还没有带 board 归属的任务。连线可跨项目,对 get 生效。`:`这个队列没有任务。连线是编排里唯一的顺序关系;不连就保持默认序。`})]}),K&&(0,w.jsx)(o,{x:K.x,y:K.y,items:K.items,onClose:()=>he(null)}),l]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,i as r,l as i}from"./popup-DLfU1TXG.js";import{f as a,y as ee}from"./tool-bar-NHeX0Kmo.js";import{n as o}from"./app-context-DPFYOrgE.js";import{n as s}from"./board-view-jt8QixVg.js";import{r as c}from"./doc-
|
|
1
|
+
import{d as e,f as t,h as n,i as r,l as i}from"./popup-DLfU1TXG.js";import{f as a,y as ee}from"./tool-bar-NHeX0Kmo.js";import{n as o}from"./app-context-DPFYOrgE.js";import{n as s}from"./board-view-jt8QixVg.js";import{r as c}from"./doc-zDLeR8PE.js";import{S as l,d as u,f as d,h as f,v as p,x as m}from"./index-Di6ErKBG.js";import{h as te,s as h}from"./reopen-text-D0eQ2XAC.js";import{a as g,c as _,d as v,f as ne,i as y,l as b,n as re,o as x,r as S,s as C,t as w,u as T}from"./task-ops-s9kkuLcK.js";import{t as E}from"./template-preview-EM3OQ1Rc.js";import{n as ie}from"./manage-session-CuaL7QqQ.js";import{i as ae}from"./task-utils-Y-j-zi8J.js";var D=n(t(),1),O=e();function k({dirKey:e}){let{dialog:t,node:n}=r(),k=o(),A=i(),j=k.rows||[],M=k.refreshLocal,N=k.tpl,P=k.model,F=k.repoData&&k.repoData.repos||[],[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(!1),B=(0,D.useMemo)(()=>j.find(t=>t.key===e)||null,[j,e]),V=(0,D.useMemo)(()=>{if(!B)return null;let e=B.repo&&B.repo.key;if(e){let t=F.find(t=>t.key===e);if(t)return t}let t=String(B.cwd||``).replace(/\\/g,`/`).toLowerCase();return t&&F.find(e=>String(e.path||``).replace(/\\/g,`/`).toLowerCase()===t)||null},[B,F]),H=(0,D.useMemo)(()=>ae((B?.tasks||[]).filter(e=>!e.deletedAt&&!s(e))),[B]),U=(0,D.useMemo)(()=>{let e={},t=H.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt);return t.forEach((n,r)=>{n.blocksFollowing&&(e[n.id]=t.slice(r+1).map(e=>e.id))}),e},[H]),oe=(0,D.useMemo)(()=>H.filter(e=>e.status===`pending`&&!e.migratedTo&&!e.deletedAt),[H]),W=(0,D.useMemo)(()=>H.map(e=>({key:String(e.id),task:e,showTimes:!0,movable:e.status===`pending`&&!e.migratedTo&&!e.deletedAt,downs:U[e.id]||[]})),[H,U]),G=e=>e().catch(e=>A(String(e.message||e))),K=()=>({cwd:B?.cwd}),q=e||``,J=!!(V&&V.getLoop&&V.getLoop.enabled),Y=V&&V.getLoop&&V.getLoop.waitMinutes!==void 0&&V.getLoop.waitMinutes!==null?Number(V.getLoop.waitMinutes):null,X={dialog:t,toast:A,refresh:()=>{M?.()},docKey:e||`local`,onDeleted:t=>{if(!P)return;let n=ee(P,`page`,{dirKey:e,task:String(t.id)});n&&k.closePanel&&k.closePanel(n.getId())}},Z=t=>{k.openPage&&k.openPage({dirKey:e,task:String(t),name:`#${t}`})},Q=t=>{let n=p();m(f(l(e),n),{title:``,body:t}),k.openPage&&k.openPage({dirKey:e,task:n,name:`新任务`})},se=()=>{let t=ie({topic:q,repo:V?.key||``,label:B?.name||e||`本目录`});k.onNavigate?.(`#/templates/manage/${t}`)},ce=()=>{P&&a(P,{component:`progress`,name:`进程`,config:{dirKey:e||``},location:`right`})},$=u(q).templates||N&&N.templates||[],le=()=>{if(!P){A(`工作区未就绪`);return}d(P,{mode:`new`,topic:q,scope:[`topic:${q}`],name:``})},ue=[...$.length?$.map(t=>({label:(t.id===N?.defaultId?`✓ `:``)+t.name,icon:`list`,onClick:()=>{T(t,{topic:q,dirKey:e||``},k)||Q(E(t))}})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>{let t=N?N.defaultPick():null,n=(N?.templates||[]).find(e=>e.id===(t?.id||N?.defaultId));n&&T(n,{topic:q,dirKey:e||``},k)||Q(t&&t.id?E(t):t?t.body:``)}}],`sep`,{label:`为本目录新建模板…`,icon:`plus`,onClick:le},{label:`管理模板…`,icon:`gear`,onClick:se}],de=()=>{if(!V){A(`这个目录还没有登记为仓库,没有项目文档列表`);return}if(!P)return;let e=V.key||B?.repo&&B.repo.key||``;if(!e){A(`这个项目还没有仓库标识(key),无法定位文档列表`);return}a(P,{component:`refs`,name:`文档列表`,config:{repoKey:e},location:`right`})},fe=async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await G(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,i=await h({cwd:B?.cwd,text:r});A(`已导入:${e.name}`),M?.();let a=i?.task?.id??i?.id;a!=null&&Z(a)})};return B?(0,O.jsx)(O.Fragment,{children:(0,O.jsx)(b,{kind:`dir`,name:B?.name||`目录`,title:`任务`,intro:V?(0,O.jsx)(c,{kind:`repo`,owner:V,model:P}):null,rows:W,emptyText:`还没有页面:点「+ 新建页」写第一篇,或让 agent 往这个目录投递任务。`,tplMenuItems:ue,onNew:()=>{let t=N?N.defaultPick():null,n=(N?.templates||[]).find(e=>e.id===(t?.id||N?.defaultId));n&&T(n,{topic:q,dirKey:e||``},k)||Q(t&&t.id?E(t):t?t.body:``)},onOpenRow:e=>Z(e.task.id),onImportFile:e=>void fe(e),onMoveRow:(e,t,n)=>G(async()=>{await te({...K(),id:e.task.id,...n===`before`?{beforeId:t.task.id}:{afterId:t.task.id}}),M?.()}),onTogglePlan:(e,t)=>void x(X,[{scope:{key:q},ids:e.map(e=>e.task.id)}],t),onOpenDag:e=>L(e.task),onToggleGate:e=>void C(X,K(),e.task),onFeedback:e=>void g(X,K(),e.task),onDeleteRow:e=>void y(X,K(),e.task),onDeleteRows:e=>S(X,[{scope:K(),ids:e.map(e=>Number(e.task.id))}]),onCancelRows:e=>w(X,[{scope:K(),ids:e.map(e=>Number(e.task.id))}]),onCompleteRows:e=>re(X,[{scope:K(),ids:e.map(e=>Number(e.task.id))}]),toolActs:{renderers:{getloop:()=>(0,O.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:J?`持续 get 已开启:agent 领完任务没活时会阻塞等待(每轮 ${Y??10} 分钟)——点这里去配置/关闭`:`持续 get 未开启:开启后 agent 领完任务没活会自动唤起阻塞等待——点这里配置`,onClick:()=>z(!0),children:J?`持续 get:开(${Y??10} 分钟)`:`持续 get:关`})},actions:{progress:ce,orch:()=>P&&a(P,{component:`dag`,name:`编排`,config:{dirKey:e}}),refs:de,getloop:()=>z(!0)}},actionExtra:R&&V?(0,O.jsx)(ne,{repo:V,onClose:()=>z(!1),onSaved:()=>k.refreshRepos?.()}):null,extra:(0,O.jsxs)(O.Fragment,{children:[I&&(0,O.jsx)(v,{task:I,tasks:oe,onClose:()=>L(null),onSave:e=>_(X,K(),e)}),n]})})}):(0,O.jsx)(`div`,{className:`rp-page`,children:(0,O.jsx)(`div`,{className:`rp-empty`,children:`目录不存在(主题可能被删了)`})})}export{k as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,m as o,u as s}from"./popup-DLfU1TXG.js";import{D as c,N as l,a as u,c as d,f,i as p,l as m,o as h,r as g,s as _,t as v}from"./tool-bar-NHeX0Kmo.js";import{n as y}from"./app-context-DPFYOrgE.js";import{a as b,i as x,o as S}from"./md-parse-BjzYV8n7.js";import{a as C,i as w,m as T,n as E,o as D,r as O,t as k,v as ee,w as A,y as j}from"./md-history-D0bYVPZY.js";import{i as M,n as N,r as te,t as P}from"./use-rail-drag-CtZxisjE.js";import{i as F,t as ne}from"./route-crumb-DS76cmRK.js";function re(){return s(`/api/docs/index`)}function ie(){return s(`/api/boards`)}function I(){return s(`/api/repos`)}function ae(){return s(`/api/docs/index`)}function oe(e){return s(`/api/docs/attachments?ref=${encodeURIComponent(e)}`)}function se(e){return s(`/api/docs/item?ref=`+encodeURIComponent(e))}function L(e){return s(`/api/repos/docs`,{method:`POST`,body:e})}function ce(e){return s(`/api/docs/unbind`,{method:`POST`,body:e})}function le(e){return s(`/api/docs/link`,{method:`POST`,body:e})}function R(e){return s(`/api/docs/bindings?ref=`+encodeURIComponent(e))}function ue(e){let t=new URLSearchParams;return e.host&&t.set(`host`,e.host),e.group&&t.set(`group`,e.group),s(`/api/docs/bindings?`+t.toString())}function de(e){return s(`/api/docs/ref`,{method:`POST`,body:e})}function fe(e){return s(`/api/docs/unbind`,{method:`POST`,body:e})}function z(e,t){return s(`/api/docs/item`,{method:`PATCH`,body:{ref:e,desc:t}})}function pe(e){return s(`/api/docs/main`,{method:`POST`,body:e})}function B(e){return s(`/api/docs/item`,{method:`PATCH`,body:e})}function me(e){return s(`/api/docs/item`,{method:`DELETE`,body:e})}var V=`nx-kv:docs-changed`;function H(){typeof window>`u`||window.dispatchEvent(new CustomEvent(V))}function he(e){if(typeof window>`u`)return()=>{};let t=()=>e();return window.addEventListener(V,t),()=>window.removeEventListener(V,t)}async function ge({owner:e,repo:t,group:n,desc:r=``,title:i=``}){let a=await de({owner:e,repo:t,group:n,desc:r});return i&&await B({ref:`ref:`+a.refId,body:`# ${i}\n\n(待补)\n`}),H(),a.refId}async function _e(e,t){let n=await z(e,String(t||``).trim());return H(),String(n?.desc??t??``)}async function ve(e){await fe({ref:e.refId,type:e.type,repo:e.repoKey,group:e.groupKey||void 0}),H()}async function ye(e){if(e.type===`group_repo`)throw Error(`组内仓库描述没有主篇概念`);await pe(e.type===`group`?{ref:e.refId,board:e.repoKey}:{ref:e.refId,repo:e.repoKey}),H()}var U=t();function be({refId:e,writable:t,onChanged:n,onOpenDoc:r}){return(0,U.jsx)(M,{host:`doc`,refId:e,allow:{file:!0,url:!0,folder:!0,task:!1,ref:!0,repo:!1},disabled:!t,disabledText:`只读文档不能添加附件。`,onChanged:n,onOpenDoc:r})}function xe({dock:t,attCount:n=0,bindCount:r=0,attachNode:i,bindNode:a}){let{dockOpen:o,dockTab:s,dockH:c,dockRef:l,dockMax:u,showDockTab:d,onDockDragStart:f,toggleDockMax:p,setDockOpen:m}=t;if(!o)return null;let h=s===`bind`?`bind`:`attach`;return(0,U.jsxs)(`div`,{className:`mdw-dock docp-dock`,ref:l,style:{height:`${c}px`},children:[(0,U.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:f,onDoubleClick:p}),(0,U.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,U.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`attach`,className:`mdw-dock-tab${h===`attach`?` is-on`:``}`,onClick:()=>d(`attach`),children:[`附件`,n?(0,U.jsx)(`span`,{className:`mdw-dock-tab-num`,children:n}):null]}),(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`bind`,className:`mdw-dock-tab${h===`bind`?` is-on`:``}`,onClick:()=>d(`bind`),children:[`归属`,r?(0,U.jsx)(`span`,{className:`mdw-dock-tab-num`,children:r}):null]})]}),(0,U.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,U.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:p,title:u?`还原面板高度`:`最大化面板高度`,"aria-label":u?`还原面板高度`:`最大化面板高度`,children:(0,U.jsx)(e,{name:u?`collapse`:`expand`,title:void 0})}),(0,U.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>m(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,U.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,U.jsxs)(`div`,{className:`mdw-dock-body`,children:[(0,U.jsx)(`div`,{className:`docp-dock-pane`,hidden:h!==`attach`,children:i}),(0,U.jsx)(`div`,{className:`docp-dock-pane`,hidden:h!==`bind`,children:a})]})]})}function Se({dock:t,attCount:n=0,bindCount:r=0}){let{dockOpen:i,dockTab:a,showDockTab:o,setDockOpen:s}=t;return(0,U.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${i&&a===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),title:`附件(点击展开信息面板)`,children:[(0,U.jsx)(e,{name:`list`,title:void 0}),(0,U.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),n?(0,U.jsx)(`span`,{className:`mdw-sbar-num`,children:n}):null]}),(0,U.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${i&&a===`bind`?` is-on`:``}`,onClick:()=>o(`bind`),title:`归属:这篇文档被哪些仓库 / 项目组引用(点击展开信息面板)`,children:[(0,U.jsx)(e,{name:`repo`,title:void 0}),(0,U.jsx)(`span`,{className:`mdw-sbar-lab`,children:`归属`}),r?(0,U.jsx)(`span`,{className:`mdw-sbar-num`,children:r}):null]}),(0,U.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,U.jsx)(`span`,{className:`docp-sbar-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 正文存库(v6 起不落盘)`}),(0,U.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${i?` is-open`:``}`,onClick:()=>s(e=>!e),title:i?`收起信息面板`:`展开信息面板`,"aria-expanded":i,"aria-label":i?`收起信息面板`:`展开信息面板`,children:(0,U.jsx)(e,{name:`chevron`,title:void 0})})]})}var W=r(n(),1);function Ce({t:e}){let t=e.main?`主篇`:`附加`;return(0,U.jsxs)(`span`,{className:`nb-tag nb-`+e.kind+(e.main?` nb-main`:``),"data-btag":e.id,title:e.title||e.label,children:[(0,U.jsx)(`span`,{className:`k`,children:(0,U.jsx)(`span`,{className:`dot`})}),(0,U.jsx)(`span`,{className:`role`+(e.main?` main`:``),children:t}),(0,U.jsx)(`span`,{className:`name`,children:e.label}),e.onRemove?(0,U.jsx)(`button`,{type:`button`,className:`x`,title:`解绑(文档本身不删除)`,onClick:t=>{t.stopPropagation(),e.onRemove?.()},children:`✕`}):null]})}function G({items:e,addLabel:t,onAdd:n,onMore:r,empty:i}){let a=(0,W.useRef)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(0),u=(0,W.useCallback)(()=>{let e=a.current;if(!e||!e.clientWidth)return;let t=Array.from(e.querySelectorAll(`:scope > [data-btag]`));if(o){t.forEach(e=>{e.style.display=``}),l(0);return}t.forEach(e=>{e.style.display=``});let n=e.querySelector(`:scope > [data-badd]`),r=e.querySelector(`:scope > [data-bmore]`),i=(n?.offsetWidth||0)+(r?.offsetWidth||0)+6,s=e.clientWidth-(i>6?i:0)-2,c=e.getBoundingClientRect().left,u=0;for(let e of t)e.getBoundingClientRect().right-c>s&&(e.style.display=`none`,u+=1);l(u)},[o]);(0,W.useLayoutEffect)(()=>{u()},[e,u]),(0,W.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>u());return t.observe(e),()=>t.disconnect()},[u]);let d=c>0||o;return(0,U.jsxs)(`div`,{className:`nb-tags`+(o?` open`:``),ref:a,children:[e.map(e=>(0,U.jsx)(Ce,{t:e},e.id)),!e.length&&i?(0,U.jsx)(`span`,{className:`nb-empty`,children:i}):null,d&&!r?(0,U.jsx)(`button`,{type:`button`,className:`nb-tag more`,"data-bmore":!0,title:o?`收起`:`展开全部`,onClick:()=>s(e=>!e),children:o?`收起`:`+${c}`}):null,d&&r?(0,U.jsxs)(`button`,{type:`button`,className:`nb-tag more`,"data-bmore":!0,title:`查看全部`,onClick:r,children:[`+`,c||0]}):null,n?(0,U.jsxs)(`button`,{type:`button`,className:`nb-tag add`,"data-badd":!0,onClick:n,children:[(0,U.jsx)(`b`,{children:`+`}),t||`加绑`]}):null]})}function K(e){let t=String(e||``);return t.startsWith(`ref:`)?t.slice(4):/^ref_[0-9a-f]{16}$/i.test(t)?t:``}function we(e,t,n=``){let r=a(),[i,o]=(0,W.useState)([]),[s,c]=(0,W.useState)(0),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(`repo`),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(``),[C,w]=(0,W.useState)(``),E=(0,W.useCallback)(()=>c(e=>e+1),[]);(0,W.useEffect)(()=>{let e=!0;return I().then(t=>{if(!e)return;let n=(Array.isArray(t)?t:t?.repos||[]).filter(e=>e&&e.key&&(e.type||`dev`)!==`group`).map(e=>({key:String(e.key),name:String(e.name||e.key),kind:`repo`}));u(n)}).catch(()=>{}),ie().then(t=>{if(!e)return;let n=(Array.isArray(t)?t:t?.boards||[]).filter(e=>e&&(e.key||e.id)).map(e=>({key:String(e.key||`board/`+(e.name||e.id)),name:String(e.name||e.key),kind:`group`}));f(n)}).catch(()=>{}),()=>{e=!1}},[]),(0,W.useEffect)(()=>{if(!e){o([]);return}let t=!0;return R(e).then(e=>{t&&o(Array.isArray(e?.bindings)?e.bindings:[])}).catch(()=>{t&&o([])}),()=>{t=!1}},[e,s]);let D=(0,W.useCallback)(e=>{let t=l.find(t=>t.key===e)||d.find(t=>t.key===e);return t?t.name:e},[l,d]);async function O(e){if(!p&&window.confirm(`解绑:${e.repoKey} 不再引用这篇文档?\n(文档本身不删除,只摘掉这条归属)`)){m(!0);try{await ce({ref:e.refId,type:e.type,repo:e.repoKey,group:e.groupKey||void 0}),r(`已解绑`),E()}catch(e){r(`解绑失败:`+(e?.message||`未知错误`))}finally{m(!1)}}}function k(){v(`repo`),b(``),w(``),g(!0)}async function ee(){if(!y){r(`先选一个宿主`);return}let t=K(e||``);if(!t){r(`这篇文档还没有 refId(外部目录不能加绑)`);return}m(!0);try{_===`repo`?await L({id:y,ref:t}):await le({board:y,ref:t}),g(!1),r(_===`repo`?`已加绑到仓库文档集`:`已加绑到组附加文档`),E()}catch(e){r(`加绑失败:`+(e?.message||`未知错误`))}finally{m(!1)}}let A=(0,W.useMemo)(()=>i.map(e=>{let n=e.type===`group_repo`?e.groupKey:null;return{id:`${e.refId}:${e.repoKey}:${e.groupKey||``}:${e.position}`,label:n?`${D(e.repoKey)} · 组 ${D(n)}`:D(e.repoKey),kind:e.type===`group`?`group`:`repo`,main:e.main,title:`${e.repoKey}${n?` @ `+n:``}\n${e.desc||e.refId}`,onRemove:t?()=>O(e):void 0}}),[i,t,D]),j=(0,W.useMemo)(()=>T(A,x,e=>[e.label,e.title]),[A,x]),M=_===`repo`?l:d,N=(0,W.useMemo)(()=>new Set(i.filter(e=>e.type!==`group_repo`).map(e=>e.repoKey)),[i]),te=(0,W.useMemo)(()=>M.filter(e=>!N.has(e.key)),[M,N]),P=(0,W.useMemo)(()=>T(te,C,e=>[e.name,e.key]),[te,C]),ne=e?(0,U.jsxs)(`div`,{className:`docp-bind-panel`,title:`这篇文档被谁引用 —— tag 上的 ✕ 解绑(不删文档)`,children:[i.length>1?(0,U.jsx)(F,{value:x,onChange:S,placeholder:`搜索归属…`,title:`过滤归属`,count:j.length,className:`wide`}):null,(0,U.jsx)(G,{items:j,addLabel:`加绑宿主`,onAdd:t&&K(e||``)?k:void 0,empty:`没有任何归属(孤儿文档)—— 不会被任何仓库 / 组面板列出`}),!i.length&&t?(0,U.jsx)(`div`,{className:`docp-bind-orphan`,children:`孤儿状态:给这篇文档加绑一个仓库或项目组,它才会出现在对应面板的文档集里。`}):null]}):null,re=h?(0,U.jsx)(`div`,{className:`nb-overlay`,onClick:e=>{e.target===e.currentTarget&&g(!1)},children:(0,U.jsxs)(`div`,{className:`nb-modal`,children:[(0,U.jsxs)(`div`,{className:`nb-modal-head`,children:[(0,U.jsx)(`span`,{className:`t`,children:`加绑宿主`}),(0,U.jsx)(`span`,{className:`sub`,children:n||`当前文档`}),(0,U.jsx)(`button`,{type:`button`,className:`close`,onClick:()=>g(!1),children:`✕`})]}),(0,U.jsxs)(`div`,{className:`nb-modal-body`,children:[(0,U.jsxs)(`div`,{className:`nb-frow`,children:[(0,U.jsx)(`label`,{children:`宿主类型`}),(0,U.jsxs)(`div`,{className:`nb-seg`,children:[(0,U.jsx)(`button`,{type:`button`,className:_===`repo`?`on`:``,onClick:()=>{v(`repo`),b(``),w(``)},children:`仓库`}),(0,U.jsx)(`button`,{type:`button`,className:_===`group`?`on`:``,onClick:()=>{v(`group`),b(``),w(``)},children:`项目组`})]})]}),(0,U.jsxs)(`div`,{className:`nb-frow`,children:[(0,U.jsx)(`label`,{children:_===`repo`?`选择仓库`:`选择项目组`}),M.length>1?(0,U.jsx)(F,{value:C,onChange:w,placeholder:_===`repo`?`搜索仓库…`:`搜索项目组…`,title:`过滤可加绑的宿主`,count:P.length,className:`wide`}):null,(0,U.jsx)(`div`,{className:`nb-list`,children:P.length?P.map(e=>(0,U.jsxs)(`label`,{style:{fontWeight:400},children:[(0,U.jsx)(`input`,{type:`radio`,name:`nb-host`,checked:y===e.key,onChange:()=>b(e.key)}),(0,U.jsx)(`span`,{children:e.name}),(0,U.jsx)(`span`,{className:`p`,children:e.key})]},e.key)):(0,U.jsxs)(`label`,{children:[`(没有可加绑的`,_===`repo`?`仓库`:`项目组`,`)`]})})]})]}),(0,U.jsxs)(`div`,{className:`nb-modal-foot`,children:[(0,U.jsx)(`span`,{className:`note`,children:_===`repo`?`落点:repo.doc.add`:`落点:docs.link`}),(0,U.jsx)(`button`,{type:`button`,className:`nb-btn`,onClick:()=>g(!1),children:`取消`}),(0,U.jsx)(`button`,{type:`button`,className:`nb-btn primary`,disabled:p,onClick:ee,children:`加绑`})]})]})}):null;return{count:i.length,strip:ne,modal:re}}var Te=l(),q=`doc`,J=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function Ee({crumb:t=null,title:n,pathLabel:r=``,dirty:i=!1,writable:a=!1,onSave:o=null,onSaveLabel:s=`保存`,menuGroups:c=[],saving:l=!1,external:f=!1,afterTitle:y=null}){let b=p(),{layout:x,setLayout:S}=h(q),[C,w]=(0,W.useState)(!1),T={};for(let e of c||[])for(let t of e?.items||[])t&&t.id&&(T[t.id]=t);T.save=o&&{id:`save`,label:l?`保存中…`:s,run:o,primary:!0,disabled:l||!i};let E=e=>e===`more`||!!T[e],D=x.filter(e=>m(q,e)&&E(e.id)),O=x.filter(e=>_(q,e)&&E(e.id)),k=e=>{let t=T[e];t&&t.run?.(),b.setOpen(!1)},ee=t=>{if(t===`more`)return(0,U.jsx)(`div`,{className:`docp-more`,ref:b.ref,children:(0,U.jsxs)(`button`,{type:`button`,className:`btn ghost sm${b.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":b.open,onClick:e=>g(b,e,`right`),children:[(0,U.jsx)(e,{name:`dots`}),`更多`]})},`more`);let n=T[t];if(!n)return null;let r=d(q,t);return(0,U.jsxs)(`button`,{type:`button`,className:n.primary||t===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!n.disabled,onClick:()=>k(t),children:[r.icon?(0,U.jsx)(e,{name:r.icon}):null,n.label||d(q,t).label||t]},t)},A=J.map(e=>({...e,items:O.filter(t=>d(q,t.id).menuGroup===e.id)})).filter(e=>e.items.length),j=O.filter(e=>!d(q,e.id).menuGroup),M=(0,U.jsxs)(`div`,{className:`mdw-top`,children:[t,(0,U.jsxs)(`div`,{className:`mdw-head`,children:[(0,U.jsx)(`div`,{className:`mdw-title`,children:n||`文档`}),(0,U.jsxs)(`div`,{className:`mdw-path`,children:[r,i?` · 未保存`:``,f?` · 外部`:``]})]})]});return a?(0,U.jsxs)(U.Fragment,{children:[M,(0,U.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,U.jsx)(`div`,{className:`mdw-toolbar-left`,children:y}),(0,U.jsxs)(`div`,{className:`mdw-actions`,children:[D.map(e=>ee(e.id)),(0,U.jsxs)(v,{menu:b,className:`mdw-act-menu`,children:[A.map(t=>(0,U.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":t.label,children:[(0,U.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:t.label}),t.items.map(t=>{let n=T[t.id],r=d(q,t.id),i=n?.danger||r.danger;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(i?` danger`:``),onClick:()=>k(t.id),children:[r.icon?(0,U.jsx)(e,{name:r.icon}):null,n?.label||r.label||t.id,n?.hint?(0,U.jsx)(`span`,{className:`hint`,children:n.hint}):null]},t.id)})]},t.id)),j.map(t=>{let n=T[t.id],r=d(q,t.id);return(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?.danger||r.danger?` danger`:``),onClick:()=>k(t.id),children:[r.icon?(0,U.jsx)(e,{name:r.icon}):null,n?.label||r.label||t.id]},t.id)}),(0,U.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{b.setOpen(!1),w(!0)},children:[(0,U.jsx)(e,{name:`gear`}),`自定义工具栏…`]})]})]})]}),C&&(0,Te.createPortal)((0,U.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>w(!1),children:(0,U.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)(u,{kind:q,layout:x,setLayout:S,onClose:()=>w(!1)})})}),document.body)]}):(0,U.jsxs)(U.Fragment,{children:[M,(0,U.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,U.jsx)(`div`,{className:`mdw-toolbar-left`,children:y}),(0,U.jsx)(`div`,{className:`mdw-actions`,children:(0,U.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function De(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function Y(e,t){return e?e.doc&&e.doc.ref?`ref:`+e.doc.ref:e.docId?e.docId:``:``}function X(e){return e?e.docId?e.docId:e.refId?`ref:`+e.refId:``:``}function Oe(e,t){return e?String(e.title||e.desc||t):t}function ke({kind:e,owner:t,model:n}){let{openByDocId:r}=$(n),i=e===`board`?`组介绍`:`项目介绍`,a=e===`board`&&t?.id||t?.key||``,o=t?.name,c=(0,W.useMemo)(()=>Y(t,e),[t,e]),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(0),h=(0,W.useCallback)(()=>m(e=>e+1),[]);(0,W.useEffect)(()=>{let t=!0;if(!a){u([]),f(``);return}let n=(e,t)=>{let n=[],r=X(e);f(r||c),r&&e&&n.push({docId:r,label:Oe(e,`主篇`),main:!0});for(let e of t){let t=X(e);t&&n.push({docId:t,label:Oe(e,`补充`),main:!1})}u(n)};return e===`repo`?s(`/api/repos/docs?id=`+encodeURIComponent(a)).then(e=>{t&&n(e?.main||null,e?.links||[])}).catch(()=>{t&&(u([]),f(c))}):s(`/api/boards/`+encodeURIComponent(String(a))).then(e=>{t&&n(e?.introMain||null,e?.introExtras||[])}).catch(()=>{t&&(u([]),f(c))}),()=>{t=!1}},[e,a,c,p]);let g=(0,W.useMemo)(()=>e===`repo`&&a?{repoKey:a}:e===`board`&&a?{boardKey:a,boardName:o||``}:{},[e,a,o]);return{kind:e,label:i,ownerKey:a,docRef:c,mainDocId:d,links:l,openMain:(0,W.useCallback)(()=>{let e=d||c;e&&r(e,null,g)},[d,c,r,g]),openDoc:(0,W.useCallback)(e=>r(e,null,g),[r,g]),createMain:(0,W.useCallback)(async()=>{if(!a)return;let t=`ref:`+await ge({owner:e===`board`?`group`:`repo`,...e===`board`?{group:a}:{repo:a},title:o||i});f(t),u([{docId:t,label:o||i,main:!0}]),r(t,null,g)},[e,a,o,i,r,g]),reload:h,canEdit:!!d||!!c}}function Ae(e){return e<=1?18:e===2?12:8}function je({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),{railRef:u,pos:d,dragging:f,draggedRef:p,handleProps:m}=P(N),h=(0,W.useMemo)(()=>e||[],[e]),g=(0,W.useMemo)(()=>n||[],[n]);(0,W.useEffect)(()=>{let e=t;if(!e||!h.length)return;let n=()=>h.map(t=>{let n=e.querySelector(`#${CSS.escape(t.id)}`);if(!n)return null;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{id:t.id,y:r.top-i.top}}).filter(e=>!!e),r=()=>{let e=n();if(!e.length)return;let t=e[0].id;for(let n of e)n.y<=28&&(t=n.id);l(t)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[t,h]);let _=(0,W.useCallback)(e=>{let n=t;if(!n)return;let r=n.querySelector(`#${CSS.escape(e)}`);if(!r){n.scrollTo({top:0,behavior:`smooth`}),l(e);return}r.scrollIntoView({behavior:`smooth`,block:`start`}),l(e)},[t]);return!h.length&&!g.length&&!a?null:(0,U.jsxs)(`aside`,{ref:u,className:`doc-rail`+(o?` open`:``)+(f?` dragging`:``),style:d?{left:d.x,top:d.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`文档目录`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录(按住拖动 · 双击回默认位)`:`展开目录 · 按住拖动 · 双击回默认位`,"aria-expanded":o,onClick:()=>{if(p.current){p.current=!1;return}s(e=>!e)},...m,children:[(0,U.jsx)(`span`,{}),(0,U.jsx)(`span`,{}),(0,U.jsx)(`span`,{})]}),(0,U.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:h.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${Ae(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>_(e.id)},e.id))}),o&&(0,U.jsxs)(`div`,{className:`doc-rail-panel`,children:[h.length>0&&(0,U.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,U.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),h.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>_(e.id),children:e.text},e.id))]}),(g.length>0||a)&&(0,U.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,U.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),g.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,U.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function Me({kind:e,owner:t,model:n}){let r=y(),i=a(),{label:o,docRef:s,mainDocId:c,links:l,openMain:u,createMain:d}=ke({kind:e,owner:t,model:n}),[p,m]=(0,W.useState)(!1);if(!t)return null;let h=!!(s||c),g=l.find(e=>e.main)?.label||`文档库`,_=l.filter(e=>!e.main).length,v=()=>{let i=n||r.model;i&&f(i,{component:`refs`,name:`文档列表`,config:e===`repo`?{repoKey:t.key||``}:{boardKey:t.id||t.key||``,boardName:t.name||``},location:`right`})};if(!h){let e=()=>{p||(m(!0),d().then(()=>r.refreshRepos?.()).catch(e=>i(String(e.message||e))).finally(()=>m(!1)))};return(0,U.jsx)(`div`,{className:`nx-intro`,children:(0,U.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-link-main is-empty`,title:`还没有${o}——点这里写第一篇`,disabled:p,onClick:e,children:p?`新建中…`:o}),(0,U.jsx)(`span`,{className:`nx-intro-path mono`,children:`未编写`}),(0,U.jsx)(`span`,{className:`nx-intro-spacer`}),(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,disabled:p,onClick:e,children:`+ 新建`}),(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,title:`在右侧栏列出${o}的全部文章(也可以在那里新建)`,onClick:v,children:`查看详情`})]})})}return(0,U.jsx)(`div`,{className:`nx-intro`,children:(0,U.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${o}(在主内容区阅读 / 编辑)`,onClick:u,children:o}),(0,U.jsx)(`span`,{className:`nx-intro-path mono`,children:g}),(0,U.jsx)(`span`,{className:`nx-intro-spacer`}),(0,U.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`在右侧栏列出${o}的全部文章(点标题在主内容区打开,可编辑)`,onClick:v,children:[`查看详情`,_>0?` ${_}`:``]})]})})}function Z(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a,m as o,u as s}from"./popup-DLfU1TXG.js";import{D as c,N as l,a as u,c as d,f,i as p,l as m,o as h,r as g,s as _,t as v}from"./tool-bar-NHeX0Kmo.js";import{n as y}from"./app-context-DPFYOrgE.js";import{a as b,i as x,o as S}from"./md-parse-BjzYV8n7.js";import{a as C,i as w,m as T,n as E,o as D,r as O,t as k,v as ee,w as A,y as j}from"./md-history-B7TamGno.js";import{i as M,n as N,r as te,t as P}from"./use-rail-drag-4iK6t5ab.js";import{i as F,t as ne}from"./route-crumb-DS76cmRK.js";function re(){return s(`/api/docs/index`)}function ie(){return s(`/api/boards`)}function I(){return s(`/api/repos`)}function ae(){return s(`/api/docs/index`)}function oe(e){return s(`/api/docs/attachments?ref=${encodeURIComponent(e)}`)}function se(e){return s(`/api/docs/item?ref=`+encodeURIComponent(e))}function L(e){return s(`/api/repos/docs`,{method:`POST`,body:e})}function ce(e){return s(`/api/docs/unbind`,{method:`POST`,body:e})}function le(e){return s(`/api/docs/link`,{method:`POST`,body:e})}function R(e){return s(`/api/docs/bindings?ref=`+encodeURIComponent(e))}function ue(e){let t=new URLSearchParams;return e.host&&t.set(`host`,e.host),e.group&&t.set(`group`,e.group),s(`/api/docs/bindings?`+t.toString())}function de(e){return s(`/api/docs/ref`,{method:`POST`,body:e})}function fe(e){return s(`/api/docs/unbind`,{method:`POST`,body:e})}function z(e,t){return s(`/api/docs/item`,{method:`PATCH`,body:{ref:e,desc:t}})}function pe(e){return s(`/api/docs/main`,{method:`POST`,body:e})}function B(e){return s(`/api/docs/item`,{method:`PATCH`,body:e})}function me(e){return s(`/api/docs/item`,{method:`DELETE`,body:e})}var V=`nx-kv:docs-changed`;function H(){typeof window>`u`||window.dispatchEvent(new CustomEvent(V))}function he(e){if(typeof window>`u`)return()=>{};let t=()=>e();return window.addEventListener(V,t),()=>window.removeEventListener(V,t)}async function ge({owner:e,repo:t,group:n,desc:r=``,title:i=``}){let a=await de({owner:e,repo:t,group:n,desc:r});return i&&await B({ref:`ref:`+a.refId,body:`# ${i}\n\n(待补)\n`}),H(),a.refId}async function _e(e,t){let n=await z(e,String(t||``).trim());return H(),String(n?.desc??t??``)}async function ve(e){await fe({ref:e.refId,type:e.type,repo:e.repoKey,group:e.groupKey||void 0}),H()}async function ye(e){if(e.type===`group_repo`)throw Error(`组内仓库描述没有主篇概念`);await pe(e.type===`group`?{ref:e.refId,board:e.repoKey}:{ref:e.refId,repo:e.repoKey}),H()}var U=t();function be({refId:e,writable:t,onChanged:n,onOpenDoc:r}){return(0,U.jsx)(M,{host:`doc`,refId:e,allow:{file:!0,url:!0,folder:!0,task:!1,ref:!0,repo:!1},disabled:!t,disabledText:`只读文档不能添加附件。`,onChanged:n,onOpenDoc:r})}function xe({dock:t,attCount:n=0,bindCount:r=0,attachNode:i,bindNode:a}){let{dockOpen:o,dockTab:s,dockH:c,dockRef:l,dockMax:u,showDockTab:d,onDockDragStart:f,toggleDockMax:p,setDockOpen:m}=t;if(!o)return null;let h=s===`bind`?`bind`:`attach`;return(0,U.jsxs)(`div`,{className:`mdw-dock docp-dock`,ref:l,style:{height:`${c}px`},children:[(0,U.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:f,onDoubleClick:p}),(0,U.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,U.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`attach`,className:`mdw-dock-tab${h===`attach`?` is-on`:``}`,onClick:()=>d(`attach`),children:[`附件`,n?(0,U.jsx)(`span`,{className:`mdw-dock-tab-num`,children:n}):null]}),(0,U.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`bind`,className:`mdw-dock-tab${h===`bind`?` is-on`:``}`,onClick:()=>d(`bind`),children:[`归属`,r?(0,U.jsx)(`span`,{className:`mdw-dock-tab-num`,children:r}):null]})]}),(0,U.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,U.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:p,title:u?`还原面板高度`:`最大化面板高度`,"aria-label":u?`还原面板高度`:`最大化面板高度`,children:(0,U.jsx)(e,{name:u?`collapse`:`expand`,title:void 0})}),(0,U.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>m(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,U.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,U.jsxs)(`div`,{className:`mdw-dock-body`,children:[(0,U.jsx)(`div`,{className:`docp-dock-pane`,hidden:h!==`attach`,children:i}),(0,U.jsx)(`div`,{className:`docp-dock-pane`,hidden:h!==`bind`,children:a})]})]})}function Se({dock:t,attCount:n=0,bindCount:r=0}){let{dockOpen:i,dockTab:a,showDockTab:o,setDockOpen:s}=t;return(0,U.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${i&&a===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),title:`附件(点击展开信息面板)`,children:[(0,U.jsx)(e,{name:`list`,title:void 0}),(0,U.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`}),n?(0,U.jsx)(`span`,{className:`mdw-sbar-num`,children:n}):null]}),(0,U.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${i&&a===`bind`?` is-on`:``}`,onClick:()=>o(`bind`),title:`归属:这篇文档被哪些仓库 / 项目组引用(点击展开信息面板)`,children:[(0,U.jsx)(e,{name:`repo`,title:void 0}),(0,U.jsx)(`span`,{className:`mdw-sbar-lab`,children:`归属`}),r?(0,U.jsx)(`span`,{className:`mdw-sbar-num`,children:r}):null]}),(0,U.jsx)(`span`,{className:`mdw-sbar-grow`}),(0,U.jsx)(`span`,{className:`docp-sbar-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 正文存库(v6 起不落盘)`}),(0,U.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${i?` is-open`:``}`,onClick:()=>s(e=>!e),title:i?`收起信息面板`:`展开信息面板`,"aria-expanded":i,"aria-label":i?`收起信息面板`:`展开信息面板`,children:(0,U.jsx)(e,{name:`chevron`,title:void 0})})]})}var W=r(n(),1);function Ce({t:e}){let t=e.main?`主篇`:`附加`;return(0,U.jsxs)(`span`,{className:`nb-tag nb-`+e.kind+(e.main?` nb-main`:``),"data-btag":e.id,title:e.title||e.label,children:[(0,U.jsx)(`span`,{className:`k`,children:(0,U.jsx)(`span`,{className:`dot`})}),(0,U.jsx)(`span`,{className:`role`+(e.main?` main`:``),children:t}),(0,U.jsx)(`span`,{className:`name`,children:e.label}),e.onRemove?(0,U.jsx)(`button`,{type:`button`,className:`x`,title:`解绑(文档本身不删除)`,onClick:t=>{t.stopPropagation(),e.onRemove?.()},children:`✕`}):null]})}function G({items:e,addLabel:t,onAdd:n,onMore:r,empty:i}){let a=(0,W.useRef)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(0),u=(0,W.useCallback)(()=>{let e=a.current;if(!e||!e.clientWidth)return;let t=Array.from(e.querySelectorAll(`:scope > [data-btag]`));if(o){t.forEach(e=>{e.style.display=``}),l(0);return}t.forEach(e=>{e.style.display=``});let n=e.querySelector(`:scope > [data-badd]`),r=e.querySelector(`:scope > [data-bmore]`),i=(n?.offsetWidth||0)+(r?.offsetWidth||0)+6,s=e.clientWidth-(i>6?i:0)-2,c=e.getBoundingClientRect().left,u=0;for(let e of t)e.getBoundingClientRect().right-c>s&&(e.style.display=`none`,u+=1);l(u)},[o]);(0,W.useLayoutEffect)(()=>{u()},[e,u]),(0,W.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>u());return t.observe(e),()=>t.disconnect()},[u]);let d=c>0||o;return(0,U.jsxs)(`div`,{className:`nb-tags`+(o?` open`:``),ref:a,children:[e.map(e=>(0,U.jsx)(Ce,{t:e},e.id)),!e.length&&i?(0,U.jsx)(`span`,{className:`nb-empty`,children:i}):null,d&&!r?(0,U.jsx)(`button`,{type:`button`,className:`nb-tag more`,"data-bmore":!0,title:o?`收起`:`展开全部`,onClick:()=>s(e=>!e),children:o?`收起`:`+${c}`}):null,d&&r?(0,U.jsxs)(`button`,{type:`button`,className:`nb-tag more`,"data-bmore":!0,title:`查看全部`,onClick:r,children:[`+`,c||0]}):null,n?(0,U.jsxs)(`button`,{type:`button`,className:`nb-tag add`,"data-badd":!0,onClick:n,children:[(0,U.jsx)(`b`,{children:`+`}),t||`加绑`]}):null]})}function K(e){let t=String(e||``);return t.startsWith(`ref:`)?t.slice(4):/^ref_[0-9a-f]{16}$/i.test(t)?t:``}function we(e,t,n=``){let r=a(),[i,o]=(0,W.useState)([]),[s,c]=(0,W.useState)(0),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(`repo`),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(``),[C,w]=(0,W.useState)(``),E=(0,W.useCallback)(()=>c(e=>e+1),[]);(0,W.useEffect)(()=>{let e=!0;return I().then(t=>{if(!e)return;let n=(Array.isArray(t)?t:t?.repos||[]).filter(e=>e&&e.key&&(e.type||`dev`)!==`group`).map(e=>({key:String(e.key),name:String(e.name||e.key),kind:`repo`}));u(n)}).catch(()=>{}),ie().then(t=>{if(!e)return;let n=(Array.isArray(t)?t:t?.boards||[]).filter(e=>e&&(e.key||e.id)).map(e=>({key:String(e.key||`board/`+(e.name||e.id)),name:String(e.name||e.key),kind:`group`}));f(n)}).catch(()=>{}),()=>{e=!1}},[]),(0,W.useEffect)(()=>{if(!e){o([]);return}let t=!0;return R(e).then(e=>{t&&o(Array.isArray(e?.bindings)?e.bindings:[])}).catch(()=>{t&&o([])}),()=>{t=!1}},[e,s]);let D=(0,W.useCallback)(e=>{let t=l.find(t=>t.key===e)||d.find(t=>t.key===e);return t?t.name:e},[l,d]);async function O(e){if(!p&&window.confirm(`解绑:${e.repoKey} 不再引用这篇文档?\n(文档本身不删除,只摘掉这条归属)`)){m(!0);try{await ce({ref:e.refId,type:e.type,repo:e.repoKey,group:e.groupKey||void 0}),r(`已解绑`),E()}catch(e){r(`解绑失败:`+(e?.message||`未知错误`))}finally{m(!1)}}}function k(){v(`repo`),b(``),w(``),g(!0)}async function ee(){if(!y){r(`先选一个宿主`);return}let t=K(e||``);if(!t){r(`这篇文档还没有 refId(外部目录不能加绑)`);return}m(!0);try{_===`repo`?await L({id:y,ref:t}):await le({board:y,ref:t}),g(!1),r(_===`repo`?`已加绑到仓库文档集`:`已加绑到组附加文档`),E()}catch(e){r(`加绑失败:`+(e?.message||`未知错误`))}finally{m(!1)}}let A=(0,W.useMemo)(()=>i.map(e=>{let n=e.type===`group_repo`?e.groupKey:null;return{id:`${e.refId}:${e.repoKey}:${e.groupKey||``}:${e.position}`,label:n?`${D(e.repoKey)} · 组 ${D(n)}`:D(e.repoKey),kind:e.type===`group`?`group`:`repo`,main:e.main,title:`${e.repoKey}${n?` @ `+n:``}\n${e.desc||e.refId}`,onRemove:t?()=>O(e):void 0}}),[i,t,D]),j=(0,W.useMemo)(()=>T(A,x,e=>[e.label,e.title]),[A,x]),M=_===`repo`?l:d,N=(0,W.useMemo)(()=>new Set(i.filter(e=>e.type!==`group_repo`).map(e=>e.repoKey)),[i]),te=(0,W.useMemo)(()=>M.filter(e=>!N.has(e.key)),[M,N]),P=(0,W.useMemo)(()=>T(te,C,e=>[e.name,e.key]),[te,C]),ne=e?(0,U.jsxs)(`div`,{className:`docp-bind-panel`,title:`这篇文档被谁引用 —— tag 上的 ✕ 解绑(不删文档)`,children:[i.length>1?(0,U.jsx)(F,{value:x,onChange:S,placeholder:`搜索归属…`,title:`过滤归属`,count:j.length,className:`wide`}):null,(0,U.jsx)(G,{items:j,addLabel:`加绑宿主`,onAdd:t&&K(e||``)?k:void 0,empty:`没有任何归属(孤儿文档)—— 不会被任何仓库 / 组面板列出`}),!i.length&&t?(0,U.jsx)(`div`,{className:`docp-bind-orphan`,children:`孤儿状态:给这篇文档加绑一个仓库或项目组,它才会出现在对应面板的文档集里。`}):null]}):null,re=h?(0,U.jsx)(`div`,{className:`nb-overlay`,onClick:e=>{e.target===e.currentTarget&&g(!1)},children:(0,U.jsxs)(`div`,{className:`nb-modal`,children:[(0,U.jsxs)(`div`,{className:`nb-modal-head`,children:[(0,U.jsx)(`span`,{className:`t`,children:`加绑宿主`}),(0,U.jsx)(`span`,{className:`sub`,children:n||`当前文档`}),(0,U.jsx)(`button`,{type:`button`,className:`close`,onClick:()=>g(!1),children:`✕`})]}),(0,U.jsxs)(`div`,{className:`nb-modal-body`,children:[(0,U.jsxs)(`div`,{className:`nb-frow`,children:[(0,U.jsx)(`label`,{children:`宿主类型`}),(0,U.jsxs)(`div`,{className:`nb-seg`,children:[(0,U.jsx)(`button`,{type:`button`,className:_===`repo`?`on`:``,onClick:()=>{v(`repo`),b(``),w(``)},children:`仓库`}),(0,U.jsx)(`button`,{type:`button`,className:_===`group`?`on`:``,onClick:()=>{v(`group`),b(``),w(``)},children:`项目组`})]})]}),(0,U.jsxs)(`div`,{className:`nb-frow`,children:[(0,U.jsx)(`label`,{children:_===`repo`?`选择仓库`:`选择项目组`}),M.length>1?(0,U.jsx)(F,{value:C,onChange:w,placeholder:_===`repo`?`搜索仓库…`:`搜索项目组…`,title:`过滤可加绑的宿主`,count:P.length,className:`wide`}):null,(0,U.jsx)(`div`,{className:`nb-list`,children:P.length?P.map(e=>(0,U.jsxs)(`label`,{style:{fontWeight:400},children:[(0,U.jsx)(`input`,{type:`radio`,name:`nb-host`,checked:y===e.key,onChange:()=>b(e.key)}),(0,U.jsx)(`span`,{children:e.name}),(0,U.jsx)(`span`,{className:`p`,children:e.key})]},e.key)):(0,U.jsxs)(`label`,{children:[`(没有可加绑的`,_===`repo`?`仓库`:`项目组`,`)`]})})]})]}),(0,U.jsxs)(`div`,{className:`nb-modal-foot`,children:[(0,U.jsx)(`span`,{className:`note`,children:_===`repo`?`落点:repo.doc.add`:`落点:docs.link`}),(0,U.jsx)(`button`,{type:`button`,className:`nb-btn`,onClick:()=>g(!1),children:`取消`}),(0,U.jsx)(`button`,{type:`button`,className:`nb-btn primary`,disabled:p,onClick:ee,children:`加绑`})]})]})}):null;return{count:i.length,strip:ne,modal:re}}var Te=l(),q=`doc`,J=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function Ee({crumb:t=null,title:n,pathLabel:r=``,dirty:i=!1,writable:a=!1,onSave:o=null,onSaveLabel:s=`保存`,menuGroups:c=[],saving:l=!1,external:f=!1,afterTitle:y=null}){let b=p(),{layout:x,setLayout:S}=h(q),[C,w]=(0,W.useState)(!1),T={};for(let e of c||[])for(let t of e?.items||[])t&&t.id&&(T[t.id]=t);T.save=o&&{id:`save`,label:l?`保存中…`:s,run:o,primary:!0,disabled:l||!i};let E=e=>e===`more`||!!T[e],D=x.filter(e=>m(q,e)&&E(e.id)),O=x.filter(e=>_(q,e)&&E(e.id)),k=e=>{let t=T[e];t&&t.run?.(),b.setOpen(!1)},ee=t=>{if(t===`more`)return(0,U.jsx)(`div`,{className:`docp-more`,ref:b.ref,children:(0,U.jsxs)(`button`,{type:`button`,className:`btn ghost sm${b.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":b.open,onClick:e=>g(b,e,`right`),children:[(0,U.jsx)(e,{name:`dots`}),`更多`]})},`more`);let n=T[t];if(!n)return null;let r=d(q,t);return(0,U.jsxs)(`button`,{type:`button`,className:n.primary||t===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!n.disabled,onClick:()=>k(t),children:[r.icon?(0,U.jsx)(e,{name:r.icon}):null,n.label||d(q,t).label||t]},t)},A=J.map(e=>({...e,items:O.filter(t=>d(q,t.id).menuGroup===e.id)})).filter(e=>e.items.length),j=O.filter(e=>!d(q,e.id).menuGroup),M=(0,U.jsxs)(`div`,{className:`mdw-top`,children:[t,(0,U.jsxs)(`div`,{className:`mdw-head`,children:[(0,U.jsx)(`div`,{className:`mdw-title`,children:n||`文档`}),(0,U.jsxs)(`div`,{className:`mdw-path`,children:[r,i?` · 未保存`:``,f?` · 外部`:``]})]})]});return a?(0,U.jsxs)(U.Fragment,{children:[M,(0,U.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,U.jsx)(`div`,{className:`mdw-toolbar-left`,children:y}),(0,U.jsxs)(`div`,{className:`mdw-actions`,children:[D.map(e=>ee(e.id)),(0,U.jsxs)(v,{menu:b,className:`mdw-act-menu`,children:[A.map(t=>(0,U.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":t.label,children:[(0,U.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:t.label}),t.items.map(t=>{let n=T[t.id],r=d(q,t.id),i=n?.danger||r.danger;return(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(i?` danger`:``),onClick:()=>k(t.id),children:[r.icon?(0,U.jsx)(e,{name:r.icon}):null,n?.label||r.label||t.id,n?.hint?(0,U.jsx)(`span`,{className:`hint`,children:n.hint}):null]},t.id)})]},t.id)),j.map(t=>{let n=T[t.id],r=d(q,t.id);return(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?.danger||r.danger?` danger`:``),onClick:()=>k(t.id),children:[r.icon?(0,U.jsx)(e,{name:r.icon}):null,n?.label||r.label||t.id]},t.id)}),(0,U.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,U.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{b.setOpen(!1),w(!0)},children:[(0,U.jsx)(e,{name:`gear`}),`自定义工具栏…`]})]})]})]}),C&&(0,Te.createPortal)((0,U.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>w(!1),children:(0,U.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)(u,{kind:q,layout:x,setLayout:S,onClose:()=>w(!1)})})}),document.body)]}):(0,U.jsxs)(U.Fragment,{children:[M,(0,U.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,U.jsx)(`div`,{className:`mdw-toolbar-left`,children:y}),(0,U.jsx)(`div`,{className:`mdw-actions`,children:(0,U.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function De(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}function Y(e,t){return e?e.doc&&e.doc.ref?`ref:`+e.doc.ref:e.docId?e.docId:``:``}function X(e){return e?e.docId?e.docId:e.refId?`ref:`+e.refId:``:``}function Oe(e,t){return e?String(e.title||e.desc||t):t}function ke({kind:e,owner:t,model:n}){let{openByDocId:r}=$(n),i=e===`board`?`组介绍`:`项目介绍`,a=e===`board`&&t?.id||t?.key||``,o=t?.name,c=(0,W.useMemo)(()=>Y(t,e),[t,e]),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(0),h=(0,W.useCallback)(()=>m(e=>e+1),[]);(0,W.useEffect)(()=>{let t=!0;if(!a){u([]),f(``);return}let n=(e,t)=>{let n=[],r=X(e);f(r||c),r&&e&&n.push({docId:r,label:Oe(e,`主篇`),main:!0});for(let e of t){let t=X(e);t&&n.push({docId:t,label:Oe(e,`补充`),main:!1})}u(n)};return e===`repo`?s(`/api/repos/docs?id=`+encodeURIComponent(a)).then(e=>{t&&n(e?.main||null,e?.links||[])}).catch(()=>{t&&(u([]),f(c))}):s(`/api/boards/`+encodeURIComponent(String(a))).then(e=>{t&&n(e?.introMain||null,e?.introExtras||[])}).catch(()=>{t&&(u([]),f(c))}),()=>{t=!1}},[e,a,c,p]);let g=(0,W.useMemo)(()=>e===`repo`&&a?{repoKey:a}:e===`board`&&a?{boardKey:a,boardName:o||``}:{},[e,a,o]);return{kind:e,label:i,ownerKey:a,docRef:c,mainDocId:d,links:l,openMain:(0,W.useCallback)(()=>{let e=d||c;e&&r(e,null,g)},[d,c,r,g]),openDoc:(0,W.useCallback)(e=>r(e,null,g),[r,g]),createMain:(0,W.useCallback)(async()=>{if(!a)return;let t=`ref:`+await ge({owner:e===`board`?`group`:`repo`,...e===`board`?{group:a}:{repo:a},title:o||i});f(t),u([{docId:t,label:o||i,main:!0}]),r(t,null,g)},[e,a,o,i,r,g]),reload:h,canEdit:!!d||!!c}}function Ae(e){return e<=1?18:e===2?12:8}function je({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),{railRef:u,pos:d,dragging:f,draggedRef:p,handleProps:m}=P(N),h=(0,W.useMemo)(()=>e||[],[e]),g=(0,W.useMemo)(()=>n||[],[n]);(0,W.useEffect)(()=>{let e=t;if(!e||!h.length)return;let n=()=>h.map(t=>{let n=e.querySelector(`#${CSS.escape(t.id)}`);if(!n)return null;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{id:t.id,y:r.top-i.top}}).filter(e=>!!e),r=()=>{let e=n();if(!e.length)return;let t=e[0].id;for(let n of e)n.y<=28&&(t=n.id);l(t)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[t,h]);let _=(0,W.useCallback)(e=>{let n=t;if(!n)return;let r=n.querySelector(`#${CSS.escape(e)}`);if(!r){n.scrollTo({top:0,behavior:`smooth`}),l(e);return}r.scrollIntoView({behavior:`smooth`,block:`start`}),l(e)},[t]);return!h.length&&!g.length&&!a?null:(0,U.jsxs)(`aside`,{ref:u,className:`doc-rail`+(o?` open`:``)+(f?` dragging`:``),style:d?{left:d.x,top:d.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`文档目录`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录(按住拖动 · 双击回默认位)`:`展开目录 · 按住拖动 · 双击回默认位`,"aria-expanded":o,onClick:()=>{if(p.current){p.current=!1;return}s(e=>!e)},...m,children:[(0,U.jsx)(`span`,{}),(0,U.jsx)(`span`,{}),(0,U.jsx)(`span`,{})]}),(0,U.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:h.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${Ae(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>_(e.id)},e.id))}),o&&(0,U.jsxs)(`div`,{className:`doc-rail-panel`,children:[h.length>0&&(0,U.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,U.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),h.map(e=>(0,U.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>_(e.id),children:e.text},e.id))]}),(g.length>0||a)&&(0,U.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,U.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),g.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,U.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function Me({kind:e,owner:t,model:n}){let r=y(),i=a(),{label:o,docRef:s,mainDocId:c,links:l,openMain:u,createMain:d}=ke({kind:e,owner:t,model:n}),[p,m]=(0,W.useState)(!1);if(!t)return null;let h=!!(s||c),g=l.find(e=>e.main)?.label||`文档库`,_=l.filter(e=>!e.main).length,v=()=>{let i=n||r.model;i&&f(i,{component:`refs`,name:`文档列表`,config:e===`repo`?{repoKey:t.key||``}:{boardKey:t.id||t.key||``,boardName:t.name||``},location:`right`})};if(!h){let e=()=>{p||(m(!0),d().then(()=>r.refreshRepos?.()).catch(e=>i(String(e.message||e))).finally(()=>m(!1)))};return(0,U.jsx)(`div`,{className:`nx-intro`,children:(0,U.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-link-main is-empty`,title:`还没有${o}——点这里写第一篇`,disabled:p,onClick:e,children:p?`新建中…`:o}),(0,U.jsx)(`span`,{className:`nx-intro-path mono`,children:`未编写`}),(0,U.jsx)(`span`,{className:`nx-intro-spacer`}),(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,disabled:p,onClick:e,children:`+ 新建`}),(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,title:`在右侧栏列出${o}的全部文章(也可以在那里新建)`,onClick:v,children:`查看详情`})]})})}return(0,U.jsx)(`div`,{className:`nx-intro`,children:(0,U.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,U.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${o}(在主内容区阅读 / 编辑)`,onClick:u,children:o}),(0,U.jsx)(`span`,{className:`nx-intro-path mono`,children:g}),(0,U.jsx)(`span`,{className:`nx-intro-spacer`}),(0,U.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`在右侧栏列出${o}的全部文章(点标题在主内容区打开,可编辑)`,onClick:v,children:[`查看详情`,_>0?` ${_}`:``]})]})})}function Z(e){let t=String(e??``).replace(/^/,``).replace(/\r\n/g,`
|
|
2
2
|
`),n=t.match(/^---\n([\s\S]*?)\n---\n?/),r=n?t.slice(n[0].length):t;for(let e of r.split(`
|
|
3
3
|
`)){let t=e.trim();if(t)return t}return``}function Q(e){let t=Z(e).match(/^#\s+(.+)$/);return t?(t[1]??``).trim():``}function Ne(e,t){let n=String(e??``),r=String(t||``).trim()||`未命名文档`,i=n.replace(/\r\n/g,`
|
|
4
4
|
`),a=i.match(/^---\n([\s\S]*?)\n---\n?/),o=a?i.slice(0,a[0].length):``,s=(a?i.slice(a[0].length):i).split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,i as r,l as i,n as a}from"./popup-DLfU1TXG.js";import{f as o}from"./tool-bar-NHeX0Kmo.js";import{n as s}from"./app-context-DPFYOrgE.js";import{a as c}from"./board-view-jt8QixVg.js";import{r as ee}from"./doc-
|
|
1
|
+
import{d as e,f as t,h as n,i as r,l as i,n as a}from"./popup-DLfU1TXG.js";import{f as o}from"./tool-bar-NHeX0Kmo.js";import{n as s}from"./app-context-DPFYOrgE.js";import{a as c}from"./board-view-jt8QixVg.js";import{r as ee}from"./doc-zDLeR8PE.js";import{t as te}from"./route-crumb-DS76cmRK.js";import{S as ne,d as l,f as re,h as ie,u,v as d,x as f}from"./index-Di6ErKBG.js";import{h as p,s as m}from"./reopen-text-D0eQ2XAC.js";import{a as h,c as g,d as _,f as v,i as y,l as b,n as ae,o as x,r as oe,s as se,t as ce,u as le}from"./task-ops-s9kkuLcK.js";import{t as ue}from"./template-preview-EM3OQ1Rc.js";import{n as de}from"./manage-session-CuaL7QqQ.js";import{t as fe}from"./group-project-memo-G-O6sPRw.js";import{t as pe}from"./member-picker-BtWykPer.js";var S=n(t(),1),C=e(),w=10;function T({x:e,y:t,members:n,repos:r,onPick:i,onClose:o}){let s=(0,S.useMemo)(()=>new Map(r.map(e=>[e.key,e])),[r]),c=n.map(e=>({m:e,repo:s.get(e.key)||null})).filter(e=>!!(e.repo&&e.repo.id)).map(({m:e,repo:t})=>{let n=t.getLoop&&typeof t.getLoop==`object`?t.getLoop:null,r=!!(n&&n.enabled),a=n?n.waitMinutes:void 0,o=a==null?w:Number(a);return{label:`${e.name} · ${r?`开(${o} 分钟)`:`关`}`,icon:r?`check`:`refresh`,onClick:()=>i(t)}});return(0,C.jsx)(a,{x:e,y:t,items:c,onClose:o})}function E({dirKey:e,rows:t,repoData:n,model:a}){let w=i(),E=s(),{dialog:D,node:O}=r(),k=u(),A=n&&n.boards||[],j=n&&n.repos||[],M=t||[],[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(null),[z,B]=(0,S.useState)(null),V=(0,S.useMemo)(()=>A.find(t=>t.id===e)||A.find(t=>t.key===e)||null,[A,e]),H=(0,S.useMemo)(()=>{if(!V)return[];let e=new Map(j.map(e=>[e.key,e])),t=new Map;for(let e of M)e.repo&&e.repo.key&&(t.has(e.repo.key)||t.set(e.repo.key,e));return(V.repos||[]).map(n=>{let r=e.get(n.key)||null,i=t.get(n.key)||null;return{key:n.key,name:n.name||r&&r.name||n.key,path:n.path||r&&r.path||``,cwd:i&&i.cwd||n.path||r&&r.path||``,desc:r&&r.desc||``,pending:i&&i.pending||0,waiting:!!(i&&i.waiting),topicKey:i?i.key:``,summary:i&&i.summary||``,tasks:i&&i.tasks||[],present:n.present!==!1,noteDocId:n.noteDocId||``}})},[V,j,M]),U=(0,S.useMemo)(()=>{let e=new Map;for(let t of M){if(!t.key)continue;let n=(t.tasks||[]).filter(e=>e&&!e.deletedAt&&!e.migratedTo&&e.status===`pending`),r={};n.forEach((e,t)=>{e.blocksFollowing&&(r[e.id]=n.slice(t+1).map(e=>e.id))}),e.set(t.key,{tasks:n,downstream:r})}return e},[M]),W=(0,S.useMemo)(()=>{let e=V?[V.id,V.key,V.name].filter(Boolean):[],t=[];for(let n of H)for(let r of n.tasks||[]){if(r.deletedAt)continue;let i=String(r.boardKey||``);i&&e.includes(i)&&t.push({member:n,task:r})}let n=new Map;return c(t.map(e=>e.task)).forEach((e,t)=>n.set(e,t)),t.sort((e,t)=>(n.get(e.task)??0)-(n.get(t.task)??0))},[V,H]),me=(e,t)=>e.key+`:`+t.id,G=(0,S.useMemo)(()=>{let e=new Map;for(let{member:t,task:n}of W){let r=me(t,n);e.set(r,{member:t,task:n,row:{key:r,task:n,projectTag:t.name,projectTitle:`归属项目:${t.name}`,showTimes:!0,movable:n.status===`pending`&&!!t.topicKey,downs:U.get(t.topicKey)?.downstream[n.id]||[]}})}return e},[W,U]),he=(0,S.useMemo)(()=>[...G.values()].map(e=>e.row),[G]),ge=fe(V?V.id:``),K=H.find(e=>e.key===ge)||H.find(e=>e.pending>0)||H[0]||null,q={dialog:D,toast:w,refresh:()=>E.refreshLocal?.(),docKey:V?.id||``},J=e=>{let t=G.get(e),n=t?t.member.cwd||t.member.path:``;return n?{cwd:n}:null},Y=e=>{let t=new Map;for(let n of e){let e=J(n.key);e&&t.set(e.cwd,[...t.get(e.cwd)||[],Number(n.task.id)])}return[...t.entries()].map(([e,t])=>({scope:{cwd:e},ids:t}))},X=e=>{if(!V)return;if(!K)return w(`这个组还没有成员——先「添加成员」,再建任务`);let t=e||(k?.templates||[]).find(e=>e.id===k.defaultId)||null;if(t&&le(t,{topic:K.topicKey||``,group:V.key||``,repo:K.key||``,groupId:V.id,board:V.id,project:K.key},E))return;let n=d(),r=ie(ne(V.id),n);f(r,{title:``,body:ue(e||k.defaultPick()),boardKey:V.id,projectKey:K.key}),E.openPage?.({groupId:V.id,task:n,name:`新任务`})},_e=async e=>{if(!V)return;if(!K)return w(`这个组还没有成员——先「添加成员」,再导入`);let t=await e.text(),n=e.name.replace(/\.md$/i,``),r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`;try{let t=await m({board:V.id,project:K.key,text:r});w(`已导入:${e.name}`),await E.refreshLocal?.();let n=t?.task?.id??t?.id;n!=null&&E.openPage?.({groupId:V.id,task:String(n),name:`#${n}`})}catch(e){w(String(e.message||e))}},Z=l({topic:K?K.topicKey:``,group:V?V.key:``,repo:K?K.key:``}).templates||k.templates||[],ve=()=>{V&&a&&re(a,{mode:`new`,scope:[`group:${V.key}`],name:``})},ye=()=>{if(!V)return;let e=de({topic:K?K.topicKey:``,group:V.key||``,repo:K?K.key:``,label:V.name||V.key});E.onNavigate?.(`#/templates/manage/${e}`)},be=[...Z.length?Z.map(e=>({label:(e.id===k.defaultId?`✓ `:``)+e.name,icon:`list`,onClick:()=>X(e.fallback?null:e)})):[{label:`按默认模板新建一页`,icon:`list`,onClick:()=>X()}],`sep`,{label:`为本组新建模板…`,icon:`plus`,onClick:ve},{label:`管理模板…`,icon:`gear`,onClick:ye}];if(!V)return(0,C.jsxs)(`div`,{className:`rp-page`,children:[(0,C.jsx)(te,{}),(0,C.jsx)(`div`,{className:`rp-empty`,children:`项目组不存在(看板可能被删了)`})]});let Q=z?G.get(z.rowKey):null,$=Q&&U.get(Q.member.topicKey)?.tasks||[];return(0,C.jsx)(C.Fragment,{children:(0,C.jsx)(b,{kind:`group`,name:V.name,title:`本组任务`,intro:(0,C.jsx)(ee,{kind:`board`,owner:V,model:a}),rows:he,extraCounts:[`${H.length} 个目录`],emptyText:`本组还没有任务——点「+ 新建页」创建;只有在本组创建的任务(携带本组语义)才会出现在这里。`,tplMenuItems:be,onNew:()=>X(),newDisabled:!K,onOpenRow:e=>E.openPage?.({groupId:V.id,task:String(e.task.id),name:`#${e.task.id}`}),onMoveRow:(e,t,n)=>{let r=G.get(e.key),i=G.get(t.key);if(!r||!i)return;if(r.member.topicKey!==i.member.topicKey){w(`只能在同一项目队列内排序(跨项目请用编排连线)`);return}let a=r.member.cwd||r.member.path;if(!r.member.topicKey||!a){w(`该成员还没有本地队列,无法排序`);return}p({cwd:a,id:Number(r.task.id),...n===`before`?{beforeId:Number(i.task.id)}:{afterId:Number(i.task.id)}}).then(()=>E.refreshLocal?.()).catch(e=>w(String(e.message||e)))},onImportFile:e=>void _e(e),onTogglePlan:(e,t)=>{let n=new Map;for(let t of e){let e=J(t.key);e&&n.set(e.cwd,[...n.get(e.cwd)||[],t.task.id])}x(q,[...n.entries()].map(([e,t])=>({scope:{cwd:e},ids:t})),t)},onOpenDag:e=>B({rowKey:e.key}),onToggleGate:e=>{let t=J(e.key);t&&se(q,t,e.task)},onFeedback:e=>{let t=J(e.key);t&&h(q,t,e.task)},onDeleteRow:e=>{let t=J(e.key);t&&y(q,t,e.task)},onDeleteRows:e=>oe(q,Y(e)),onCancelRows:e=>ce(q,Y(e)),onCompleteRows:e=>ae(q,Y(e)),toolActs:{titles:{progress:`打开本组的任务进程面板`,addMember:`挑项目加进这个组`,orch:`打开可视化编排面板`,refs:`查看文档 / reference 列表`,getloop:`按成员项目配置持续 get(选一个项目去开/关)`},disabled:{new:!K,import:!K},actions:{progress:()=>{a&&o(a,{component:`progress`,name:`进程`,config:{groupKey:e},location:`right`})},addMember:()=>P(!0),orch:()=>{a&&o(a,{component:`dag`,name:`编排`,config:{dirKey:K&&K.topicKey||``,groupId:V.id}})},refs:()=>{a&&o(a,{component:`refs`,name:`文档列表`,config:{boardKey:e,boardName:V.name},location:`right`})},getloop:e=>{if(!H.some(e=>{let t=j.find(t=>t.key===e.key);return!!(t&&t.id)})){w(`这个组还没有已登记本机的成员项目——先「添加成员」,持续 get 按项目配置`);return}e&&I({x:e.clientX,y:e.clientY})}}},actionExtra:(0,C.jsxs)(C.Fragment,{children:[F&&!L&&(0,C.jsx)(T,{x:F.x,y:F.y,members:H,repos:j,onPick:e=>{I(null),R(e)},onClose:()=>I(null)}),L&&(0,C.jsx)(v,{repo:L,onClose:()=>R(null),onSaved:()=>E.refreshRepos&&E.refreshRepos()})]}),extra:(0,C.jsxs)(C.Fragment,{children:[Q&&(0,C.jsx)(_,{task:Q.task,tasks:$,onClose:()=>B(null),onSave:e=>{let t=J(Q.row.key);return t?g(q,t,e):Promise.resolve()}}),N?(0,C.jsx)(pe,{board:V,boards:A,repos:j,onClose:()=>P(!1),onChanged:()=>E.refreshRepos&&E.refreshRepos()}):null,O]})})})}export{E as default};
|