nx-kv 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/package.json +1 -1
- package/src/core/db/migrations/index.js +2 -0
- package/src/core/db/migrations/v3.sql +20 -0
- package/src/core/db/version.js +4 -1
- package/src/modules/localtask/task-ops.js +9 -0
- package/src/modules/localtask/task-view.js +4 -0
- package/src/modules/templates/index.js +65 -9
- package/src/modules/templates/repo/templates.js +24 -2
- package/src/modules/templates/scope.js +107 -0
- package/src/modules/templates/service.js +83 -4
- package/src/runtime/spec.js +6 -1
- package/src/web/frontend/App.jsx +34 -2
- package/src/web/frontend/components/button/index.jsx +34 -7
- package/src/web/frontend/components/button/style.css +1 -1
- package/src/web/frontend/components/doc/doc-head.jsx +164 -48
- package/src/web/frontend/components/layout/crumbs.js +4 -1
- package/src/web/frontend/components/md/attach-area.jsx +20 -11
- package/src/web/frontend/components/md/attach-modal.jsx +3 -2
- package/src/web/frontend/components/md/attach-picker.jsx +37 -7
- package/src/web/frontend/components/md/md-panes.jsx +102 -23
- package/src/web/frontend/components/md/sel-menu.jsx +11 -0
- package/src/web/frontend/components/md/tool-bar.jsx +151 -94
- package/src/web/frontend/components/sidebar/task-children.jsx +6 -20
- package/src/web/frontend/components/status-tag/index.jsx +30 -0
- package/src/web/frontend/components/status-tag/model.js +53 -0
- package/src/web/frontend/components/tool-acts/bar.jsx +156 -0
- package/src/web/frontend/components/tool-acts/dnd.js +59 -0
- package/src/web/frontend/components/tool-acts/layout-panel.jsx +289 -0
- package/src/web/frontend/components/tool-acts/modules.js +162 -0
- package/src/web/frontend/components/tool-acts/style.css +108 -0
- package/src/web/frontend/components/tool-acts/use-layout.js +27 -0
- package/src/web/frontend/modules/md/attach-mention.js +11 -0
- package/src/web/frontend/modules/md/md-edit-ops.js +10 -7
- package/src/web/frontend/modules/md/md-parse.js +8 -21
- package/src/web/frontend/modules/md/progress-search.js +96 -0
- package/src/web/frontend/modules/md/style.css +52 -19
- package/src/web/frontend/modules/md/use-templates.js +65 -2
- package/src/web/frontend/page/dir/index.jsx +51 -38
- package/src/web/frontend/page/dir/landing.jsx +50 -70
- package/src/web/frontend/page/dir/task.jsx +45 -10
- package/src/web/frontend/page/group/index.jsx +194 -88
- package/src/web/frontend/page/overview/index.jsx +168 -269
- package/src/web/frontend/page/progress/index.jsx +59 -9
- package/src/web/frontend/page/repos/index.jsx +95 -103
- package/src/web/frontend/page/settings/index.jsx +4 -3
- package/src/web/frontend/page/settings/style.css +59 -31
- package/src/web/frontend/page/settings/task-templates-section.jsx +94 -99
- package/src/web/frontend/page/templates/index.jsx +221 -203
- package/src/web/frontend/page/templates/scope-chips.jsx +211 -0
- package/src/web/frontend/panels.jsx +28 -4
- package/src/web/frontend/route-map.js +42 -2
- package/src/web/frontend/style-v2.css +33 -77
- package/src/web/frontend/style.css +127 -319
- package/src/web/frontend/workspace/areas.js +1 -1
- package/src/web/public/assets/Introduction-DU27b_b_.js +1 -0
- package/src/web/public/assets/bar-CNuQf706.js +1 -0
- package/src/web/public/assets/board-view-t8CKtq17.js +1 -0
- package/src/web/public/assets/button-BPYMY-zh.js +1 -0
- package/src/web/public/assets/button-DA4lNJeC.css +1 -0
- package/src/web/public/assets/cloud-DgNCxJsL.js +3 -0
- package/src/web/public/assets/{composer-launch-CfVAwzTt.js → composer-launch-BKeKTPp4.js} +1 -1
- package/src/web/public/assets/composer-panel-DP322mVs.js +1 -0
- package/src/web/public/assets/dag-C4702bOt.js +1 -0
- package/src/web/public/assets/dir-Cipgyv3a.js +5 -0
- package/src/web/public/assets/group-m61-WL4C.js +1 -0
- package/src/web/public/assets/index-BEkITE6q.css +1 -0
- package/src/web/public/assets/index-CeIJd4ee.js +30 -0
- package/src/web/public/assets/md-history-Uo6U7hYS.js +1 -0
- package/src/web/public/assets/md-panes-PS7K93Lg.js +28 -0
- package/src/web/public/assets/md-parse-DN9INgZn.js +25 -0
- package/src/web/public/assets/member-picker--32VkTmv.js +1 -0
- package/src/web/public/assets/overview-BmoTQJuu.js +1 -0
- package/src/web/public/assets/progress-CWy9bYKr.js +3 -0
- package/src/web/public/assets/refs-DAy1kYGf.js +1 -0
- package/src/web/public/assets/repos-D_NT51Dq.js +9 -0
- package/src/web/public/assets/route-crumb-lOriqwxP.js +1 -0
- package/src/web/public/assets/settings-CBrQ3Iz5.css +1 -0
- package/src/web/public/assets/settings-Vp3ZMC1M.js +7 -0
- package/src/web/public/assets/status-tag-DGlwjAg2.js +1 -0
- package/src/web/public/assets/task-CRpctHxx.js +9 -0
- package/src/web/public/assets/task-status-BP6y8MVu.js +1 -0
- package/src/web/public/assets/templates-D900RS5b.js +1 -0
- package/src/web/public/assets/tool-bar-1h2zairf.css +1 -0
- package/src/web/public/assets/tool-bar-C-rnP0vv.js +1 -0
- package/src/web/public/assets/upload-L1g-pfvZ.js +1 -0
- package/src/web/public/index.html +6 -5
- package/src/web/public/assets/Introduction-C5sQqMIg.js +0 -1
- package/src/web/public/assets/attach-evLB-_o-.js +0 -1
- package/src/web/public/assets/cloud-B_LvtXsR.js +0 -3
- package/src/web/public/assets/composer-panel-DIbBPnrY.js +0 -1
- package/src/web/public/assets/dag-B9ujKuhg.js +0 -1
- package/src/web/public/assets/dir-us1qOb74.js +0 -5
- package/src/web/public/assets/group-BV9RUHL2.js +0 -1
- package/src/web/public/assets/index-B3bvje4X.css +0 -1
- package/src/web/public/assets/index-Dw5qvd3H.js +0 -54
- package/src/web/public/assets/md-edit-ops-ZwnwtEax.js +0 -22
- package/src/web/public/assets/md-history-DXAULvOG.js +0 -1
- package/src/web/public/assets/md-panes-XVBqxolq.js +0 -7
- package/src/web/public/assets/member-picker-caRH-T0U.js +0 -1
- package/src/web/public/assets/overview-BuK893nH.js +0 -1
- package/src/web/public/assets/progress-CXDMbg9t.js +0 -3
- package/src/web/public/assets/refs-CRV9oVjk.js +0 -1
- package/src/web/public/assets/repos-B4Kzl-pe.js +0 -9
- package/src/web/public/assets/route-crumb-BBKKZ3aI.js +0 -1
- package/src/web/public/assets/settings-BaiD0fFN.js +0 -7
- package/src/web/public/assets/settings-qCi-niJC.css +0 -1
- package/src/web/public/assets/task-CLl1Jg0v.js +0 -7
- package/src/web/public/assets/task-status-Bgo2Nfiw.js +0 -1
- package/src/web/public/assets/template-editor-D_rc4c19.js +0 -1
- package/src/web/public/assets/templates-G3voUFjL.js +0 -2
- package/src/web/public/assets/upload-DV28XAi0.js +0 -1
- /package/src/web/public/assets/{attach-BZrdOH46.css → task-status-BZrdOH46.css} +0 -0
package/src/web/frontend/App.jsx
CHANGED
|
@@ -81,7 +81,35 @@ function routeFromHash() {
|
|
|
81
81
|
boardName: name,
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
// 任务模板编辑(#137):#/templates/new[?scope=&topic=] / #/templates/edit/<id>
|
|
85
|
+
// 必须带 mode,否则会与空 config 的「目录页」互相冲掉全屏编辑器。
|
|
86
|
+
if (path === 'templates' || path.startsWith('templates/')) {
|
|
87
|
+
const rest = path === 'templates' ? '' : path.slice('templates/'.length);
|
|
88
|
+
if (rest.startsWith('edit/')) {
|
|
89
|
+
return {
|
|
90
|
+
view: 'templates',
|
|
91
|
+
key: '',
|
|
92
|
+
task: '',
|
|
93
|
+
mode: 'edit',
|
|
94
|
+
id: decodeURIComponent(rest.slice(5)),
|
|
95
|
+
topic: '',
|
|
96
|
+
scope: '',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (rest === 'new') {
|
|
100
|
+
return {
|
|
101
|
+
view: 'templates',
|
|
102
|
+
key: '',
|
|
103
|
+
task: '',
|
|
104
|
+
mode: 'new',
|
|
105
|
+
id: '',
|
|
106
|
+
topic: qs.get('topic') || '',
|
|
107
|
+
scope: qs.get('scope') || '',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return { view: 'templates', key: '', task: '', mode: '', id: '', topic: '', scope: '' };
|
|
111
|
+
}
|
|
112
|
+
const KNOWN = ['global', 'overview', 'cloud', 'todo', 'repos'];
|
|
85
113
|
if (KNOWN.includes(path)) {
|
|
86
114
|
// 全局池的页:#/global?task=1 —— 全局池的子任务表与页都在同一路由下
|
|
87
115
|
return { view: path === 'todo' ? 'cloud' : path, key: path === 'global' ? '__GLOBAL__' : '', task: path === 'global' ? task : '' };
|
|
@@ -340,7 +368,7 @@ export default function App() {
|
|
|
340
368
|
if (!m) return;
|
|
341
369
|
const spec = panelSpecOfRoute(route, specCtxRef.current);
|
|
342
370
|
if (!spec) return;
|
|
343
|
-
const routeSig = `${route.view}|${route.key}|${route.task}|${route.repoKey || ''}|${route.boardKey || ''}`;
|
|
371
|
+
const routeSig = `${route.view}|${route.key}|${route.task}|${route.repoKey || ''}|${route.boardKey || ''}|${route.mode || ''}|${route.id || ''}|${route.topic || ''}|${route.scope || ''}`;
|
|
344
372
|
const prev = openedRef.current;
|
|
345
373
|
if (prev.route === routeSig && prev.key === specCtxKey) return;
|
|
346
374
|
openedRef.current = { route: routeSig, key: specCtxKey };
|
|
@@ -401,6 +429,10 @@ export default function App() {
|
|
|
401
429
|
&& prev.repoKey === next.repoKey
|
|
402
430
|
&& prev.boardKey === next.boardKey
|
|
403
431
|
&& prev.boardName === next.boardName
|
|
432
|
+
&& prev.mode === next.mode
|
|
433
|
+
&& prev.id === next.id
|
|
434
|
+
&& prev.topic === next.topic
|
|
435
|
+
&& prev.scope === next.scope
|
|
404
436
|
? prev
|
|
405
437
|
: next
|
|
406
438
|
));
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
// primary 主按钮:实色块。**一个页面只能出现一个**——由使用约定保证,
|
|
7
7
|
// 页面里第二颗想强调的按钮请降级 secondary。
|
|
8
8
|
// secondary 次级按钮:浅底(.btn.ghost),表格行、工具栏里的默认形态。
|
|
9
|
-
// DropdownButton
|
|
9
|
+
// DropdownButton 下拉按钮:文字右侧带向下箭头,点击展开菜单(#138)。
|
|
10
10
|
//
|
|
11
11
|
// 现状(迁移口径):全库还有 ~30 个文件用裸 `<button className="btn ...">`,
|
|
12
12
|
// 一次性替换 300+ 处风险过大;设置页(任务点名的重灾区)已换成本组件,
|
|
13
13
|
// 其余页面靠 CSS 统一尺寸,后续按页面渐进迁移。图标按钮(.iconbtn 26×26)、
|
|
14
14
|
// 开关(.toggle)不属于这三分类,不走本组件。
|
|
15
|
-
import { useState } from 'react';
|
|
15
|
+
import { useEffect, useRef, useState } from 'react';
|
|
16
16
|
import './style.css';
|
|
17
17
|
|
|
18
18
|
const VARIANT_CLASS = { primary: '', secondary: 'ghost' };
|
|
@@ -48,8 +48,8 @@ export function Button({
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* 下拉按钮:文字 +
|
|
52
|
-
*
|
|
51
|
+
* 下拉按钮:文字 + 右侧向下箭头,**点击**展开菜单(#138:不要 hover)。
|
|
52
|
+
* 菜单贴按钮左缘;点菜单项 / 点外侧 / Esc 关闭。
|
|
53
53
|
*
|
|
54
54
|
* @param {object} props
|
|
55
55
|
* @param {string} props.label 按钮文字
|
|
@@ -59,13 +59,40 @@ export function Button({
|
|
|
59
59
|
*/
|
|
60
60
|
export function DropdownButton({ label, items = [], onSelect, variant = 'secondary', className = '', ...rest }) {
|
|
61
61
|
const [open, setOpen] = useState(false);
|
|
62
|
+
const rootRef = useRef(null);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!open) return undefined;
|
|
66
|
+
const onDoc = (e) => {
|
|
67
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false);
|
|
68
|
+
};
|
|
69
|
+
const onKey = (e) => {
|
|
70
|
+
if (e.key === 'Escape') setOpen(false);
|
|
71
|
+
};
|
|
72
|
+
document.addEventListener('mousedown', onDoc);
|
|
73
|
+
document.addEventListener('keydown', onKey);
|
|
74
|
+
return () => {
|
|
75
|
+
document.removeEventListener('mousedown', onDoc);
|
|
76
|
+
document.removeEventListener('keydown', onKey);
|
|
77
|
+
};
|
|
78
|
+
}, [open]);
|
|
79
|
+
|
|
62
80
|
return (
|
|
63
81
|
<span
|
|
82
|
+
ref={rootRef}
|
|
64
83
|
className={'nx-btn-dd' + (open ? ' open' : '') + (className ? ' ' + className : '')}
|
|
65
|
-
onMouseEnter={() => setOpen(true)}
|
|
66
|
-
onMouseLeave={() => setOpen(false)}
|
|
67
84
|
>
|
|
68
|
-
<Button
|
|
85
|
+
<Button
|
|
86
|
+
variant={variant}
|
|
87
|
+
className="nx-btn-dd-main"
|
|
88
|
+
aria-haspopup="menu"
|
|
89
|
+
aria-expanded={open}
|
|
90
|
+
{...rest}
|
|
91
|
+
onClick={(e) => {
|
|
92
|
+
rest.onClick && rest.onClick(e);
|
|
93
|
+
setOpen((v) => !v);
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
69
96
|
{label}
|
|
70
97
|
<span className="nx-btn-dd-arrow" aria-hidden="true">▾</span>
|
|
71
98
|
</Button>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
.nx-btn-dd { position: relative; display: inline-flex; }
|
|
4
4
|
|
|
5
|
-
/*
|
|
5
|
+
/* 箭头:文字右侧;打开态轻微下沉示意展开(#138:点击开关,非 hover) */
|
|
6
6
|
.nx-btn-dd-arrow { font-size: 10px; line-height: 1; transform: translateY(0); transition: transform .12s ease; }
|
|
7
7
|
.nx-btn-dd.open .nx-btn-dd-arrow { transform: translateY(1px); }
|
|
8
8
|
|
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
// 布局与任务页一致:`[面包屑] [标题·路径]` 一行、`[更多 · 保存]` 右对齐,
|
|
4
4
|
// 下面是编辑器本体。
|
|
5
5
|
//
|
|
6
|
-
// 「更多」按 编辑 / 文档 / 查看 三层分组(沿用任务页 ToolBar
|
|
7
|
-
//
|
|
8
|
-
|
|
6
|
+
// 「更多」按 编辑 / 文档 / 查看 三层分组(沿用任务页 ToolBar 口径);
|
|
7
|
+
// #143:与 task/group/dir 同套 tool-acts 编排(顺序/显隐)。
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
9
10
|
import { MenuPortal, openMenuAt, useMenu } from '../md/tool-bar.jsx';
|
|
11
|
+
import { inMoreOf, metaOf, onBarOf } from '../tool-acts/modules.js';
|
|
12
|
+
import { useToolActsLayout } from '../tool-acts/use-layout.js';
|
|
13
|
+
import ToolActsLayoutPanel from '../tool-acts/layout-panel.jsx';
|
|
14
|
+
import '../tool-acts/style.css';
|
|
15
|
+
|
|
16
|
+
const KIND = 'doc';
|
|
17
|
+
|
|
18
|
+
const MENU_GROUPS = [
|
|
19
|
+
{ id: 'edit', label: '编辑' },
|
|
20
|
+
{ id: 'doc', label: '文档' },
|
|
21
|
+
{ id: 'view', label: '查看' },
|
|
22
|
+
];
|
|
10
23
|
|
|
11
24
|
/**
|
|
12
25
|
* @param {object} p
|
|
@@ -16,7 +29,7 @@ import { MenuPortal, openMenuAt, useMenu } from '../md/tool-bar.jsx';
|
|
|
16
29
|
* @param {boolean} p.dirty 未保存
|
|
17
30
|
* @param {boolean} p.writable 可写(false 时不给「保存」与编辑类菜单)
|
|
18
31
|
* @param {() => void} p.onSave
|
|
19
|
-
* @param {Array<{label: string, items: Array}>} p.menuGroups
|
|
32
|
+
* @param {Array<{label: string, items: Array}>} p.menuGroups 额外菜单分组(按 id 并入编排)
|
|
20
33
|
* @param {boolean} [p.saving]
|
|
21
34
|
* @param {boolean} [p.external] 外部文档(页头给「外部 · 可写回」提示)
|
|
22
35
|
* @param {React.ReactNode} [p.afterTitle] 标题行里追加的控件(模式切换等)
|
|
@@ -35,8 +48,93 @@ export default function DocHead({
|
|
|
35
48
|
afterTitle = null,
|
|
36
49
|
}) {
|
|
37
50
|
const more = useMenu();
|
|
51
|
+
const { layout, setLayout } = useToolActsLayout(KIND);
|
|
52
|
+
const [panelOpen, setPanelOpen] = useState(false);
|
|
53
|
+
|
|
54
|
+
// 把调用方 menuGroups 摊成 id → spec(动态 label/hint/run)
|
|
55
|
+
const specs = {};
|
|
56
|
+
for (const g of menuGroups || []) {
|
|
57
|
+
for (const a of g?.items || []) {
|
|
58
|
+
if (!a || !a.id) continue;
|
|
59
|
+
specs[a.id] = a;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
specs.save = onSave && {
|
|
63
|
+
id: 'save',
|
|
64
|
+
label: saving ? '保存中…' : onSaveLabel,
|
|
65
|
+
run: onSave,
|
|
66
|
+
primary: true,
|
|
67
|
+
disabled: saving || !dirty,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const available = (id) => id === 'more' || !!specs[id];
|
|
38
71
|
|
|
39
|
-
const
|
|
72
|
+
const barItems = layout.filter((x) => onBarOf(KIND, x) && available(x.id));
|
|
73
|
+
const moreItems = layout.filter((x) => inMoreOf(KIND, x) && available(x.id));
|
|
74
|
+
|
|
75
|
+
const runItem = (id) => {
|
|
76
|
+
specs[id]?.run?.();
|
|
77
|
+
more.setOpen(false);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const renderBarBtn = (id) => {
|
|
81
|
+
if (id === 'more') {
|
|
82
|
+
return (
|
|
83
|
+
<div className="docp-more" ref={more.ref} key="more">
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
className={`btn ghost sm${more.open ? ' on' : ''}`}
|
|
87
|
+
title="更多操作"
|
|
88
|
+
aria-haspopup="menu"
|
|
89
|
+
aria-expanded={more.open}
|
|
90
|
+
onClick={(e) => openMenuAt(more, e, 'right')}
|
|
91
|
+
>
|
|
92
|
+
更多
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const s = specs[id];
|
|
98
|
+
if (!s) return null;
|
|
99
|
+
return (
|
|
100
|
+
<button
|
|
101
|
+
key={id}
|
|
102
|
+
type="button"
|
|
103
|
+
className={s.primary || id === 'save' ? 'btn sm primary docp-save' : 'btn ghost sm'}
|
|
104
|
+
disabled={!!s.disabled}
|
|
105
|
+
onClick={() => runItem(id)}
|
|
106
|
+
>
|
|
107
|
+
{s.label || metaOf(KIND, id).label || id}
|
|
108
|
+
</button>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const groupedMore = MENU_GROUPS.map((g) => ({
|
|
113
|
+
...g,
|
|
114
|
+
items: moreItems.filter((x) => metaOf(KIND, x.id).menuGroup === g.id),
|
|
115
|
+
})).filter((g) => g.items.length);
|
|
116
|
+
const ungroupedMore = moreItems.filter((x) => !metaOf(KIND, x.id).menuGroup);
|
|
117
|
+
|
|
118
|
+
if (!writable) {
|
|
119
|
+
return (
|
|
120
|
+
<div className="mdw-top docp-top">
|
|
121
|
+
{crumb}
|
|
122
|
+
<div className="mdw-head">
|
|
123
|
+
<div className="mdw-title">{title || '文档'}</div>
|
|
124
|
+
<div className="mdw-path">
|
|
125
|
+
{pathLabel}
|
|
126
|
+
{dirty ? ' · 未保存' : ''}
|
|
127
|
+
{external ? ' · 外部' : ''}
|
|
128
|
+
</div>
|
|
129
|
+
<span className="grow" />
|
|
130
|
+
{afterTitle}
|
|
131
|
+
<div className="docp-actions">
|
|
132
|
+
<span className="docp-tag ext">只读</span>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
40
138
|
|
|
41
139
|
return (
|
|
42
140
|
<div className="mdw-top docp-top">
|
|
@@ -51,55 +149,73 @@ export default function DocHead({
|
|
|
51
149
|
<span className="grow" />
|
|
52
150
|
{afterTitle}
|
|
53
151
|
<div className="docp-actions">
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
152
|
+
{barItems.map((x) => renderBarBtn(x.id))}
|
|
153
|
+
|
|
154
|
+
<MenuPortal menu={more} className="mdw-act-menu">
|
|
155
|
+
{groupedMore.map((g) => (
|
|
156
|
+
<div className="mdw-fmt-menu-group" role="group" aria-label={g.label} key={g.id}>
|
|
157
|
+
<div className="mdw-fmt-menu-cap">{g.label}</div>
|
|
158
|
+
{g.items.map((x) => {
|
|
159
|
+
const s = specs[x.id];
|
|
160
|
+
const danger = s?.danger || metaOf(KIND, x.id).danger;
|
|
161
|
+
return (
|
|
162
|
+
<button
|
|
163
|
+
key={x.id}
|
|
164
|
+
type="button"
|
|
165
|
+
role="menuitem"
|
|
166
|
+
className={'mdw-fmt-menu-item' + (danger ? ' danger' : '')}
|
|
167
|
+
onClick={() => runItem(x.id)}
|
|
168
|
+
>
|
|
169
|
+
{s?.label || metaOf(KIND, x.id).label || x.id}
|
|
170
|
+
{s?.hint ? <span className="hint">{s.hint}</span> : null}
|
|
171
|
+
</button>
|
|
172
|
+
);
|
|
173
|
+
})}
|
|
174
|
+
</div>
|
|
175
|
+
))}
|
|
176
|
+
{ungroupedMore.map((x) => {
|
|
177
|
+
const s = specs[x.id];
|
|
178
|
+
return (
|
|
179
|
+
<button
|
|
180
|
+
key={x.id}
|
|
181
|
+
type="button"
|
|
182
|
+
role="menuitem"
|
|
183
|
+
className={'mdw-fmt-menu-item' + (s?.danger || metaOf(KIND, x.id).danger ? ' danger' : '')}
|
|
184
|
+
onClick={() => runItem(x.id)}
|
|
185
|
+
>
|
|
186
|
+
{s?.label || metaOf(KIND, x.id).label || x.id}
|
|
187
|
+
</button>
|
|
188
|
+
);
|
|
189
|
+
})}
|
|
190
|
+
<div className="mdw-fmt-menu-sep" role="separator" />
|
|
91
191
|
<button
|
|
92
192
|
type="button"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
onClick={
|
|
193
|
+
role="menuitem"
|
|
194
|
+
className="mdw-fmt-menu-item"
|
|
195
|
+
onClick={() => {
|
|
196
|
+
more.setOpen(false);
|
|
197
|
+
setPanelOpen(true);
|
|
198
|
+
}}
|
|
96
199
|
>
|
|
97
|
-
|
|
200
|
+
自定义工具栏…
|
|
98
201
|
</button>
|
|
99
|
-
|
|
100
|
-
{!writable && <span className="docp-tag ext">只读</span>}
|
|
202
|
+
</MenuPortal>
|
|
101
203
|
</div>
|
|
102
204
|
</div>
|
|
205
|
+
|
|
206
|
+
{panelOpen && createPortal(
|
|
207
|
+
<div className="ta-panel-mask" onClick={() => setPanelOpen(false)}>
|
|
208
|
+
<div className="ta-panel-wrap" onClick={(e) => e.stopPropagation()}>
|
|
209
|
+
<ToolActsLayoutPanel
|
|
210
|
+
kind={KIND}
|
|
211
|
+
layout={layout}
|
|
212
|
+
setLayout={setLayout}
|
|
213
|
+
onClose={() => setPanelOpen(false)}
|
|
214
|
+
/>
|
|
215
|
+
</div>
|
|
216
|
+
</div>,
|
|
217
|
+
document.body
|
|
218
|
+
)}
|
|
103
219
|
</div>
|
|
104
220
|
);
|
|
105
221
|
}
|
|
@@ -41,8 +41,11 @@ export function crumbsOf(route, ctx = {}) {
|
|
|
41
41
|
return ['云端总览'];
|
|
42
42
|
case 'overview':
|
|
43
43
|
return ['全部目录总览'];
|
|
44
|
-
case 'templates':
|
|
44
|
+
case 'templates': {
|
|
45
|
+
if (route.mode === 'new') return ['新建模板'];
|
|
46
|
+
if (route.mode === 'edit') return ['编辑模板'];
|
|
45
47
|
return ['任务模板'];
|
|
48
|
+
}
|
|
46
49
|
// 文档页(#88):只画**归属**(仓库 / 项目组)——文档名已经在 DocHead 的
|
|
47
50
|
// 标题行里,面包屑再画一遍就是同一行重复两遍。
|
|
48
51
|
case 'doc': {
|
|
@@ -140,17 +140,26 @@ export default function AttachArea({
|
|
|
140
140
|
const emptyAll = !loading && !error && !list.length;
|
|
141
141
|
|
|
142
142
|
return (
|
|
143
|
-
<div
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
<div
|
|
144
|
+
className={`att-area${disabled ? ' is-disabled' : ''}`}
|
|
145
|
+
// 拖放落点是**整个附件区**:空态提示写着「拖文件到这里」,落点只盖头部
|
|
146
|
+
// 一条的话提示区反而是空的(md/pdf 等文件拖上去落空,触发浏览器默认打开文件)。
|
|
147
|
+
onDragOver={(e) => {
|
|
148
|
+
if (disabled || ![...(e.dataTransfer?.types || [])].includes('Files')) return;
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
setDragOver(true);
|
|
151
|
+
}}
|
|
152
|
+
onDragLeave={(e) => {
|
|
153
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setDragOver(false);
|
|
154
|
+
}}
|
|
155
|
+
onDrop={(e) => {
|
|
156
|
+
setDragOver(false);
|
|
157
|
+
if (disabled || ![...(e.dataTransfer?.types || [])].includes('Files')) return;
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
dropFiles(null, e);
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
<div className={'att-area-head' + (dragOver && !disabled ? ' is-over' : '')}>
|
|
154
163
|
<span className="att-area-title">
|
|
155
164
|
附件
|
|
156
165
|
{list.length ? <span className="att-count">{list.length}</span> : null}
|
|
@@ -11,7 +11,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
11
11
|
import { Modal } from '../popup/index.jsx';
|
|
12
12
|
import { api } from '../../api/client.js';
|
|
13
13
|
import { clipboardFiles, droppedFiles, readableName, uploadOne } from '../cloud/upload.js';
|
|
14
|
-
import
|
|
14
|
+
import StatusTag from '../status-tag/index.jsx';
|
|
15
15
|
import {
|
|
16
16
|
attachBodyOf,
|
|
17
17
|
badgeOf,
|
|
@@ -317,7 +317,8 @@ export default function AttachModal({
|
|
|
317
317
|
{taskList.map((t) => (
|
|
318
318
|
<button key={t.id} type="button" className="att-pick-item" onClick={() => addTask(t)}>
|
|
319
319
|
<span className="att-pick-main">#{t.id} {taskTitleOf(t) || '(无标题)'}</span>
|
|
320
|
-
|
|
320
|
+
{/* #121 统一组件:配色由 tstat-* 接管,att-sbadge 只给尺寸 */}
|
|
321
|
+
<StatusTag t={t} className="att-sbadge" />
|
|
321
322
|
</button>
|
|
322
323
|
))}
|
|
323
324
|
</div>
|
|
@@ -27,7 +27,7 @@ import { openBesideMain } from '../../workspace.js';
|
|
|
27
27
|
* onInsert({index, embed, at, caret}):调用方做正文替换(两处编辑器口径不同:
|
|
28
28
|
* 块内替换 vs 全文替换)。
|
|
29
29
|
*/
|
|
30
|
-
export function useAttachPicker({ host, onInsert }) {
|
|
30
|
+
export function useAttachPicker({ host, itemsOverride = null, onInsert }) {
|
|
31
31
|
const [menu, setMenu] = useState(null); // {index, at, caret, x, y, query, active, loading, error}
|
|
32
32
|
const [items, setItems] = useState([]);
|
|
33
33
|
// host 是对象 prop(每次渲染新对象)——依赖用序列化后的**身份字段**(不含
|
|
@@ -38,7 +38,10 @@ export function useAttachPicker({ host, onInsert }) {
|
|
|
38
38
|
|
|
39
39
|
const load = useCallback(async () => {
|
|
40
40
|
if (!host) {
|
|
41
|
+
// 草稿没有 v2 取数描述(清单来自会话 doc 的 itemsOverride)——
|
|
42
|
+
// 但**必须**把 loading 收掉,否则面板永远停在「读取附件…」(#111 实测)。
|
|
41
43
|
setItems([]);
|
|
44
|
+
setMenu((cur) => (cur ? { ...cur, loading: false, error: '' } : cur));
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
44
47
|
try {
|
|
@@ -53,7 +56,7 @@ export function useAttachPicker({ host, onInsert }) {
|
|
|
53
56
|
}, [hostKey]); // host 是对象 prop,用序列化后的 key 做依赖(每次渲染新对象)
|
|
54
57
|
|
|
55
58
|
const open = useCallback(({ index, ta, at, caret }) => {
|
|
56
|
-
if (!
|
|
59
|
+
if (!ta) return;
|
|
57
60
|
const rect = ta.getBoundingClientRect();
|
|
58
61
|
const lineH = 20;
|
|
59
62
|
const line = caretLineCol(ta.value, caret).line;
|
|
@@ -65,11 +68,12 @@ export function useAttachPicker({ host, onInsert }) {
|
|
|
65
68
|
|
|
66
69
|
const close = useCallback(() => setMenu((cur) => (cur ? null : cur)), []);
|
|
67
70
|
|
|
71
|
+
const source = itemsOverride !== undefined && itemsOverride !== null ? itemsOverride : items;
|
|
68
72
|
const filtered = useMemo(() => {
|
|
69
73
|
const q = String(menu?.query || '').trim().toLowerCase();
|
|
70
|
-
if (!q) return
|
|
71
|
-
return
|
|
72
|
-
}, [
|
|
74
|
+
if (!q) return source;
|
|
75
|
+
return source.filter((a) => String(a.name || a.title || a.locator || '').toLowerCase().includes(q));
|
|
76
|
+
}, [source, menu?.query]);
|
|
73
77
|
|
|
74
78
|
const active = filtered.length
|
|
75
79
|
? Math.min(Math.max(0, menu?.active ?? 0), filtered.length - 1)
|
|
@@ -114,9 +118,11 @@ export default function AttachPicker({
|
|
|
114
118
|
position,
|
|
115
119
|
host = null, // 取数描述(含 allow / taskOptions——「添加附件」弹窗要用)
|
|
116
120
|
onReload = null, // 添加附件成功后刷新清单
|
|
121
|
+
onAddFiles = null, // 草稿通道(无 host):文件进会话 doc 附件,插入点由调用方管
|
|
117
122
|
}) {
|
|
118
123
|
const listRef = useRef(null);
|
|
119
124
|
const inputRef = useRef(null);
|
|
125
|
+
const fileRef = useRef(null);
|
|
120
126
|
const app = useApp() || {};
|
|
121
127
|
const [addOpen, setAddOpen] = useState(false);
|
|
122
128
|
|
|
@@ -240,7 +246,7 @@ export default function AttachPicker({
|
|
|
240
246
|
<div className="mdw-atpick-foot">
|
|
241
247
|
<span className="mdw-atpick-cap">↑↓ 选择 · Enter 引用 · Esc 取消</span>
|
|
242
248
|
<span className="grow" />
|
|
243
|
-
{host
|
|
249
|
+
{host ? (
|
|
244
250
|
<button
|
|
245
251
|
type="button"
|
|
246
252
|
className="mdw-atpick-add"
|
|
@@ -250,8 +256,32 @@ export default function AttachPicker({
|
|
|
250
256
|
>
|
|
251
257
|
+ 添加附件
|
|
252
258
|
</button>
|
|
253
|
-
)
|
|
259
|
+
) : onAddFiles ? (
|
|
260
|
+
<button
|
|
261
|
+
type="button"
|
|
262
|
+
className="mdw-atpick-add"
|
|
263
|
+
title="上传本机文件(草稿:先挂进会话草稿,提交任务时一并带上)"
|
|
264
|
+
onMouseDown={(e) => e.preventDefault()}
|
|
265
|
+
onClick={() => fileRef.current?.click()}
|
|
266
|
+
>
|
|
267
|
+
+ 添加附件
|
|
268
|
+
</button>
|
|
269
|
+
) : null}
|
|
254
270
|
</div>
|
|
271
|
+
{onAddFiles && (
|
|
272
|
+
<input
|
|
273
|
+
ref={fileRef}
|
|
274
|
+
type="file"
|
|
275
|
+
multiple
|
|
276
|
+
hidden
|
|
277
|
+
onChange={(e) => {
|
|
278
|
+
// 快照成数组:FileList 是输入框的**活视图**,面板重渲染把它换掉就空了
|
|
279
|
+
const files = Array.from(e.target.files || []);
|
|
280
|
+
if (files.length) onAddFiles(files);
|
|
281
|
+
if (fileRef.current) fileRef.current.value = '';
|
|
282
|
+
}}
|
|
283
|
+
/>
|
|
284
|
+
)}
|
|
255
285
|
{host && (
|
|
256
286
|
<AttachModal
|
|
257
287
|
open={addOpen}
|