nx-kv 0.42.2 → 0.42.3
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 +11 -0
- package/package.json +1 -1
- package/src/web/frontend/components/task-panel/index.jsx +7 -25
- package/src/web/frontend/page/dir/landing.jsx +3 -3
- package/src/web/frontend/page/group/index.jsx +55 -49
- package/src/web/public/assets/{Introduction-CdC8MBfL.js → Introduction--ILYt-bQ.js} +1 -1
- package/src/web/public/assets/{bar-yESbzCxC.js → bar-C0LZwZoX.js} +1 -1
- package/src/web/public/assets/{cloud-BotRQcvf.js → cloud-ol3se4zn.js} +1 -1
- package/src/web/public/assets/{composer-panel-Xru2qIma.js → composer-panel-O04Eac_2.js} +1 -1
- package/src/web/public/assets/{dir-D4Q3L20K.js → dir-B_HW1kpE.js} +4 -4
- package/src/web/public/assets/group-BCOXDlvk.js +1 -0
- package/src/web/public/assets/{index-BrAIkzFc.js → index-BAS6Qpjs.js} +2 -2
- package/src/web/public/assets/{md-history-DB5forf2.js → md-history-DCgN2zcc.js} +1 -1
- package/src/web/public/assets/{overview-J1mQpmJt.js → overview-CIeUo4At.js} +1 -1
- package/src/web/public/assets/{refs-FI1FMoGi.js → refs-BpET-Lxl.js} +1 -1
- package/src/web/public/assets/{repos-Oaycnb4I.js → repos-K67Ie07A.js} +1 -1
- package/src/web/public/assets/{route-crumb-C8JzPIax.js → route-crumb-B7T_Hupr.js} +1 -1
- package/src/web/public/assets/{settings-D5wTGhPD.js → settings-Bek4c_r_.js} +1 -1
- package/src/web/public/assets/{status-tag-BoUoKYZK.js → status-tag-B7CrVhQP.js} +1 -1
- package/src/web/public/assets/{task-BgubFzHT.js → task-DHca1uMu.js} +1 -1
- package/src/web/public/assets/task-row-W12GJMCO.js +1 -0
- package/src/web/public/assets/{templates-6DQdUpiB.js → templates-6moKn9GB.js} +1 -1
- package/src/web/public/assets/{tool-bar-DGCwnUcn.js → tool-bar-CDUi6q4z.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/group-Csco0TYH.js +0 -1
- package/src/web/public/assets/task-row-Bc6JBfrE.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录对外可见的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。
|
|
4
4
|
|
|
5
|
+
## [0.42.3] - 2026-11-10 组任务面板分页 + 两页彻底同构
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **组任务列表加分页(#164 三轮验收)**:「本组任务」面板改用与目录任务页同一套
|
|
10
|
+
分页(每页 20 条,待领取在前、历史按领取时间倒序在后混排当前页,底部翻页条);
|
|
11
|
+
原「已领取」折叠段被分页取代而移除。至此两页任务面板完全同构:同头部结构、
|
|
12
|
+
同工具区对齐、同面板容器、同分页口径。
|
|
13
|
+
- **两页顶部结构对齐**:目录任务页去掉面包屑条(组页没有;返回导航走左侧树);
|
|
14
|
+
计数 chip 措辞统一为「待领取 N」。
|
|
15
|
+
|
|
5
16
|
## [0.42.2] - 2026-11-10 目录页外壳与项目组页对齐
|
|
6
17
|
|
|
7
18
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// 共享任务面板容器(#164):rp-tasks 卡片框 +
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// 全选入口走 headerExtra。
|
|
1
|
+
// 共享任务面板容器(#164/#167):rp-tasks 卡片框 + 头部(图标 + 标题 + 待领取计数
|
|
2
|
+
// + 可选附加件)+ 行列表 + 空态。group 与 dir 两页同构:列表分页由调用方
|
|
3
|
+
// (usePager + 底部 Pager)负责,本组件只画当前页的行——旧的「历史折叠段」
|
|
4
|
+
// 已被分页取代(#167 三轮验收:group 列表加分页)。
|
|
6
5
|
import { Icon } from '../icons.jsx';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -10,45 +9,28 @@ import { Icon } from '../icons.jsx';
|
|
|
10
9
|
* @param {object} props
|
|
11
10
|
* @param {string} [props.icon] 头部图标(缺省 list)
|
|
12
11
|
* @param {string} props.title 面板标题(如「本组任务」/「任务」)
|
|
13
|
-
* @param {number} [props.pendingCount] 待领取数(头部 chip
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {React.ReactNode} [props.headerExtra] 头部右侧附加件(如「全选本页」)
|
|
16
|
-
* @param {boolean} [props.historyOpen] 历史段展开态
|
|
17
|
-
* @param {Function} [props.onToggleHistory] 折叠开关
|
|
12
|
+
* @param {number} [props.pendingCount] 待领取数(头部 chip;0 不显示)
|
|
13
|
+
* @param {React.ReactNode} [props.headerExtra] 头部右侧附加件(如 dir 的「全选本页」)
|
|
18
14
|
* @param {React.ReactNode} props.children 行列表(null 时显示 emptyText)
|
|
19
15
|
* @param {string} [props.emptyText] 空态文案
|
|
20
|
-
* @param {React.ReactNode} [props.history] 历史段行(展开时渲染)
|
|
21
16
|
*/
|
|
22
17
|
export default function TaskPanel({
|
|
23
18
|
icon = 'list',
|
|
24
19
|
title,
|
|
25
20
|
pendingCount = 0,
|
|
26
|
-
historyCount = 0,
|
|
27
21
|
headerExtra = null,
|
|
28
|
-
historyOpen = false,
|
|
29
|
-
onToggleHistory,
|
|
30
22
|
children = null,
|
|
31
23
|
emptyText = '',
|
|
32
|
-
history = null,
|
|
33
24
|
}) {
|
|
34
25
|
return (
|
|
35
26
|
<div className="rp-tasks">
|
|
36
27
|
<div className="rp-tasks-h">
|
|
37
28
|
<Icon name={icon} size={13} /> {title}
|
|
38
|
-
<span className="rp-chip-count"
|
|
39
|
-
{historyCount > 0 && <span className="rp-chip-count">已领取 {historyCount}</span>}
|
|
29
|
+
{pendingCount > 0 && <span className="rp-chip-count">待领取 {pendingCount}</span>}
|
|
40
30
|
{headerExtra}
|
|
41
31
|
</div>
|
|
42
32
|
{children}
|
|
43
33
|
{!children && emptyText ? <div className="rp-proj-none muted">{emptyText}</div> : null}
|
|
44
|
-
{historyCount > 0 && (
|
|
45
|
-
<>
|
|
46
|
-
<button type="button" className="rp-done-toggle" onClick={onToggleHistory}>
|
|
47
|
-
<span className={'tri' + (historyOpen ? ' open' : '')}>▸</span> 已领取 {historyCount}
|
|
48
|
-
</button>
|
|
49
|
-
{historyOpen && history}
|
|
50
|
-
</>
|
|
51
|
-
)}
|
|
52
34
|
</div>
|
|
53
35
|
);
|
|
54
36
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 以组面板行结构为准)——待领取行拖动排序(拖把手)、行尾操作(编排菜单 /
|
|
6
6
|
// 反馈 / 删除)、多选批量条、状态统一为 StatusTag 全称药丸(原单字徽标
|
|
7
7
|
// 等/跑/完/档 收口)。分页与计数由容器(page/dir/index.jsx)算好传进来。
|
|
8
|
-
|
|
8
|
+
// #167 三轮:去面包屑(group 页没有,返回导航走左侧树)。
|
|
9
9
|
import { useEffect, useRef, useState } from 'react';
|
|
10
10
|
import { Icon } from '../../components/icons.jsx';
|
|
11
11
|
import Introduction from '../../components/Introduction/index.jsx';
|
|
@@ -137,14 +137,14 @@ export default function Landing({
|
|
|
137
137
|
return (
|
|
138
138
|
// 根容器与项目组页同款(rp-page:无底色差、同内距、flex gap)——#164 验收反馈
|
|
139
139
|
// 「两种 ui 仍然不一,比如工具区、背景等」:外壳向 group 页看齐。
|
|
140
|
+
// #167 三轮:去面包屑(group 页没有;返回导航走左侧树,两页顶部结构一致)。
|
|
140
141
|
<div className="rp-page">
|
|
141
|
-
<RouteBreadcrumb />
|
|
142
142
|
{/* 头部 = group 同构:h2(图标 + 名字 + 计数 chips)+ 右对齐工具区 */}
|
|
143
143
|
<div className="rp-group-head">
|
|
144
144
|
<h2>
|
|
145
145
|
<Icon name="folder" size={15} /> {name}
|
|
146
146
|
<span className="rp-chip-count">{taskCount} 个任务</span>
|
|
147
|
-
{pendingCount > 0 ? <span className="rp-chip-count"
|
|
147
|
+
{pendingCount > 0 ? <span className="rp-chip-count">待领取 {pendingCount}</span> : null}
|
|
148
148
|
</h2>
|
|
149
149
|
<div className="rp-group-acts">
|
|
150
150
|
{/* #139:工具区可编排(顺序 / 显隐;隐藏收入「更多」) */}
|
|
@@ -17,6 +17,7 @@ import Introduction from '../../components/Introduction/index.jsx';
|
|
|
17
17
|
import MemberPicker from '../../components/board/member-picker.jsx';
|
|
18
18
|
import TaskPanel from '../../components/task-panel/index.jsx';
|
|
19
19
|
import TaskRow from '../../components/task-panel/task-row.jsx';
|
|
20
|
+
import Pager, { usePager } from '../../components/pager.jsx';
|
|
20
21
|
import { useApp } from '../../app-context.jsx';
|
|
21
22
|
import { api } from '../../api/client.js';
|
|
22
23
|
import { openPanel } from '../../workspace.js';
|
|
@@ -28,6 +29,9 @@ import { NEW_TEMPLATE_VALUES, parseFrontmatter, withFrontmatter } from '../../mo
|
|
|
28
29
|
import { renderTemplateBody } from '../../modules/prompts/placeholders.js';
|
|
29
30
|
import { useTemplates, useTemplatesFor } from '../../modules/md/use-templates.js';
|
|
30
31
|
|
|
32
|
+
// 本组任务列表页大小:与目录任务页同值——两页面板同构(#167 三轮)
|
|
33
|
+
const PAGE_SIZE = 20;
|
|
34
|
+
|
|
31
35
|
export default function GroupView({ dirKey, rows, repoData, model }) {
|
|
32
36
|
const toast = useToast();
|
|
33
37
|
const { node: dialogNode } = useDialog();
|
|
@@ -36,9 +40,7 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
|
|
|
36
40
|
const boards = (repoData && repoData.boards) || [];
|
|
37
41
|
const repos = (repoData && repoData.repos) || [];
|
|
38
42
|
const topics = rows || [];
|
|
39
|
-
//
|
|
40
|
-
// 已领取历史折叠态
|
|
41
|
-
const [showDone, setShowDone] = useState(false);
|
|
43
|
+
// 已领取历史折叠态:#167 三轮起被分页取代(列表进 usePager,历史行混排在页内)
|
|
42
44
|
// 「添加成员」就地弹窗(不跳仓库管理页——组面板里就地改归属)
|
|
43
45
|
const [addOpen, setAddOpen] = useState(false);
|
|
44
46
|
// 「+ 新增任务 ▾」(#131/#132):点击开合;portal + fixed 防组页矮容器裁切出滚动条。
|
|
@@ -161,7 +163,8 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
|
|
|
161
163
|
null;
|
|
162
164
|
|
|
163
165
|
// 本组任务 = 成员队列里**正文 frontmatter.board 指向本组**的任务。
|
|
164
|
-
//
|
|
166
|
+
// 展示序列与目录页同构(#167 三轮):待领取在前(各成员队列序),历史在后
|
|
167
|
+
// (领取时间倒序)——整条序列进 usePager 分页,两页面板完全一致。
|
|
165
168
|
const groupTasks = useMemo(() => {
|
|
166
169
|
const ids = board ? [board.id, board.key, board.name].filter(Boolean) : [];
|
|
167
170
|
const pend = [];
|
|
@@ -174,8 +177,13 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
|
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
179
|
done.sort((a, b) => String(b.task.consumedAt || '').localeCompare(String(a.task.consumedAt || '')));
|
|
177
|
-
return
|
|
180
|
+
return [...pend, ...done];
|
|
178
181
|
}, [board, items]);
|
|
182
|
+
const groupPendingCount = useMemo(
|
|
183
|
+
() => groupTasks.filter((x) => x.task.status === 'pending').length,
|
|
184
|
+
[groupTasks]
|
|
185
|
+
);
|
|
186
|
+
const pager = usePager(groupTasks, PAGE_SIZE);
|
|
179
187
|
|
|
180
188
|
// 待领取拖动排序(同目录页 HTML5 DnD;落点须同 topic)
|
|
181
189
|
const dragRef = useRef(null); // { id, topicKey, cwd }
|
|
@@ -446,63 +454,61 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
|
|
|
446
454
|
<Introduction kind="board" owner={board} model={model} />
|
|
447
455
|
|
|
448
456
|
{/* 首屏:本组任务面板——只列 frontmatter.board 指向本组的任务,项目 tag 标归属。
|
|
449
|
-
#164:面板外壳与任务行抽到 components/task-panel
|
|
450
|
-
|
|
457
|
+
#164:面板外壳与任务行抽到 components/task-panel(与目录任务页共用);
|
|
458
|
+
#167 三轮:列表进 usePager 分页(待领取在前、历史在后混排当前页),
|
|
459
|
+
与目录页完全同构,历史行走 history 样式 + StatusTag 真实状态。 */}
|
|
451
460
|
<TaskPanel
|
|
452
461
|
title="本组任务"
|
|
453
|
-
pendingCount={
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
462
|
+
pendingCount={groupPendingCount}
|
|
463
|
+
emptyText="本组还没有任务——点「+ 新增任务」创建;只有在本组创建的任务(携带本组语义)才会出现在这里。"
|
|
464
|
+
>
|
|
465
|
+
{pager.items.map(({ member, task }) => {
|
|
466
|
+
const isPending = task.status === 'pending';
|
|
467
|
+
const dagInfo = dagByTopic.get(member.topicKey);
|
|
468
|
+
const downs = (dagInfo && dagInfo.downstream[task.id]) || [];
|
|
469
|
+
const rk = rowKey(member, task);
|
|
470
|
+
return (
|
|
471
|
+
<TaskRow
|
|
472
|
+
key={rk}
|
|
473
|
+
t={task}
|
|
474
|
+
projectTag={member.name}
|
|
475
|
+
history={!isPending}
|
|
476
|
+
draggable={isPending && !!member.topicKey}
|
|
477
|
+
dragHandlers={
|
|
478
|
+
isPending && member.topicKey
|
|
479
|
+
? {
|
|
471
480
|
onDragStart: (e) => onDragStart(e, member, task),
|
|
472
481
|
onDragOver: (e) => onDragOver(e, member, task),
|
|
473
482
|
onDragLeave: onDragLeave,
|
|
474
483
|
onDrop: (e) => onDrop(e, member, task),
|
|
475
484
|
onDragEnd: onDragEnd,
|
|
476
|
-
}}
|
|
477
|
-
dragVisual={{
|
|
478
|
-
dragging: dragId === rk,
|
|
479
|
-
drop: dropAt && dropAt.key === rk ? dropAt.zone : null,
|
|
480
|
-
}}
|
|
481
|
-
downs={downs}
|
|
482
|
-
onOpen={() =>
|
|
483
|
-
app.openPage &&
|
|
484
|
-
app.openPage({ groupId: board.id, task: String(task.id), name: `#${task.id}` })
|
|
485
485
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
<TaskRow
|
|
494
|
-
key={member.key + ':' + task.id}
|
|
495
|
-
t={task}
|
|
496
|
-
projectTag={member.name}
|
|
497
|
-
history
|
|
486
|
+
: null
|
|
487
|
+
}
|
|
488
|
+
dragVisual={{
|
|
489
|
+
dragging: dragId === rk,
|
|
490
|
+
drop: dropAt && dropAt.key === rk ? dropAt.zone : null,
|
|
491
|
+
}}
|
|
492
|
+
downs={downs}
|
|
498
493
|
onOpen={() =>
|
|
499
494
|
app.openPage &&
|
|
500
495
|
app.openPage({ groupId: board.id, task: String(task.id), name: `#${task.id}` })
|
|
501
496
|
}
|
|
502
497
|
/>
|
|
503
|
-
)
|
|
504
|
-
}
|
|
505
|
-
|
|
498
|
+
);
|
|
499
|
+
})}
|
|
500
|
+
</TaskPanel>
|
|
501
|
+
|
|
502
|
+
{/* 翻页条:与目录任务页同款(#167 三轮:group 列表加分页) */}
|
|
503
|
+
<div className="mdw-land-pager">
|
|
504
|
+
<Pager
|
|
505
|
+
page={pager.page}
|
|
506
|
+
pageCount={pager.pageCount}
|
|
507
|
+
total={pager.total}
|
|
508
|
+
onPage={pager.setPage}
|
|
509
|
+
unit="个任务"
|
|
510
|
+
/>
|
|
511
|
+
</div>
|
|
506
512
|
|
|
507
513
|
{/* 添加成员:就地弹窗(项目 + 项目组,可搜索) */}
|
|
508
514
|
{addOpen && board ? (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-DB5forf2.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{a as w,r as ee}from"./md-parse-awNLHAzO.js";import{t as T}from"./route-crumb-C8JzPIax.js";import{a as E,c as D,i as O,l as k,o as A,r as j,s as M,t as N,u as te}from"./tool-bar-DGCwnUcn.js";var P=s(e(),1),F=u(),I=t(),L=`doc`,R=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function ne({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=O(),{layout:f,setLayout:p}=A(L),[m,h]=(0,P.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>k(L,e)&&_(e.id)),y=f.filter(e=>M(L,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,I.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>j(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,I.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||D(L,e).label||e},e):null},S=R.map(e=>({...e,items:y.filter(t=>D(L,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!D(L,e.id).menuGroup);return i?(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,I.jsxs)(N,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,I.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||D(L,e.id).danger;return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||D(L,e.id).label||e.id,t?.hint?(0,I.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||D(L,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||D(L,e.id).label||e.id},e.id)}),(0,I.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,F.createPortal)((0,I.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,I.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(E,{kind:L,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsx)(`div`,{className:`docp-actions`,children:(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function z(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}var B=o({default:()=>H,useWikiNav:()=>V});function V(e){let t=d()||{},n=a(),i=e||t.model,o=(0,P.useRef)(null),s=(0,P.useCallback)(async()=>{if(!o.current)try{o.current=(await r(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),l=(0,P.useCallback)(async(e,t,n={})=>{let r=(t||await s()).find(t=>t.docId===e);c(i,{component:`doc`,name:r?r.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[i,s]),u=(0,P.useCallback)(async e=>{let t=await s(),r=x(e,t);if(r&&r.docId)return l(r.docId,t);if(r&&r.candidates)return n(`「${e}」同名文档多份:${r.candidates.join(`、`)}`);n(`未找到「${e}」——可用 nx-kv docs add <rel> 创建`)},[s,l,n]);return{nav:u,onClick:(0,P.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),u(t.getAttribute(`data-wl`)))},[u]),ensureIndex:s,openByDocId:l}}function H({docId:e,repoKey:t,boardKey:i,boardName:o,model:s,tabId:u}){let d=a(),{dialog:x,node:E}=n(),D=(0,P.useRef)(new Map),O=(0,P.useRef)(null),k=(0,P.useRef)(null),{onClick:A,openByDocId:j}=V(s),M=t?`repo`:i?`board`:``,N=t||i||``,F=(0,P.useMemo)(()=>t?{repoKey:t}:i?{boardKey:i,boardName:o||``}:{},[t,i,o]),[L,R]=(0,P.useState)(null),[B,H]=(0,P.useState)(``),[re,W]=(0,P.useState)(!1),[G,K]=(0,P.useState)(`split`),[q,J]=(0,P.useState)([]),[ie,Y]=(0,P.useState)(null),X=(0,P.useRef)(null);(0,P.useEffect)(()=>{X.current=L},[L]);let Z=(0,P.useCallback)(async()=>{H(``);try{let t=await r(`/api/docs/item?ref=`+encodeURIComponent(e||``));R(t),W(!1)}catch(e){H(String(e.message||e)),R(null)}},[e]);(0,P.useEffect)(()=>{R(null),Z()},[Z]);let oe=(0,P.useCallback)(()=>{if(!N){J([]);return}if(M===`repo`){r(`/api/repos/docs?id=`+encodeURIComponent(N)).then(t=>{let n=[],r=(e,t)=>{if(!e)return;let r=e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``;r&&n.push({docId:r,label:e.rel||e.path||(t?`主篇`:`补充`),note:e.note||``,main:t})};r(t.main||{rel:`repo/${N}.md`},!0);for(let e of t.links||[])r(e,!1);e&&!n.some(t=>t.docId===e)&&n.push({docId:e,label:`当前`,note:``,main:!0}),J(n)}).catch(()=>J(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}r(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===N||e.key===N),r=[];e&&r.push({docId:e,label:`当前`,note:``,main:!0});for(let e of n&&n.docLinks||[]){let t=e.rel?`rel:${e.rel}`:e.path?`path:${e.path}`:``;t&&!r.some(e=>e.docId===t)&&r.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,main:!1})}J(r)}).catch(()=>J(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[N,M,e]);(0,P.useEffect)(()=>{oe()},[oe]);let[se,ce]=(0,P.useState)(null);(0,P.useEffect)(()=>{r(`/api/docs/index`).then(e=>{let t=new Set;for(let n of e.index||[])t.add(n.name),n.rel&&t.add(String(n.rel).toLowerCase()),n.path&&t.add(String(n.path).replace(/\\/g,`/`).toLowerCase());ce(t)}).catch(()=>{})},[]);let Q=!!(L&&L.writable),le=(0,P.useMemo)(()=>L?b(L.body,[],Q?se:null):``,[L,se,Q]),ue=(0,P.useMemo)(()=>L?f(L.body):[],[L]);(0,P.useEffect)(()=>{let e=k.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;Y(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Y(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[L,G,le]);let $=e=>e().catch(e=>d(String(e.message||e))),de=(0,P.useCallback)(e=>j(e,null,F),[j,F]),fe=(0,P.useCallback)(()=>{let e=s;e&&N&&c(e,{component:`refs`,name:`文档列表`,config:t?{repoKey:t}:{boardKey:i,boardName:o||``},location:`right`})},[s,N,t,i,o]),pe=()=>{N&&$(async()=>{let t=await x({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(t===null)return;let n=ee(String(t).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?U(e):M===`repo`?`repo/${N}`:`board/${o||N}`}/reference/${n}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(t).trim()||n}\n\n(待补)\n`}});try{M===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:N,rel:i}}):await r(`/api/docs/link`,{method:`POST`,body:{board:N,doc:i}})}catch{}d(`已补充:${i}`),oe(),j(`rel:`+i,null,F)})},me=()=>$(async()=>{if(!L||!Q)return;let t=await r(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:L.body}});R(e=>({...e,body:L.body,summary:t.summary})),W(!1),v(D.current,e),d(t.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{L&&(h(D.current,e,{body:L.body},n),W(!0),R(e=>({...e,body:t,title:w(t,e.title)})))},ge=(t,n=`typing`)=>{if(!L)return;h(D.current,e,{body:L.body},n),W(!0);let r=/^#\s+/m.test(L.body)?L.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${L.body}`;R(e=>({...e,body:r,title:t}))},_e=()=>{if(!L)return;let t=m(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:w(t.body,e.title)})),W(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ve=()=>{if(!L)return;let t=_(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:w(t.body,e.title)})),W(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await S(r,{local:!0,onProgress:(e,t,n)=>d(`正在上传 ${e}/${t}:${n.name}`)}),i=C(t);if(!i)return;let a=X.current||L;if(!a)return;let o=g(a.body,i,n);h(D.current,e,{body:a.body}),W(!0),R(e=>e&&{...e,body:o.body,title:w(o.body,e.title)}),d(`已插入 ${t.length} 个附件`)}catch(e){d(`附件上传失败:${String(e.message||e)}`)}},be=()=>{L&&L.rel&&$(async()=>{let t=await x({title:`重命名文档`,input:!0,value:L.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(t===null)return;let n=String(t).trim();if(n&&n!==L.rel){if(!/\.md$/i.test(n))return d(`文档路径必须以 .md 结尾`);try{await r(`/api/docs/item`,{method:`POST`,body:{rel:n,body:L.body}})}catch(e){d(`重命名失败:${String(e.message||e)}`);return}await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),v(D.current,e),d(`已重命名为:${n}`),j(`rel:`+n,null,F)}})},xe=()=>{L&&$(async()=>{await x({title:`删除文档「${L.title||L.rel||e}」`,message:`磁盘上的 ${L.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),d(`已删除:${L.rel||e}`),s&&u&&s.doAction(l.deleteTab(u)))})},Se=()=>$(async()=>{let t=String(e||``).startsWith(`rel:`)?e.slice(4):String(e||``).startsWith(`path:`)?``:String(e||``);if(!t)return;let n=t.replace(/\.md$/i,``).split(`/`).pop()||`未命名文档`;await r(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n}\n\n(待补)\n`}}),d(`已创建:${t}`),await Z()});if(L&&L.dir)return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsxs)(`div`,{className:`docp-head`,children:[(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.path}),(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,I.jsxs)(`div`,{className:`docp-files`,children:[L.files.map(e=>(0,I.jsx)(`button`,{className:`docp-file`,onClick:()=>j(`path:`+e,null),children:e},e)),!L.files.length&&(0,I.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(B)return(0,I.jsx)(`div`,{className:`mdw docp`,children:(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档打开失败`})}),(0,I.jsx)(`div`,{className:`hint`,children:B})]})});if(!L)return(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(L.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsx)(`div`,{className:`docp-head`,children:(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.rel||L.path||e})}),(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,I.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,I.jsx)(`div`,{children:(0,I.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?G:`read`;return(0,I.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:A,ref:k,children:[(0,I.jsxs)(`div`,{className:`mdw-main`,children:[(0,I.jsx)(ne,{crumb:(0,I.jsx)(T,{}),title:L.title||L.rel||L.path||`文档`,pathLabel:L.rel||L.path||``,dirty:re,writable:Q,external:!!L.external,menuGroups:[z(`edit`,`编辑`,[{id:`mode`,label:G===`edit`?`返回实时预览`:`源码模式`,hint:G===`edit`?`当前`:``,run:()=>K(G===`edit`?`split`:`edit`)}]),z(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),z(`view`,`查看`,[N&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),L.summary&&Q&&(0,I.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,L.summary]}),(0,I.jsx)(p,{mode:Ce,title:L.title,body:L.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:O,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,I.jsx)(te,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=y(e);t&&j(t,null,F)}}),(0,I.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,I.jsx)(ae,{headings:ue,scrollRoot:ie,links:q,activeDocId:e,onOpenDoc:N?de:null,onAddRef:N?pe:null}),E]})}function U(e){let t=String(e||``).startsWith(`rel:`)?String(e).slice(4):``;return t?/\/index\.md$/i.test(t)?t.replace(/\/index\.md$/i,``):/\.md$/i.test(t)?t.replace(/\.md$/i,``):t.replace(/\/+$/,``):``}function re(e,t){return e?e.doc&&e.doc.path?`path:`+e.doc.path:e.doc&&e.doc.rel?`rel:`+e.doc.rel:e.docPath?`path:`+e.docPath:e.docRel?`rel:`+e.docRel:t===`repo`&&e.key?`rel:repo/`+e.key+`.md`:``:``}function W(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function G({kind:e,owner:t,model:n}){let{openByDocId:i}=V(n),a=e===`board`?`组介绍`:`项目介绍`,o=e===`board`?t&&(t.id||t.key):t&&t.key,s=t&&t.name,c=(0,P.useMemo)(()=>re(t,e),[t,e]),[l,u]=(0,P.useState)([]),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(0),h=(0,P.useCallback)(()=>m(e=>e+1),[]);(0,P.useEffect)(()=>{let n=!0;if(!o){u([]);return}if(e===`repo`)r(`/api/repos/docs?id=`+encodeURIComponent(o)).then(e=>{if(!n)return;let t=[],r=W(e.main);f(r||c),r&&t.push({docId:r,label:e.main.rel||e.main.path||`主篇`,note:e.main.note||``,tag:e.main.tag||``,main:!0,ref:e.main.ref||``});for(let n of e.extras||[]){let e=W(n);e&&t.push({docId:e,label:n.name||n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}for(let n of e.links||[]){let e=W(n);e&&t.push({docId:e,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}u(t)}).catch(()=>{n&&(u([]),f(c))});else{let e=()=>{let e=[];c&&e.push({docId:c,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let n of t?.docLinks||[]){let t=W(n);t&&e.push({docId:t,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}return e};r(`/api/boards/`+encodeURIComponent(String(o))).then(t=>{if(!n)return;let r=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!r){u(e()),f(c);return}let i=[],a=W(t&&t.introMain)||c;f(a),a&&i.push({docId:a,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of t&&t.introExtras||[]){let t=W(e);t&&i.push({docId:t,label:e.name||e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}for(let e of r){let t=W(e);t&&i.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}u(i)}).catch(()=>{n&&(u(e()),f(c))})}return()=>{n=!1}},[e,o,t,c,p]);let g=(0,P.useMemo)(()=>e===`repo`&&o?{repoKey:o}:e===`board`&&o?{boardKey:o,boardName:s||``}:{},[e,o,s]);return{kind:e,label:a,ownerKey:o,docRef:c,mainDocId:d,links:l,openMain:(0,P.useCallback)(()=>{let e=d||c;e&&i(e,null,g)},[d,c,i,g]),openDoc:(0,P.useCallback)(e=>i(e,null,g),[i,g]),addRef:(0,P.useCallback)(async(t,n)=>{if(!o||!c.startsWith(`rel:`))return n&&n(`当前简介无法补充(需要自有树路径)`),null;let a=await t({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(a===null)return null;let l=typeof a==`string`?a:a&&a.value||``,u=typeof a==`object`&&a&&a.tag||``,d=ee(String(l).trim()||`note`).replace(/\.md$/i,``),f=`${U(c)||(e===`repo`?`repo/${o}`:`board/${s||o}`)}/reference/${d}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:f,body:`# ${String(l).trim()||d}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,rel:f,tag:u||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:f,tag:u||void 0}})}catch{}return n&&n(`已补充:${f}${u?` [${u}]`:``}`),h(),i(`rel:`+f,null,g),f},[o,c,e,s,i,g,h]),setLinkTag:(0,P.useCallback)(async(t,n,i)=>{if(!o)throw Error(`缺少归属`);let a=String(t||``).startsWith(`path:`)?{path:String(t).slice(5)}:{rel:String(t||``).startsWith(`rel:`)?String(t).slice(4):String(t||``)},s=i&&i.note||``;e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,...a,note:s||void 0,tag:n||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:a.path||a.rel,note:s||void 0,tag:n||void 0}}),h()},[o,e,h]),reload:h,canEdit:!!c}}function K(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function q(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function J(e,t,n){let r=[],i=e&&(e.main||e.introMain);i&&r.push({id:K(i),kind:`main`,label:`主篇`,sub:i.rel||i.path||``,tag:``,note:``,docId:K(i),removable:n===`repo`&&!!(t&&t.doc),removeTip:`摘除主篇自定义绑定(回退约定路径,文档不删)`,taggable:!1});for(let t of e&&(e.extras||e.introExtras)||[]){let e=K(t);e&&r.push({id:e,kind:`extra`,label:q(t),sub:t.rel||t.path||``,tag:``,note:``,docId:e,removable:!1,taggable:String(e).startsWith(`rel:`)})}(e&&(e.links||e.docLinks)||[]).forEach((e,t)=>{let i=K(e);i&&r.push({id:i,kind:`link`,label:q(e),sub:e.rel||e.path||``,tag:e.tag||``,note:e.note||``,docId:i,removeIndex:n===`repo`?t+2:t+1,removable:!0,taggable:!0})});for(let e of n===`repo`&&t&&t.boards||[]){let t=e.noteDocPath||``,n=e.noteDocRel||``,i=t?`path:`+t:n?`rel:`+n:``;i&&r.push({id:i,kind:`scoped`,label:`${e.name} · 组内描述`,sub:t||n,tag:``,note:e.note||``,docId:i,removable:!1,taggable:!1})}return r.filter(e=>e.docId)}var ie={main:`● `,scoped:`◇ `,extra:`○ `,link:`○ `};function Y({kind:e,owner:t,model:o,onClose:s,onChanged:l}){let u=a(),{dialog:f,node:p}=n(),m=d()||{},h=o||m.model,g=G({kind:e,owner:t,model:h}),_=g.ownerKey,v=t&&t.name,[y,b]=(0,P.useState)([]),[x,S]=(0,P.useState)(!0),[C,w]=(0,P.useState)(``),T=(0,P.useCallback)(async()=>{if(!_){b([]),S(!1);return}S(!0);try{let n=e===`repo`?await r(`/api/repos/docs?id=`+encodeURIComponent(_)):await r(`/api/boards/`+encodeURIComponent(String(_)));b(J(n,t,e)),w(``)}catch(e){b([]),w(String(e.message||e))}finally{S(!1)}},[e,_,t]);(0,P.useEffect)(()=>{T()},[T]);let E=t=>{if(!t)return;let n=h;if(!n){u(`工作区不可用,无法打开文档`);return}c(n,{component:`doc`,name:t.label||t.sub||t.docId,config:{docId:t.docId,...e===`repo`?{repoKey:_}:{boardKey:_,boardName:v||``}},location:`center`}),s()},D=e=>e().catch(e=>u(String(e.message||e))),O=t=>D(async()=>{await f({message:`摘除「${t.label}」?${t.kind===`main`?`(只拆绑定,文档不删)`:`(文档不删,仅移出列表)`}`,danger:!0})&&(e===`repo`?await r(`/api/repos/docs`,{method:`DELETE`,body:{id:_,index:t.removeIndex}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,remove:t.removeIndex}}),u(`已摘除`),T(),l&&l())}),k=e=>D(async()=>{let t=await f({title:`标签 · ${e.label}`,input:!0,placeholder:`标签(如 qa;留空 = 清掉)`,value:e.tag||``,okText:`保存标签`});if(t===null)return;let n=typeof t==`string`?t:t&&t.tag||``;await g.setLinkTag(e.docId,n,e),u(n?`标签已设为 [${n}]`:`标签已清除`),T(),l&&l()}),A=()=>D(async()=>{if(!_||!String(g.docRef||``).startsWith(`rel:`)){u(`当前简介无法补充(需要自有树路径)`);return}let t=await f({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(t===null)return;let n=typeof t==`string`?t:t&&t.value||``,i=typeof t==`object`&&t&&t.tag||``,a=ee(String(n).trim()||`note`).replace(/\.md$/i,``),o=`${U(g.docRef)||(e===`repo`?`repo/${_}`:`board/${v||_}`)}/reference/${a}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:o,body:`# ${String(n).trim()||a}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:_,rel:o,tag:i||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,doc:o,tag:i||void 0}})}catch{}u(`已补充:${o}${i?` [${i}]`:``}`),await T(),l&&l(),E({docId:`rel:`+o,label:String(n).trim()||a,sub:o})}),j=!!String(g.docRef||``).startsWith(`rel:`)&&_,M=y.length,N=`文档列表 · ${v||``}${e===`board`?`(项目组)`:``}`;return(0,I.jsxs)(i,{size:`md`,title:N,onClose:s,children:[(0,I.jsxs)(`div`,{className:`nx-dl`,children:[(0,I.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,I.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,I.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,I.jsx)(`span`,{className:`grow`}),j&&(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:A,children:`+ 补充`})]}),C?(0,I.jsx)(`div`,{className:`rpd-err`,children:C}):null,!C&&x&&M===0?(0,I.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!C&&!x&&M===0?(0,I.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,I.jsx)(`div`,{className:`nx-dl-list`,children:y.map(e=>(0,I.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>E(e),children:[(0,I.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ie[e.kind]||`○ `,e.label]}),e.tag?(0,I.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,I.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>k(e),children:`#`}),e.removable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>O(e),children:`×`})]})]},e.id))})]}),p]})}function X(e){return e<=1?18:e===2?12:8}function ae({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(``),u=(0,P.useMemo)(()=>e||[],[e]),d=(0,P.useMemo)(()=>n||[],[n]);(0,P.useEffect)(()=>{let e=t;if(!e||!u.length)return;let n=()=>u.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(Boolean),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,u]);let f=(0,P.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!u.length&&!d.length&&!a?null:(0,I.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{})]}),(0,I.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${X(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,I.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>f(e.id),children:e.text},e.id))]}),(d.length>0||a)&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.note||e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function Z({kind:e,owner:t,model:n}){let{label:r,docRef:i,links:a,openMain:o}=G({kind:e,owner:t,model:n}),[s,c]=(0,P.useState)(!1);if(!t||!i)return null;let l=a.find(e=>e.main),u=l?l.docId:i,d=u.startsWith(`rel:`)?u.slice(4):u,f=a.filter(e=>!e.main).length;return(0,I.jsxs)(`div`,{className:`nx-intro`,children:[(0,I.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,I.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,I.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,I.jsx)(`span`,{className:`nx-intro-spacer`}),(0,I.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,I.jsx)(Y,{kind:e,owner:t,model:n,onClose:()=>c(!1)})]})}export{V as i,Y as n,B as r,Z as t};
|
|
1
|
+
import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-DCgN2zcc.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{a as w,r as ee}from"./md-parse-awNLHAzO.js";import{t as T}from"./route-crumb-B7T_Hupr.js";import{a as E,c as D,i as O,l as k,o as A,r as j,s as M,t as N,u as te}from"./tool-bar-CDUi6q4z.js";var P=s(e(),1),F=u(),I=t(),L=`doc`,R=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function ne({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=O(),{layout:f,setLayout:p}=A(L),[m,h]=(0,P.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>k(L,e)&&_(e.id)),y=f.filter(e=>M(L,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,I.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>j(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,I.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||D(L,e).label||e},e):null},S=R.map(e=>({...e,items:y.filter(t=>D(L,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!D(L,e.id).menuGroup);return i?(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,I.jsxs)(N,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,I.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||D(L,e.id).danger;return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||D(L,e.id).label||e.id,t?.hint?(0,I.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||D(L,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||D(L,e.id).label||e.id},e.id)}),(0,I.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,F.createPortal)((0,I.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,I.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(E,{kind:L,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsx)(`div`,{className:`docp-actions`,children:(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function z(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}var B=o({default:()=>H,useWikiNav:()=>V});function V(e){let t=d()||{},n=a(),i=e||t.model,o=(0,P.useRef)(null),s=(0,P.useCallback)(async()=>{if(!o.current)try{o.current=(await r(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),l=(0,P.useCallback)(async(e,t,n={})=>{let r=(t||await s()).find(t=>t.docId===e);c(i,{component:`doc`,name:r?r.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[i,s]),u=(0,P.useCallback)(async e=>{let t=await s(),r=x(e,t);if(r&&r.docId)return l(r.docId,t);if(r&&r.candidates)return n(`「${e}」同名文档多份:${r.candidates.join(`、`)}`);n(`未找到「${e}」——可用 nx-kv docs add <rel> 创建`)},[s,l,n]);return{nav:u,onClick:(0,P.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),u(t.getAttribute(`data-wl`)))},[u]),ensureIndex:s,openByDocId:l}}function H({docId:e,repoKey:t,boardKey:i,boardName:o,model:s,tabId:u}){let d=a(),{dialog:x,node:E}=n(),D=(0,P.useRef)(new Map),O=(0,P.useRef)(null),k=(0,P.useRef)(null),{onClick:A,openByDocId:j}=V(s),M=t?`repo`:i?`board`:``,N=t||i||``,F=(0,P.useMemo)(()=>t?{repoKey:t}:i?{boardKey:i,boardName:o||``}:{},[t,i,o]),[L,R]=(0,P.useState)(null),[B,H]=(0,P.useState)(``),[re,W]=(0,P.useState)(!1),[G,K]=(0,P.useState)(`split`),[q,J]=(0,P.useState)([]),[ie,Y]=(0,P.useState)(null),X=(0,P.useRef)(null);(0,P.useEffect)(()=>{X.current=L},[L]);let Z=(0,P.useCallback)(async()=>{H(``);try{let t=await r(`/api/docs/item?ref=`+encodeURIComponent(e||``));R(t),W(!1)}catch(e){H(String(e.message||e)),R(null)}},[e]);(0,P.useEffect)(()=>{R(null),Z()},[Z]);let oe=(0,P.useCallback)(()=>{if(!N){J([]);return}if(M===`repo`){r(`/api/repos/docs?id=`+encodeURIComponent(N)).then(t=>{let n=[],r=(e,t)=>{if(!e)return;let r=e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``;r&&n.push({docId:r,label:e.rel||e.path||(t?`主篇`:`补充`),note:e.note||``,main:t})};r(t.main||{rel:`repo/${N}.md`},!0);for(let e of t.links||[])r(e,!1);e&&!n.some(t=>t.docId===e)&&n.push({docId:e,label:`当前`,note:``,main:!0}),J(n)}).catch(()=>J(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}r(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===N||e.key===N),r=[];e&&r.push({docId:e,label:`当前`,note:``,main:!0});for(let e of n&&n.docLinks||[]){let t=e.rel?`rel:${e.rel}`:e.path?`path:${e.path}`:``;t&&!r.some(e=>e.docId===t)&&r.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,main:!1})}J(r)}).catch(()=>J(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[N,M,e]);(0,P.useEffect)(()=>{oe()},[oe]);let[se,ce]=(0,P.useState)(null);(0,P.useEffect)(()=>{r(`/api/docs/index`).then(e=>{let t=new Set;for(let n of e.index||[])t.add(n.name),n.rel&&t.add(String(n.rel).toLowerCase()),n.path&&t.add(String(n.path).replace(/\\/g,`/`).toLowerCase());ce(t)}).catch(()=>{})},[]);let Q=!!(L&&L.writable),le=(0,P.useMemo)(()=>L?b(L.body,[],Q?se:null):``,[L,se,Q]),ue=(0,P.useMemo)(()=>L?f(L.body):[],[L]);(0,P.useEffect)(()=>{let e=k.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;Y(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Y(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[L,G,le]);let $=e=>e().catch(e=>d(String(e.message||e))),de=(0,P.useCallback)(e=>j(e,null,F),[j,F]),fe=(0,P.useCallback)(()=>{let e=s;e&&N&&c(e,{component:`refs`,name:`文档列表`,config:t?{repoKey:t}:{boardKey:i,boardName:o||``},location:`right`})},[s,N,t,i,o]),pe=()=>{N&&$(async()=>{let t=await x({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(t===null)return;let n=ee(String(t).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?U(e):M===`repo`?`repo/${N}`:`board/${o||N}`}/reference/${n}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(t).trim()||n}\n\n(待补)\n`}});try{M===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:N,rel:i}}):await r(`/api/docs/link`,{method:`POST`,body:{board:N,doc:i}})}catch{}d(`已补充:${i}`),oe(),j(`rel:`+i,null,F)})},me=()=>$(async()=>{if(!L||!Q)return;let t=await r(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:L.body}});R(e=>({...e,body:L.body,summary:t.summary})),W(!1),v(D.current,e),d(t.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{L&&(h(D.current,e,{body:L.body},n),W(!0),R(e=>({...e,body:t,title:w(t,e.title)})))},ge=(t,n=`typing`)=>{if(!L)return;h(D.current,e,{body:L.body},n),W(!0);let r=/^#\s+/m.test(L.body)?L.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${L.body}`;R(e=>({...e,body:r,title:t}))},_e=()=>{if(!L)return;let t=m(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:w(t.body,e.title)})),W(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ve=()=>{if(!L)return;let t=_(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:w(t.body,e.title)})),W(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await S(r,{local:!0,onProgress:(e,t,n)=>d(`正在上传 ${e}/${t}:${n.name}`)}),i=C(t);if(!i)return;let a=X.current||L;if(!a)return;let o=g(a.body,i,n);h(D.current,e,{body:a.body}),W(!0),R(e=>e&&{...e,body:o.body,title:w(o.body,e.title)}),d(`已插入 ${t.length} 个附件`)}catch(e){d(`附件上传失败:${String(e.message||e)}`)}},be=()=>{L&&L.rel&&$(async()=>{let t=await x({title:`重命名文档`,input:!0,value:L.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(t===null)return;let n=String(t).trim();if(n&&n!==L.rel){if(!/\.md$/i.test(n))return d(`文档路径必须以 .md 结尾`);try{await r(`/api/docs/item`,{method:`POST`,body:{rel:n,body:L.body}})}catch(e){d(`重命名失败:${String(e.message||e)}`);return}await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),v(D.current,e),d(`已重命名为:${n}`),j(`rel:`+n,null,F)}})},xe=()=>{L&&$(async()=>{await x({title:`删除文档「${L.title||L.rel||e}」`,message:`磁盘上的 ${L.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),d(`已删除:${L.rel||e}`),s&&u&&s.doAction(l.deleteTab(u)))})},Se=()=>$(async()=>{let t=String(e||``).startsWith(`rel:`)?e.slice(4):String(e||``).startsWith(`path:`)?``:String(e||``);if(!t)return;let n=t.replace(/\.md$/i,``).split(`/`).pop()||`未命名文档`;await r(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n}\n\n(待补)\n`}}),d(`已创建:${t}`),await Z()});if(L&&L.dir)return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsxs)(`div`,{className:`docp-head`,children:[(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.path}),(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,I.jsxs)(`div`,{className:`docp-files`,children:[L.files.map(e=>(0,I.jsx)(`button`,{className:`docp-file`,onClick:()=>j(`path:`+e,null),children:e},e)),!L.files.length&&(0,I.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(B)return(0,I.jsx)(`div`,{className:`mdw docp`,children:(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档打开失败`})}),(0,I.jsx)(`div`,{className:`hint`,children:B})]})});if(!L)return(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(L.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsx)(`div`,{className:`docp-head`,children:(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.rel||L.path||e})}),(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,I.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,I.jsx)(`div`,{children:(0,I.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?G:`read`;return(0,I.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:A,ref:k,children:[(0,I.jsxs)(`div`,{className:`mdw-main`,children:[(0,I.jsx)(ne,{crumb:(0,I.jsx)(T,{}),title:L.title||L.rel||L.path||`文档`,pathLabel:L.rel||L.path||``,dirty:re,writable:Q,external:!!L.external,menuGroups:[z(`edit`,`编辑`,[{id:`mode`,label:G===`edit`?`返回实时预览`:`源码模式`,hint:G===`edit`?`当前`:``,run:()=>K(G===`edit`?`split`:`edit`)}]),z(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),z(`view`,`查看`,[N&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),L.summary&&Q&&(0,I.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,L.summary]}),(0,I.jsx)(p,{mode:Ce,title:L.title,body:L.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:O,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,I.jsx)(te,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=y(e);t&&j(t,null,F)}}),(0,I.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,I.jsx)(ae,{headings:ue,scrollRoot:ie,links:q,activeDocId:e,onOpenDoc:N?de:null,onAddRef:N?pe:null}),E]})}function U(e){let t=String(e||``).startsWith(`rel:`)?String(e).slice(4):``;return t?/\/index\.md$/i.test(t)?t.replace(/\/index\.md$/i,``):/\.md$/i.test(t)?t.replace(/\.md$/i,``):t.replace(/\/+$/,``):``}function re(e,t){return e?e.doc&&e.doc.path?`path:`+e.doc.path:e.doc&&e.doc.rel?`rel:`+e.doc.rel:e.docPath?`path:`+e.docPath:e.docRel?`rel:`+e.docRel:t===`repo`&&e.key?`rel:repo/`+e.key+`.md`:``:``}function W(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function G({kind:e,owner:t,model:n}){let{openByDocId:i}=V(n),a=e===`board`?`组介绍`:`项目介绍`,o=e===`board`?t&&(t.id||t.key):t&&t.key,s=t&&t.name,c=(0,P.useMemo)(()=>re(t,e),[t,e]),[l,u]=(0,P.useState)([]),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(0),h=(0,P.useCallback)(()=>m(e=>e+1),[]);(0,P.useEffect)(()=>{let n=!0;if(!o){u([]);return}if(e===`repo`)r(`/api/repos/docs?id=`+encodeURIComponent(o)).then(e=>{if(!n)return;let t=[],r=W(e.main);f(r||c),r&&t.push({docId:r,label:e.main.rel||e.main.path||`主篇`,note:e.main.note||``,tag:e.main.tag||``,main:!0,ref:e.main.ref||``});for(let n of e.extras||[]){let e=W(n);e&&t.push({docId:e,label:n.name||n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}for(let n of e.links||[]){let e=W(n);e&&t.push({docId:e,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}u(t)}).catch(()=>{n&&(u([]),f(c))});else{let e=()=>{let e=[];c&&e.push({docId:c,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let n of t?.docLinks||[]){let t=W(n);t&&e.push({docId:t,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}return e};r(`/api/boards/`+encodeURIComponent(String(o))).then(t=>{if(!n)return;let r=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!r){u(e()),f(c);return}let i=[],a=W(t&&t.introMain)||c;f(a),a&&i.push({docId:a,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of t&&t.introExtras||[]){let t=W(e);t&&i.push({docId:t,label:e.name||e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}for(let e of r){let t=W(e);t&&i.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}u(i)}).catch(()=>{n&&(u(e()),f(c))})}return()=>{n=!1}},[e,o,t,c,p]);let g=(0,P.useMemo)(()=>e===`repo`&&o?{repoKey:o}:e===`board`&&o?{boardKey:o,boardName:s||``}:{},[e,o,s]);return{kind:e,label:a,ownerKey:o,docRef:c,mainDocId:d,links:l,openMain:(0,P.useCallback)(()=>{let e=d||c;e&&i(e,null,g)},[d,c,i,g]),openDoc:(0,P.useCallback)(e=>i(e,null,g),[i,g]),addRef:(0,P.useCallback)(async(t,n)=>{if(!o||!c.startsWith(`rel:`))return n&&n(`当前简介无法补充(需要自有树路径)`),null;let a=await t({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(a===null)return null;let l=typeof a==`string`?a:a&&a.value||``,u=typeof a==`object`&&a&&a.tag||``,d=ee(String(l).trim()||`note`).replace(/\.md$/i,``),f=`${U(c)||(e===`repo`?`repo/${o}`:`board/${s||o}`)}/reference/${d}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:f,body:`# ${String(l).trim()||d}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,rel:f,tag:u||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:f,tag:u||void 0}})}catch{}return n&&n(`已补充:${f}${u?` [${u}]`:``}`),h(),i(`rel:`+f,null,g),f},[o,c,e,s,i,g,h]),setLinkTag:(0,P.useCallback)(async(t,n,i)=>{if(!o)throw Error(`缺少归属`);let a=String(t||``).startsWith(`path:`)?{path:String(t).slice(5)}:{rel:String(t||``).startsWith(`rel:`)?String(t).slice(4):String(t||``)},s=i&&i.note||``;e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,...a,note:s||void 0,tag:n||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:a.path||a.rel,note:s||void 0,tag:n||void 0}}),h()},[o,e,h]),reload:h,canEdit:!!c}}function K(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function q(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function J(e,t,n){let r=[],i=e&&(e.main||e.introMain);i&&r.push({id:K(i),kind:`main`,label:`主篇`,sub:i.rel||i.path||``,tag:``,note:``,docId:K(i),removable:n===`repo`&&!!(t&&t.doc),removeTip:`摘除主篇自定义绑定(回退约定路径,文档不删)`,taggable:!1});for(let t of e&&(e.extras||e.introExtras)||[]){let e=K(t);e&&r.push({id:e,kind:`extra`,label:q(t),sub:t.rel||t.path||``,tag:``,note:``,docId:e,removable:!1,taggable:String(e).startsWith(`rel:`)})}(e&&(e.links||e.docLinks)||[]).forEach((e,t)=>{let i=K(e);i&&r.push({id:i,kind:`link`,label:q(e),sub:e.rel||e.path||``,tag:e.tag||``,note:e.note||``,docId:i,removeIndex:n===`repo`?t+2:t+1,removable:!0,taggable:!0})});for(let e of n===`repo`&&t&&t.boards||[]){let t=e.noteDocPath||``,n=e.noteDocRel||``,i=t?`path:`+t:n?`rel:`+n:``;i&&r.push({id:i,kind:`scoped`,label:`${e.name} · 组内描述`,sub:t||n,tag:``,note:e.note||``,docId:i,removable:!1,taggable:!1})}return r.filter(e=>e.docId)}var ie={main:`● `,scoped:`◇ `,extra:`○ `,link:`○ `};function Y({kind:e,owner:t,model:o,onClose:s,onChanged:l}){let u=a(),{dialog:f,node:p}=n(),m=d()||{},h=o||m.model,g=G({kind:e,owner:t,model:h}),_=g.ownerKey,v=t&&t.name,[y,b]=(0,P.useState)([]),[x,S]=(0,P.useState)(!0),[C,w]=(0,P.useState)(``),T=(0,P.useCallback)(async()=>{if(!_){b([]),S(!1);return}S(!0);try{let n=e===`repo`?await r(`/api/repos/docs?id=`+encodeURIComponent(_)):await r(`/api/boards/`+encodeURIComponent(String(_)));b(J(n,t,e)),w(``)}catch(e){b([]),w(String(e.message||e))}finally{S(!1)}},[e,_,t]);(0,P.useEffect)(()=>{T()},[T]);let E=t=>{if(!t)return;let n=h;if(!n){u(`工作区不可用,无法打开文档`);return}c(n,{component:`doc`,name:t.label||t.sub||t.docId,config:{docId:t.docId,...e===`repo`?{repoKey:_}:{boardKey:_,boardName:v||``}},location:`center`}),s()},D=e=>e().catch(e=>u(String(e.message||e))),O=t=>D(async()=>{await f({message:`摘除「${t.label}」?${t.kind===`main`?`(只拆绑定,文档不删)`:`(文档不删,仅移出列表)`}`,danger:!0})&&(e===`repo`?await r(`/api/repos/docs`,{method:`DELETE`,body:{id:_,index:t.removeIndex}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,remove:t.removeIndex}}),u(`已摘除`),T(),l&&l())}),k=e=>D(async()=>{let t=await f({title:`标签 · ${e.label}`,input:!0,placeholder:`标签(如 qa;留空 = 清掉)`,value:e.tag||``,okText:`保存标签`});if(t===null)return;let n=typeof t==`string`?t:t&&t.tag||``;await g.setLinkTag(e.docId,n,e),u(n?`标签已设为 [${n}]`:`标签已清除`),T(),l&&l()}),A=()=>D(async()=>{if(!_||!String(g.docRef||``).startsWith(`rel:`)){u(`当前简介无法补充(需要自有树路径)`);return}let t=await f({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(t===null)return;let n=typeof t==`string`?t:t&&t.value||``,i=typeof t==`object`&&t&&t.tag||``,a=ee(String(n).trim()||`note`).replace(/\.md$/i,``),o=`${U(g.docRef)||(e===`repo`?`repo/${_}`:`board/${v||_}`)}/reference/${a}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:o,body:`# ${String(n).trim()||a}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:_,rel:o,tag:i||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,doc:o,tag:i||void 0}})}catch{}u(`已补充:${o}${i?` [${i}]`:``}`),await T(),l&&l(),E({docId:`rel:`+o,label:String(n).trim()||a,sub:o})}),j=!!String(g.docRef||``).startsWith(`rel:`)&&_,M=y.length,N=`文档列表 · ${v||``}${e===`board`?`(项目组)`:``}`;return(0,I.jsxs)(i,{size:`md`,title:N,onClose:s,children:[(0,I.jsxs)(`div`,{className:`nx-dl`,children:[(0,I.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,I.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,I.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,I.jsx)(`span`,{className:`grow`}),j&&(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:A,children:`+ 补充`})]}),C?(0,I.jsx)(`div`,{className:`rpd-err`,children:C}):null,!C&&x&&M===0?(0,I.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!C&&!x&&M===0?(0,I.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,I.jsx)(`div`,{className:`nx-dl-list`,children:y.map(e=>(0,I.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>E(e),children:[(0,I.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ie[e.kind]||`○ `,e.label]}),e.tag?(0,I.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,I.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>k(e),children:`#`}),e.removable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>O(e),children:`×`})]})]},e.id))})]}),p]})}function X(e){return e<=1?18:e===2?12:8}function ae({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(``),u=(0,P.useMemo)(()=>e||[],[e]),d=(0,P.useMemo)(()=>n||[],[n]);(0,P.useEffect)(()=>{let e=t;if(!e||!u.length)return;let n=()=>u.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(Boolean),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,u]);let f=(0,P.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!u.length&&!d.length&&!a?null:(0,I.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{})]}),(0,I.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${X(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,I.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>f(e.id),children:e.text},e.id))]}),(d.length>0||a)&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.note||e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function Z({kind:e,owner:t,model:n}){let{label:r,docRef:i,links:a,openMain:o}=G({kind:e,owner:t,model:n}),[s,c]=(0,P.useState)(!1);if(!t||!i)return null;let l=a.find(e=>e.main),u=l?l.docId:i,d=u.startsWith(`rel:`)?u.slice(4):u,f=a.filter(e=>!e.main).length;return(0,I.jsxs)(`div`,{className:`nx-intro`,children:[(0,I.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,I.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,I.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,I.jsx)(`span`,{className:`nx-intro-spacer`}),(0,I.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,I.jsx)(Y,{kind:e,owner:t,model:n,onClose:()=>c(!1)})]})}export{V as i,Y as n,B as r,Z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-
|
|
1
|
+
import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{w as r}from"./workspace-C_5X2gIr.js";import{a as i,c as a,l as o,o as s,s as c}from"./tool-bar-CDUi6q4z.js";var l=n(e(),1),u=r(),d=t();function f({kind:e,renderers:t={},actions:n={},titles:r={},disabled:f={},labels:p={},className:m=``}){let{layout:h,setLayout:g}=s(e),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),C=(0,l.useRef)(null),w=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!_)return;let e=e=>{C.current?.contains(e.target)||w.current?.contains(e.target)||v(!1)},t=e=>{e.key===`Escape`&&v(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[_]);let T=h.filter(t=>o(e,t)),E=h.filter(t=>c(e,t)),D=t=>p[t]||a(e,t).label||t,O=(e,t={})=>(0,d.jsx)(`button`,{type:`button`,className:t.primary?`btn small primary`:`btn small ghost`,title:r[e]||D(e),disabled:!!f[e],onClick:()=>n[e]&&n[e](),children:D(e)},e),k=n=>n===`more`?(0,d.jsxs)(`button`,{ref:C,type:`button`,className:`btn small ghost`+(_?` is-open`:``),title:r.more||`更多操作`,"aria-haspopup":`menu`,"aria-expanded":_,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b({top:t.bottom+6,right:Math.max(8,window.innerWidth-t.right)}),v(e=>!e)},children:[D(`more`),` ▾`]},`more`):t[n]?(0,d.jsx)(`span`,{className:`ta-slot`,children:t[n]({open:_})},n):O(n,{primary:a(e,n).section===`primary`});return(0,d.jsxs)(`div`,{className:`ta-bar`+(m?` ${m}`:``),children:[T.map(e=>k(e.id)),_&&y&&(0,u.createPortal)((0,d.jsxs)(`div`,{ref:w,className:`ta-more-menu`,role:`menu`,style:{top:y.top,right:y.right},children:[E.length===0&&(0,d.jsx)(`div`,{className:`ta-more-empty`,children:`没有收纳的工具——可在编排里把按钮收入更多`}),E.map(e=>(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it`,disabled:!!f[e.id],title:r[e.id]||D(e.id),onClick:()=>{v(!1),n[e.id]&&n[e.id]()},children:D(e.id)},e.id)),(0,d.jsx)(`div`,{className:`ta-more-sep`}),(0,d.jsx)(`button`,{type:`button`,role:`menuitem`,className:`ta-more-it ta-more-cfg`,onClick:()=>{v(!1),S(!0)},children:`自定义工具栏…`})]}),document.body),x&&(0,u.createPortal)((0,d.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>S(!1),children:(0,d.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,d.jsx)(i,{kind:e,layout:h,setLayout:g,onClose:()=>S(!1)})})}),document.body)]})}export{f as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-BnymQMTw.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BIMbGcCB.js";import{S as m,x as h}from"./index-BrAIkzFc.js";import{t as g}from"./route-crumb-C8JzPIax.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t&&t.selectionStart!==null?t.selectionStart:n.length,i=t&&t.selectionEnd!==null?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ,其他文件写 [文件名](fileId)`,onChange:e=>O(e.target.value),onPaste:j,onKeyDown:P}),(0,v.jsxs)(`div`,{className:`ed-meta`,children:[(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn small`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:F}),(0,v.jsxs)(`span`,{className:`hint`,children:[`图片 `,(0,v.jsx)(`code`,{children:``}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});t!==null&&t.trim()&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:t.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{let n=[];for(let[t]of C)for(let r of O[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await y({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${w(e.task.createdAt)} #${e.task.id}`).join(`
|
|
1
|
+
import{c as e,f as t,g as n,h as r,l as i,m as a,o,p as s,y as c}from"./task-status-BnymQMTw.js";import{a as l,i as u,l as d,n as f,t as p}from"./upload-BIMbGcCB.js";import{S as m,x as h}from"./index-BAS6Qpjs.js";import{t as g}from"./route-crumb-B7T_Hupr.js";var _=c(n(),1),v=r(),y=e=>`/api/file/content/${encodeURIComponent(e)}`;function b({text:e,compact:t=!1,className:n=``}){let r=d(e);return r.some(e=>e.type!==`text`)?(0,v.jsx)(`span`,{className:n?`mdtext ${n}`:`mdtext`,children:r.map((e,n)=>{if(e.type===`text`)return(0,v.jsx)(`span`,{className:`mdtext-plain`,children:e.value},n);let r=y(e.id);return e.type===`image`?(0,v.jsx)(`a`,{className:`embed-image`+(t?` compact`:``),href:r,target:`_blank`,rel:`noreferrer`,title:e.alt?`${e.alt}(点击看原图)`:e.id,children:(0,v.jsx)(`img`,{src:r,alt:e.alt||e.id,loading:`lazy`})},n):(0,v.jsx)(`a`,{className:`embed-file`,href:r,target:`_blank`,rel:`noreferrer`,title:e.id,children:e.alt||e.id},n)})}):(0,v.jsx)(`span`,{className:n,children:e})}function x({task:e,pick:t,group:n,onSaved:r,onCancel:i}){let o=s(),[c,d]=(0,_.useState)(e.text||``),[m,h]=(0,_.useState)(e.note||``),[g,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1),T=(0,_.useRef)(null),E=(0,_.useRef)(null),D=(0,_.useRef)(c),O=e=>{D.current=e,d(e)};(0,_.useEffect)(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[]);let k=e=>{if(!e)return;let t=T.current,n=D.current,r=t&&t.selectionStart!==null?t.selectionStart:n.length,i=t&&t.selectionEnd!==null?t.selectionEnd:r,a=n.slice(0,r),o=n.slice(i),s=a&&!/\s$/.test(a)?` `:``,c=`${a}${s}${e}${o&&!/^\s/.test(o)?` `:``}${o}`;O(c);let l=a.length+s.length+e.length;requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(l,l))})},A=async e=>{let t=Array.from(e||[]).filter(e=>e&&e.size>0);if(t.length&&!x){S({done:0,total:t.length});try{let e=await l(t,{group:n,onProgress:(e,t)=>S({done:e,total:t})});k(u(e));let r=e.filter(e=>e.isImage).length;o(e.length===1?`已插入 ${e[0].name}`:`已插入 ${e.length} 个附件${r?`(图片 ${r} 个)`:``}`)}catch(e){o(String(e&&e.message||e))}finally{S(null)}}},j=e=>{let t=p(e);t.length&&(e.preventDefault(),A(t))},M=(0,_.useRef)(null);M.current=e=>A(f(e)),(0,_.useEffect)(()=>{let e=e=>Array.from(e.dataTransfer&&e.dataTransfer.types||[]).includes(`Files`),t=t=>{e(t)&&(t.preventDefault(),w(!0))},n=e=>{e.relatedTarget||w(!1)},r=t=>{e(t)&&(t.preventDefault(),w(!1),M.current&&M.current(t))};return window.addEventListener(`dragover`,t),window.addEventListener(`dragleave`,n),window.addEventListener(`drop`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`dragleave`,n),window.removeEventListener(`drop`,r)}},[]);let N=()=>{if(g)return;if(!String(D.current).trim()){o(`正文不能为空`);return}let i={group:n,ref:e.text,pick:t,matchTopic:e.topic,text:D.current};m!==(e.note||``)&&(i.note=m),y(!0),a(`/api/todo/item`,{method:`PATCH`,body:i}).then(()=>{o(`已保存`),r()}).catch(e=>o(String(e&&e.message||e))).finally(()=>y(!1))},P=e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),N())},F=x?`上传中 ${x.done}/${x.total}…`:`选择文件上传`,I=!String(c).trim();return(0,v.jsxs)(`div`,{className:`editor`+(C?` drag`:``),children:[(0,v.jsxs)(`div`,{className:`ed-tip`,children:[`粘贴(`,(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`V`}),` 截图)、拖文件进来,或`,(0,v.jsx)(`button`,{type:`button`,className:`ed-link`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:`选择文件`}),`—— 会自动上传并插到光标处。`,(0,v.jsx)(`input`,{ref:E,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,A(t)}})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`正文`}),(0,v.jsx)(`textarea`,{ref:T,className:`ed-textarea`,rows:4,value:c,spellCheck:`false`,placeholder:`要做什么… 图片写 ,其他文件写 [文件名](fileId)`,onChange:e=>O(e.target.value),onPaste:j,onKeyDown:P}),(0,v.jsxs)(`div`,{className:`ed-meta`,children:[(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn small`,onClick:()=>E.current&&E.current.click(),disabled:!!x,children:F}),(0,v.jsxs)(`span`,{className:`hint`,children:[`图片 `,(0,v.jsx)(`code`,{children:``}),` 文件 `,(0,v.jsx)(`code`,{children:`[文件名](id)`})]})]}),(0,v.jsxs)(`span`,{className:`hint`,children:[c.length,` 字符`]})]})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`预览`}),(0,v.jsx)(`div`,{className:`preview`+(I?` empty`:``),children:I?(0,v.jsx)(`span`,{className:`muted`,children:`(暂无内容)`}):(0,v.jsx)(b,{text:c})})]}),(0,v.jsxs)(`div`,{className:`ed-field`,children:[(0,v.jsx)(`div`,{className:`ed-label`,children:`备注`}),(0,v.jsx)(`textarea`,{className:`ed-textarea`,rows:2,value:m,spellCheck:`false`,placeholder:`可选:完成结果、上下文补充`,onChange:e=>h(e.target.value)})]}),(0,v.jsxs)(`div`,{className:`ed-foot`,children:[(0,v.jsxs)(`span`,{className:`hint`,children:[(0,v.jsx)(`kbd`,{children:`Ctrl`}),`+`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 保存`]}),(0,v.jsxs)(`span`,{className:`ed-acts`,children:[(0,v.jsx)(`button`,{className:`btn ghost`,onClick:i,disabled:g,children:`取消`}),(0,v.jsx)(`button`,{className:`btn`,onClick:N,disabled:g||!!x,children:g?`保存中…`:`保存`})]})]})]})}function S({onClose:e}){let{boot:n,refreshBoot:r}=m(),c=s(),l=t(),{dialog:u,node:d}=i(),[f,p]=(0,_.useState)([]),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)({name:``,description:``}),[S,C]=(0,_.useState)(null),w=(0,_.useCallback)(async()=>{try{let e=await a(`/api/groups`);p(e.groups||[]),y(``)}catch(e){y(e.message||String(e))}},[]);(0,_.useEffect)(()=>{w()},[w]);let T=n?.groupId??0,E=e=>l(async()=>{let t=await a(`/api/group`,{method:`POST`,body:{locator:e}});c(t.id===0?`已切回默认组`:`已切换到 ${t.name}`),await r(),await w()}),D=()=>l(async()=>{let e=b.name.trim();if(!e){c(`请填名称`);return}let t=await a(`/api/groups`,{method:`POST`,body:{name:e,description:b.description.trim()}});x({name:``,description:``}),c(`已新建工作空间 ${t.name}(id=${t.id})`),await r(),await w()}),O=e=>l(async()=>{let t=await u({title:`重命名「${e.name}」`,input:!0,value:e.name});t!==null&&t.trim()&&(await a(`/api/groups/${e.id}`,{method:`PATCH`,body:{name:t.trim()}}),c(`已更新名称`),await r(),await w())}),k=e=>l(async()=>{await u({message:`解散工作空间「${e.name}」(id=${e.id})?\n\n后端要求组内已无 KV 数据,否则会拒绝。此操作不可撤销。`,danger:!0})&&(await a(`/api/groups/${e.id}`,{method:`DELETE`}),c(`已解散 ${e.name}`),await r(),await w())}),A=e=>l(async()=>{let t=await a(`/api/groups/${e.id}/members`);C({group:t.group,list:t.members||[]})});return n?.loggedIn?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(o,{title:`工作空间`,onClose:e,children:[(0,v.jsx)(`div`,{className:`muted`,style:{marginBottom:8},children:`清单按工作空间隔离读写。切换只改本机配置,不动服务端数据。`}),g?(0,v.jsx)(`div`,{className:`row muted`,children:g}):null,(0,v.jsxs)(`div`,{className:`list`,children:[(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(`span`,{className:`name`,children:`默认组`}),(0,v.jsx)(`span`,{className:`desc`,children:`不传 groupId,由后端回落`}),(0,v.jsx)(`span`,{className:`acts`,children:T===0?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(`default`),children:`切到这里`})})]}),f.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.name,title:`点击复制名称`,children:e.name}),(0,v.jsx)(`span`,{className:`tag`,children:e.myRole||`member`}),e.description?(0,v.jsx)(`span`,{className:`desc`,children:e.description}):null,(0,v.jsxs)(`span`,{className:`muted mono`,children:[`id=`,e.id]}),(0,v.jsxs)(`span`,{className:`muted`,children:[e.memberCount,` 人`]}),(0,v.jsxs)(`span`,{className:`acts`,children:[e.id===T?(0,v.jsx)(`span`,{className:`tag strong`,children:`当前`}):(0,v.jsx)(`button`,{className:`btn small`,onClick:()=>E(String(e.id)),children:`切到这里`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>A(e),children:`成员`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>O(e),children:`改名`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:()=>k(e),children:`解散`})]})]},e.id)),!g&&!f.length?(0,v.jsx)(`div`,{className:`row muted`,children:`(没有其他工作空间)`}):null]}),(0,v.jsxs)(`div`,{className:`toolbar`,style:{marginTop:10},children:[(0,v.jsx)(`input`,{placeholder:`新工作空间名称`,size:`16`,value:b.name,onChange:e=>x({...b,name:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,v.jsx)(`input`,{placeholder:`描述(可选)`,size:`20`,value:b.description,onChange:e=>x({...b,description:e.target.value})}),(0,v.jsx)(`button`,{className:`btn`,onClick:D,children:`新建`}),(0,v.jsx)(`button`,{className:`btn ghost`,onClick:()=>l(w),children:`刷新`})]})]}),S?(0,v.jsx)(o,{title:`成员 · ${S.group.name}`,onClose:()=>C(null),children:(0,v.jsx)(`div`,{className:`list`,children:S.list.length?S.list.map(e=>(0,v.jsxs)(`div`,{className:`row`,children:[(0,v.jsx)(h,{className:`name`,text:e.email,title:`点击复制邮箱`,children:e.email}),(0,v.jsx)(`span`,{className:`tag`,children:e.role||`member`}),(0,v.jsx)(`span`,{className:`muted`,children:e.nickname})]},e.userId)):(0,v.jsx)(`div`,{className:`row muted`,children:`(没有成员)`})})}):null,d]}):(0,v.jsx)(o,{title:`工作空间`,onClose:e,children:(0,v.jsx)(`div`,{className:`muted`,children:`工作空间需要登录后才能列出。`})})}var C=[[`open`,`待办`],[`done`,`已完成`],[`freeze`,`冻结`]],w=e=>e?String(e).slice(0,16).replace(`T`,` `):``,T=15,E=(e,t)=>`${e}:${t.id}:${t.text}`;function D({bucket:t,task:n,dupCount:r,onAct:i}){let a=t===`done`,o=t===`freeze`,s=a?n.doneAt:o?n.frozenAt:n.createdAt;return(0,v.jsxs)(`div`,{className:`row cloud-row`,children:[(0,v.jsxs)(`div`,{className:`row-main`,children:[(0,v.jsxs)(`span`,{className:`tid`,children:[`#`,n.id]}),(0,v.jsx)(h,{className:`topic`,text:n.topic,title:`点击复制主题`,children:n.topic}),(0,v.jsx)(`span`,{className:`text`,title:n.text,children:(0,v.jsx)(b,{text:n.text,compact:!0})}),r>1?(0,v.jsxs)(`span`,{className:`tag`,title:`同内容有 ${r} 条,操作时需要消歧`,children:[`同内容×`,r]}):null,(0,v.jsx)(`span`,{className:`muted time`,children:w(s)}),(0,v.jsxs)(`span`,{className:`acts`,children:[t===`open`?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`done`,n),children:`完成`}):null,o?(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:()=>i(`unfreeze`,n),children:`解冻`}):null,(0,v.jsx)(e,{items:[t===`open`&&{label:`冻结`,onPick:()=>i(`freeze`,n)},{label:`编辑`,onPick:()=>i(`edit`,n,t)},{label:`删除`,danger:!0,onPick:()=>i(`remove`,n,t)}]})]})]}),n.note?(0,v.jsx)(`div`,{className:`note`,children:n.note}):null]})}function O(){let{boot:e,ui:n,patchUi:r,refreshBoot:c}=m(),d=s(),f=t(),{dialog:y,node:b}=i(),[O,k]=(0,_.useState)(null),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)({topic:``,text:``}),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(!1),[B,ee]=(0,_.useState)({}),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)(null),G=e?.groupId??0,te=(e?.groups||[]).find(e=>e.id===G)?.name||(G?`#${G}`:`默认组`),[K,q]=(0,_.useState)({email:e?.email||``,password:``,busy:!1,open:!1}),J=()=>f(async()=>{if(!K.email.trim()){d(`请填邮箱`);return}if(!K.password){d(`请填密码`);return}q(e=>({...e,busy:!0}));try{let e=await a(`/api/auth/login`,{method:`POST`,body:{email:K.email.trim(),password:K.password}});q(e=>({...e,password:``})),d(`已登录: ${e.email}`),await c()}finally{q(e=>({...e,busy:!1}))}}),ne=()=>f(async()=>{await a(`/api/auth/logout`,{method:`POST`}),d(`已登出`),await c()}),Y=(0,_.useCallback)(async()=>{if(e?.loggedIn)try{k(await a(`/api/todo`)),j(``)}catch(e){j(String(e.message||e))}},[e?.loggedIn]);(0,_.useEffect)(()=>{Y()},[Y,G]),(0,_.useEffect)(()=>{a(`/api/setting`).then(W).catch(()=>{})},[]);let X=!!U?.autoSyncAttachments,re=()=>f(async()=>{let e=!X,t=await a(`/api/setting`,{method:`POST`,body:{autoSyncAttachments:e}});W(t),d(e?`已开启:读任务时自动下载附件到本地`:`已关闭自动下载附件`)}),Z=(0,_.useCallback)(async()=>{N(!0);try{await Y()}finally{N(!1)}},[Y]),ie=(0,_.useMemo)(()=>{let e=new Map;if(!O)return e;for(let[t]of C)for(let n of O[t]||[])e.set(n.text,(e.get(n.text)||0)+1);return e},[O]),Q=(0,_.useMemo)(()=>{if(!O)return null;let e=n.topic,t=t=>t?e?t.filter(t=>t.topic===e):t:null;return{open:t(O.open),done:t(O.done),freeze:t(O.freeze)}},[O,n.topic]);if(!e?.loggedIn)return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsx)(g,{}),(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,maxWidth:640},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录云端`}),(0,v.jsx)(`span`,{className:`tag bad`,children:`未登录`})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:12},children:[(0,v.jsx)(`input`,{placeholder:`邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]}),(0,v.jsxs)(`div`,{className:`muted`,style:{padding:`0 12px 12px`,fontSize:12},children:[`密码只用于本次请求,不写入本机配置;配置里只保存 token。 也可以用 CLI:`,(0,v.jsx)(`code`,{children:`nx-kv auth login <email>`}),`。`]})]})]});let ae=async(e,t)=>{let n=[];for(let[t]of C)for(let r of O[t]||[])r.text===e.text&&n.push({bucket:t,task:r});if(n.length<=1)return{bucket:t,task:e,pick:void 0};let r=n.findIndex(n=>n.bucket===t&&n.task.createdAt===e.createdAt),i=await y({title:`「${e.text.slice(0,30)}」有 ${n.length} 条,选哪一条?`,message:n.map((e,t)=>`[${t}] ${e.bucket} ${w(e.task.createdAt)} #${e.task.id}`).join(`
|
|
2
2
|
`),input:!0,placeholder:`输入 0..${n.length-1}`,value:String(r>=0?r:0)});if(i===null)return null;let a=Number(i);return!Number.isInteger(a)||!n[a]?(d(`请输入 0..${n.length-1}`),null):{...n[a],pick:a}},oe=(e,t,n)=>f(async()=>{let r=e===`remove`||e===`edit`?await ae(t,n):{bucket:n,task:t,pick:void 0};if(!r)return;let i={group:G,ref:r.task.text,pick:r.pick};if(e===`done`){let e=await y({title:`完成结果`,message:`完成「${t.text.slice(0,40)}」`,input:!0,placeholder:`可选:写一句完成结果`});if(e===null)return;await a(`/api/todo/done`,{method:`POST`,body:{...i,result:e||void 0}}),d(`已完成`)}else if(e===`freeze`)await a(`/api/todo/freeze`,{method:`POST`,body:i}),d(`已冻结`);else if(e===`unfreeze`)await a(`/api/todo/unfreeze`,{method:`POST`,body:i}),d(`已解冻`);else if(e===`remove`){if(!await y({message:`删除「${t.text.slice(0,40)}」?`,danger:!0}))return;await a(`/api/todo/item`,{method:`DELETE`,body:i}),d(`已删除`)}else if(e===`edit`){H({task:r.task,pick:r.pick});return}await Z(),await c()}),se=()=>f(async()=>{let e=await y({title:`归档已完成的旧记录`,message:`把「完成时间早于该日期」的记录移到冷 key(默认 30 天前)。留空用默认值。`,input:!0,placeholder:`YYYY-MM-DD,留空 = 30 天前`});if(e===null)return;let t=await a(`/api/todo/archive`,{method:`POST`,body:{before:e.trim()||void 0,group:G}});d(t.moved?`已归档 ${t.moved} 条 → ${t.coldKey}`:`没有需要归档的记录`),await Z()}),ce=async e=>{let t=p(e);if(t.length){e.preventDefault();try{let e=await l(t,{group:G}),n=u(e);F(e=>({...e,text:[e.text,n].filter(Boolean).join(` `)})),d(e.length===1?`已上传 ${e[0].name} 并附到内容里`:`已上传 ${e.length} 个附件并附到内容里`)}catch(e){d(String(e&&e.message||e))}}},$=()=>f(async()=>{let e=P.topic.trim(),t=P.text.trim();if(!e){d(`请填主题`);return}if(!t){d(`请填内容`);return}let n=await a(`/api/todo`,{method:`POST`,body:{topic:e,text:t,group:G}});F({topic:e,text:``}),d(`已加入待办${n.topicAdded?`(新主题 ${e})`:``}`),await Z()}),le=(e,t)=>B[e]?t:t.slice(0,T),ue=O?.topics||[];return(0,v.jsxs)(`div`,{className:`cloud-page`,children:[(0,v.jsxs)(`div`,{className:`cloud-toolbar`,children:[(0,v.jsxs)(`button`,{className:`pill on rp-ws-trigger`,title:`切换工作空间 / 管理(清单按工作空间隔离)`,onClick:()=>z(!0),children:[te,` `,(0,v.jsx)(`span`,{className:`rp-caret`,children:`▾`})]}),(0,v.jsx)(`span`,{className:`sep`}),(0,v.jsx)(`label`,{children:`主题`}),(0,v.jsxs)(`select`,{value:n.topic,onChange:e=>r({topic:e.target.value}),children:[(0,v.jsx)(`option`,{value:``,children:`全部`}),ue.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))]}),(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsxs)(`label`,{className:`toggle`+(X?` on`:``),title:`开启后,读取任务时会把正文引用的附件下载到本地,并把本地绝对路径一并返回给 agent。
|
|
3
3
|
当前目录:${U?U.resolvedDir:`(读取中…)`}`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:X,onChange:re}),(0,v.jsx)(`span`,{className:`dot`}),`附件自动下载`]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,disabled:M,children:M?`刷新中…`:`刷新`}),(0,v.jsx)(`button`,{className:`pill`+(K.open?` on`:``),title:`账号 ${e.email||``}(点击展开登录态 / 登出)`,onClick:()=>q(e=>({...e,open:!e.open})),children:e.email||`已登录`})]}),K.open?(0,v.jsxs)(`div`,{className:`card`,style:{padding:16,marginBottom:12},children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:`登录态`}),(0,v.jsx)(`button`,{className:`btn small ghost danger`,onClick:ne,children:`登出`})]}),(0,v.jsxs)(`div`,{className:`settings`,children:[(0,v.jsx)(`dt`,{children:`账号`}),(0,v.jsx)(`dd`,{children:e?.email}),(0,v.jsx)(`dt`,{children:`userId`}),(0,v.jsx)(`dd`,{children:e?.userId||`-`}),(0,v.jsx)(`dt`,{children:`后端`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.baseUrl,children:e?.baseUrl})}),(0,v.jsx)(`dt`,{children:`本机配置`}),(0,v.jsx)(`dd`,{className:`mono`,children:(0,v.jsx)(h,{text:e?.configPath,children:e?.configPath})})]}),(0,v.jsxs)(`div`,{className:`row-inline`,style:{padding:`10px 0 0`},children:[(0,v.jsx)(`input`,{placeholder:`切换账号:邮箱`,size:`24`,spellCheck:`false`,value:K.email,onChange:e=>q(t=>({...t,email:e.target.value}))}),(0,v.jsx)(`input`,{placeholder:`密码`,type:`password`,size:`18`,value:K.password,onChange:e=>q(t=>({...t,password:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&J()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:J,disabled:K.busy,children:K.busy?`登录中…`:`登录`})]})]}):null,(0,v.jsxs)(`div`,{className:`cloud-compose`,children:[(0,v.jsx)(`input`,{className:`cloud-compose-topic`,placeholder:`主题`,"aria-label":`新任务主题`,value:P.topic,onChange:e=>F({...P,topic:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`input`,{className:`cloud-compose-text`,placeholder:`要做什么…(可 Ctrl+V 粘贴图片)`,"aria-label":`新任务内容`,value:P.text,title:`可以直接 Ctrl+V 粘贴截图:会自动上传为附件并附在内容里`,onChange:e=>F({...P,text:e.target.value}),onPaste:ce,onKeyDown:e=>{e.key===`Enter`&&$()}}),(0,v.jsx)(`button`,{className:`btn`,onClick:$,children:`加入待办`})]}),A?(0,v.jsxs)(`div`,{className:`cloud-error`,children:[(0,v.jsxs)(`span`,{children:[`清单读取失败:`,A]}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:Z,children:`重试`})]}):null,!O&&!A?(0,v.jsx)(`div`,{className:`cloud-loading muted`,children:`读取中…`}):null,O?(0,v.jsx)(`div`,{className:`cols`,children:C.map(([e,t])=>(0,v.jsxs)(`div`,{className:`col col-`+e,children:[(0,v.jsxs)(`div`,{className:`colhead`,children:[(0,v.jsx)(`h3`,{children:t}),(0,v.jsx)(`span`,{className:`cnt`,children:(Q?.[e]||[]).length}),e===`done`&&(Q?.done||[]).length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`grow`}),(0,v.jsx)(`button`,{className:`btn small ghost`,onClick:se,title:`把较旧的完成记录移到冷 key`,children:`归档旧记录`})]}):null]}),(0,v.jsxs)(`div`,{className:`card list`,children:[(Q?.[e]||[]).length?le(e,Q[e]).map(t=>(0,v.jsx)(D,{bucket:e,task:t,dupCount:ie.get(t.text)||1,onAct:oe},E(e,t))):(0,v.jsx)(`div`,{className:`cloud-empty`,children:e===`open`?(0,v.jsxs)(v.Fragment,{children:[`还没有待办`,(0,v.jsx)(`br`,{}),`在上方投递条输入,`,(0,v.jsx)(`kbd`,{children:`Enter`}),` 直达`]}):e===`done`?`还没有完成记录`:`没有冻结的任务`}),(Q?.[e]||[]).length>T?(0,v.jsx)(`div`,{className:`row muted`,style:{cursor:`pointer`,justifyContent:`center`},onClick:()=>ee(t=>({...t,[e]:!t[e]})),children:B[e]?`收起`:`还有 ${Q[e].length-T} 条,点击展开`}):null]})]},e))}):null,R?(0,v.jsx)(S,{onClose:()=>z(!1)}):null,V?(0,v.jsx)(o,{title:`编辑任务`,onClose:()=>H(null),children:(0,v.jsx)(x,{task:V.task,pick:V.pick,group:G,onCancel:()=>H(null),onSaved:async()=>{H(null),await Z(),await c()}})}):null,I?(0,v.jsx)(o,{title:I.title,size:`lg`,onClose:()=>L(null),children:I.node}):null,b]})}export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,h as t,p as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{t as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,p as u,r as d,t as f}from"./md-history-
|
|
1
|
+
import{g as e,h as t,p as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{t as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,p as u,r as d,t as f}from"./md-history-DCgN2zcc.js";import"./index-BAS6Qpjs.js";import{i as p,o as m,r as ee,t as h}from"./composer-launch-Bf4rXhLs.js";var g=i(e(),1),_=t(),v=96;function y({token:e,mode:t=`comment`,quote:i=``,prevQuote:y=``,taskLabel:b=``,taskTitle:x=``,src:S=null}){let C=o()||{},w=n(),[T,E]=(0,g.useState)(``),[D,O]=(0,g.useState)([]),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=t===`feedback`,N=(0,g.useRef)(new Map),P=`compose-`+e,F=()=>{f(N.current,P),ee(C.model,e)},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 t=String(T||``).trim();if(!t&&!D.length){w(M?`写一下要改的地方`:`写一下要提的问题`);return}let n=h(e);if(!n||!n.onSubmit){w(`提交入口已失效(来源页面已关闭)`);return}A(!0);try{await n.onSubmit({text:t,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||`(这条任务还没有可引用的上轮总结)`})]}):i?(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:i}):(0,_.jsx)(`div`,{className:`cmp-quote`,children:i})]}):null,(0,_.jsx)(`div`,{className:`cmp-body`,children:(0,_.jsx)(s,{mode:`split`,title:``,body:T,onTitle:()=>{},onBody:I,attachments:D,docKey:`compose-`+e,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)(r,{name:`plus`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:X,title:q?`还原面板高度`:`最大化面板高度`,"aria-label":q?`还原面板高度`:`最大化面板高度`,children:(0,_.jsx)(r,{name:q?`collapse`:`expand`})}),(0,_.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>U(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,_.jsx)(r,{name:`x`})})]})]}),(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)(r,{name:`list`}),(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)(r,{name:`chevron`})})]}),(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};
|