nx-kv 0.24.0 → 0.24.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +21 -0
- package/package.json +1 -1
- package/src/modules/docs/knowledge.js +175 -64
- package/src/modules/docs/refs.js +26 -3
- package/src/modules/repos/boards.js +25 -1
- package/src/modules/repos/index.js +5 -2
- package/src/modules/tasktool/groupctx.js +38 -4
- package/src/runtime/api.js +6 -23
- package/src/runtime/cli.js +8 -3
- package/src/runtime/cors.js +125 -0
- package/src/runtime/server.js +14 -1
- package/src/web/frontend/components/Introduction/index.jsx +5 -1
- package/src/web/frontend/components/Introduction/use-intro.js +31 -9
- package/src/web/public/assets/Introduction-Dr99GN_o.js +1 -0
- package/src/web/public/assets/{cloud-E33bm4CD.js → cloud-BJbs3IuB.js} +1 -1
- package/src/web/public/assets/{dag-ClRadqiu.js → dag-DBydHtGQ.js} +1 -1
- package/src/web/public/assets/{dir-Dj-3QRkO.js → dir-DgWqKcbC.js} +1 -1
- package/src/web/public/assets/{group-Ckwoc5tW.js → group-ji7zeaXJ.js} +1 -1
- package/src/web/public/assets/{index-DMp4lRKl.js → index-CHHRdALV.js} +2 -2
- package/src/web/public/assets/{md-history-CwtrJcZo.js → md-history-H16pOkv6.js} +1 -1
- package/src/web/public/assets/{member-picker-BV1a-LiO.js → member-picker-BmVwgSWB.js} +1 -1
- package/src/web/public/assets/{overview-CQW1MViJ.js → overview-BNovkb_k.js} +1 -1
- package/src/web/public/assets/{progress-CDiNmHVI.js → progress-Ck-s4Ypp.js} +1 -1
- package/src/web/public/assets/{repos-BYFj2sjE.js → repos-A2URD6SC.js} +1 -1
- package/src/web/public/assets/{route-crumb-DSgy8FTp.js → route-crumb-x1Za8gFU.js} +1 -1
- package/src/web/public/assets/{settings-BoAQ5YXH.js → settings-DNZkV_Be.js} +1 -1
- package/src/web/public/assets/{task-Br1K-bzV.js → task-BqQw-96B.js} +1 -1
- package/src/web/public/assets/{template-slots-CMB5ZTZE.js → template-slots-DTd6DvJ3.js} +1 -1
- package/src/web/public/assets/{templates-DMVIPsdx.js → templates-CHvZ38Vw.js} +1 -1
- package/src/web/public/assets/{upload-CzfyPGrk.js → upload-BM8dlfZG.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/Introduction-DGcd3YBk.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{W as o,a as s,c,i as l,j as u,n as d,o as f,q as p,r as m}from"./index-
|
|
1
|
+
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{W as o,a as s,c,i as l,j as u,n as d,o as f,q as p,r as m}from"./index-CHHRdALV.js";import{t as h}from"./template-slots-DTd6DvJ3.js";var g=n(t(),1),_=e();function v(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function y({value:e,onChange:t,placeholder:n,rows:r=3,sections:i=!1,hint:a=``}){let[o,u]=(0,g.useState)(!1),d=(0,g.useRef)(null),f=(0,g.useRef)(null),p=n=>{let r=d.current,i=r?r.selectionStart:null,a=s(e,n,i);t(a.text),u(!1),requestAnimationFrame(()=>{let e=d.current;if(e){e.focus();try{e.setSelectionRange(a.caret,a.caret)}catch{}}})},h=c(e);return(0,_.jsxs)(`div`,{className:`pp-field`,ref:f,children:[(0,_.jsx)(`textarea`,{ref:d,className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value),onBlur:()=>{requestAnimationFrame(()=>{f.current&&f.current.contains(document.activeElement)||u(!1)})}}),(0,_.jsxs)(`div`,{className:`pp-field-bar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-ph-btn`+(o?` on`:``),title:`插入占位符`,onClick:()=>u(e=>!e),children:[`{`,`占位符`,`}`]}),h.length>0&&(0,_.jsx)(`span`,{className:`pp-field-used`,title:`本条用到的占位符`,children:h.map(e=>(0,_.jsx)(`span`,{className:`pp-field-used-chip mono`,children:`{{${e}}}`},e))}),o&&(0,_.jsxs)(`div`,{className:`pp-field-menu`,role:`menu`,children:[m.map(e=>(0,_.jsxs)(`div`,{className:`pp-field-menu-sec`,children:[(0,_.jsx)(`div`,{className:`pp-field-menu-lab`,children:e.label}),e.items.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-menu-item`,title:e.desc,onMouseDown:t=>{t.preventDefault(),p(`{{${e.token}}}`)},children:[(0,_.jsx)(`span`,{className:`mono`,children:`{{${e.token}}}`}),(0,_.jsx)(`span`,{className:`pp-field-menu-desc`,children:e.desc})]},e.token))]},e.label)),i&&(0,_.jsxs)(`div`,{className:`pp-field-menu-sec`,children:[(0,_.jsx)(`div`,{className:`pp-field-menu-lab`,children:`段落`}),l.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-menu-item`,onMouseDown:t=>{t.preventDefault(),p(e.token)},children:[(0,_.jsx)(`span`,{className:`mono`,children:e.token}),(0,_.jsx)(`span`,{className:`pp-field-menu-desc`,children:e.label})]},e.token))]})]})]}),a?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:a}):null]})}function b({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,sections:a=!1,hint:o=``,accordion:s=!1,openIndex:c,onOpenChange:l}){let[u,d]=(0,g.useState)(-1),f=c===void 0?u:c,p=e=>{d(e),l&&l(e)},m=(n,r)=>t(e.map((e,t)=>t===n?r:e)),h=n=>{t(e.filter((e,t)=>t!==n)),p(e=>e===n?-1:e>n?e-1:e)};return s?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let o=f===t,s=v(e.split(`
|
|
2
2
|
`)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>p(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:s||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a,hint:o})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var x=10,S=[{id:`template`,label:`任务模板`},{id:`suffix`,label:`回调提示词`},{id:`ack`,label:`ack 总结`}];function C({listFlag:e,listKey:t,placeholder:n,offText:r}){let i=a(),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(-1),f=(0,g.useCallback)(()=>{p(`/api/localtasks`).then(e=>s(e?.settings?.[t]??[])).catch(e=>i(`读取失败:`+(e.message||e)))},[t,i]);(0,g.useEffect)(()=>{f()},[f]);let m=async n=>{if(!(n==null||c)){l(!0);try{let a=(await p(`/api/localtasks/setting`,{method:`PATCH`,body:{[e]:n}}))?.[t]??[];s(a),i(a.length?`已保存(${a.length} 条)`:r)}catch(e){i(String(e.message||e))}finally{l(!1)}}};return(0,_.jsxs)(`div`,{className:`setp-suffix`,children:[o!==null&&!o.length&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`已关闭`}),o!==null&&(0,_.jsx)(b,{items:o,onChange:s,disabled:c,placeholder:n,sections:!0,accordion:!0,openIndex:u,onOpenChange:d}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:c||o===null||o.length>=x,onClick:()=>{let e=o.length;s([...o,``]),d(e)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:c||o===null,onClick:()=>m(o),children:`保存`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:c||o===null,onClick:()=>m([]),title:r,children:`关闭`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:c,onClick:f,children:`撤销改动`})]})]})}function w({openTemplates:e}){let t=a(),n=d(),[r,i]=(0,g.useState)(!1),o=n.templates||[],[s,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!o.length){c(null);return}(!s||!o.some(e=>e.id===s))&&c(n.defaultId||o[0].id)},[o,n.defaultId,s]);let l=o.find(e=>e.id===s)||null,u=l?f(l.body,l.values||{}):``,p=async(e,r)=>{i(!0);try{await n.update(e.id,{values:r}),t(`已保存「${e.name}」的槽位内容`)}catch(e){t(String(e.message||e))}finally{i(!1)}};return n.unsupported?(0,_.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`}):o.length?(0,_.jsxs)(`div`,{className:`setp-tpl-split`,children:[(0,_.jsxs)(`div`,{className:`setp-tpl-side`,children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`选用模板`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e?.(),children:`管理…`})]}),(0,_.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`任务模板`,children:o.map(e=>(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===s,className:`setp-tpl-pick${e.id===s?` is-on`:``}`,onClick:()=>c(e.id),children:[(0,_.jsx)(`span`,{className:`setp-tpl-name`,children:e.name}),e.id===n.defaultId&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`默认`}),e.builtin&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`内置`})]},e.id))})]}),(0,_.jsx)(`div`,{className:`setp-tpl-main`,children:l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsxs)(`span`,{children:[`槽位内容 · `,l.name]})}),(0,_.jsx)(h,{body:l.body,values:l.values,disabled:r,onSave:e=>p(l,e)}),u.trim()?(0,_.jsxs)(`details`,{className:`setp-tpl-preview`,children:[(0,_.jsx)(`summary`,{children:`预览新建任务正文`}),(0,_.jsx)(`pre`,{className:`setp-tpl-preview-body`,children:u})]}):null]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`从左侧选一个模板。`})})]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`})}function T({openTemplates:e}){let[t,n]=(0,g.useState)(`template`);return(0,_.jsxs)(`div`,{className:`setp-prompts`,children:[(0,_.jsx)(`nav`,{className:`setp-prompts-nav`,"aria-label":`提示词与模板分类`,children:S.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`setp-prompts-tab${t===e.id?` is-on`:``}`,onMouseEnter:()=>n(e.id),onClick:()=>n(e.id),children:e.label},e.id))}),(0,_.jsxs)(`div`,{className:`setp-prompts-pane`,children:[t===`template`&&(0,_.jsx)(w,{openTemplates:e}),t===`suffix`&&(0,_.jsx)(C,{listFlag:`suffixList`,listKey:`taskSuffixList`,placeholder:`一条收尾指令(支持 {{task.text}} / {{goal.*}} 占位符)`,offText:`已关闭回调提示词`}),t===`ack`&&(0,_.jsx)(C,{listFlag:`ackList`,listKey:`ackPromptList`,placeholder:`例如:完成总结按「改了什么 · 怎么验证 · 遗留什么」三段写,每段一行`,offText:`已关闭 ack 提示词`})]})]})}var E=10,D=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。`,O=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`prompts`,label:`提示词 / 模板`,icon:`list`},{id:`template`,label:`任务工具`,icon:`clock`},{id:`project`,label:`项目级设置`,icon:`repo`}];function k({repo:e,docStateOf:t,openDoc:n,bindExternal:r,unbind:s}){let c=o()||{},l=a(),[u,d]=(0,g.useState)(e.icon||``),[f,m]=(0,g.useState)(!1),[h,v]=(0,g.useState)(!1);(0,g.useEffect)(()=>{d(e.icon||``)},[e.icon]);let y=async t=>{let n=String(t??u).trim();if(n===String(e.icon||``).trim()){m(!1);return}v(!0);try{await p(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{icon:n}}),d(n),l(n?`已保存「${e.name}」的图标`:`已清除「${e.name}」的图标`),c.refreshRepos&&c.refreshRepos(),m(!1)}catch(e){l(String(e.message||e))}finally{v(!1)}},b=t(e),x=!!(e.getLoop&&e.getLoop.enabled);return(0,_.jsxs)(`div`,{className:`setp-proj`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-head`,children:[(0,_.jsx)(`div`,{className:`setp-icon`+(f?` open`:``),children:(0,_.jsx)(`button`,{type:`button`,className:`setp-icon-btn`,title:u?`项目图标:${u}(点击修改)`:`设置项目图标(emoji / 单字符)`,"aria-label":`项目图标`,"aria-expanded":f,onClick:()=>m(e=>!e),children:u?(0,_.jsx)(`span`,{className:`setp-icon-glyph`,"aria-hidden":!0,children:u}):(0,_.jsx)(i,{name:`folder`,size:14})})}),(0,_.jsxs)(`div`,{className:`setp-proj-meta`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-t`,children:[(0,_.jsx)(`b`,{children:e.name}),(0,_.jsx)(`span`,{className:`setp-badge `+b.kind,children:b.kind===`external`?`外部`:b.kind===`own`?`自有`:`约定`}),x&&(0,_.jsx)(`span`,{className:`setp-badge loop`,children:`持续 get`})]}),(0,_.jsx)(`div`,{className:`setp-proj-p mono`,title:b.label,children:b.label})]}),(0,_.jsxs)(`div`,{className:`setp-proj-actions`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>n(e),children:`介绍`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>r(e),children:`绑定…`}),e.doc?(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>s(e),children:`解绑`}):null]})]}),f&&(0,_.jsxs)(`div`,{className:`setp-icon-edit`,role:`group`,"aria-label":`编辑项目图标`,children:[(0,_.jsx)(`input`,{autoFocus:!0,value:u,maxLength:8,placeholder:`emoji 或单字符`,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),y(u)),t.key===`Escape`&&(t.preventDefault(),d(e.icon||``),m(!1))},disabled:h}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:h,onClick:()=>y(u),children:`保存`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h||!u,title:`清空,侧栏回退默认文件夹图标`,onClick:()=>y(``),children:`清除`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h,onClick:()=>{d(e.icon||``),m(!1)},children:`取消`})]}),(0,_.jsx)(j,{repo:e})]})}var A=2e3;function j({repo:e}){let t=o()||{},n=a(),r=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[i,s]=(0,g.useState)(!!(r&&r.enabled)),[c,l]=(0,g.useState)(String(r&&r.waitMinutes||10)),[u,d]=(0,g.useState)(()=>{let e=r&&r.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[f,m]=(0,g.useState)(-1),[h,v]=(0,g.useState)(``),[y,x]=(0,g.useState)([]),[S,C]=(0,g.useState)(!1);(0,g.useEffect)(()=>{p(`/api/localtasks`).then(e=>x(e?.settings?.taskSuffixList??[])).catch(()=>x([]))},[]);let w=async()=>{C(!0);try{let r=u.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,E);await p(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:i,...i?{waitMinutes:Number(c)||10,template:r}:{}}}}),n(i?`已保存「${e.name}」的持续 get 设置(模板 ${r.length} 条)`:`已关闭「${e.name}」的持续 get`),t.refreshRepos&&t.refreshRepos()}catch(e){n(String(e.message||e))}finally{C(!1)}},T=()=>{let e=h.trim();!e||u.length>=E||(d([...u,e.slice(0,A)]),m(u.length),v(``))},O=e=>v(e);return i?(0,_.jsxs)(`div`,{className:`setp-loop`,children:[(0,_.jsxs)(`label`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`持续 get(waitgoal)`}),(0,_.jsxs)(`button`,{className:`toggle`+(i?` on`:``),onClick:()=>s(!1),children:[(0,_.jsx)(`span`,{className:`dot`}),i?`开`:`关`]})]}),i&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口(分钟)`}),(0,_.jsx)(`input`,{className:`setp-min`,value:c,onChange:e=>l(e.target.value),inputMode:`numeric`})]}),(0,_.jsxs)(`div`,{className:`setp-oneline`,children:[(0,_.jsxs)(`select`,{className:`setp-oneline-pick`,value:``,title:`选提示词模板填入下方输入框`,onChange:e=>{e.target.value&&O(e.target.value),e.target.value=``},children:[(0,_.jsx)(`option`,{value:``,children:`选模板…`}),(0,_.jsx)(`option`,{value:D,children:`内置默认(继续 get 直到 timeout)`}),y.map((e,t)=>(0,_.jsx)(`option`,{value:e,children:(e.split(`
|
|
3
3
|
`)[0]||``).slice(0,40)||`回调提示词 ${t+1}`},t))]}),(0,_.jsx)(`input`,{className:`setp-oneline-input`,value:h,placeholder:`一句话(%s = 任务编号),选模板后可改`,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T()}}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:S||!h.trim(),onClick:T,children:`添加`})]}),u.length?(0,_.jsx)(b,{items:u,onChange:d,disabled:S,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:f,onOpenChange:m}):(0,_.jsx)(`div`,{className:`setp-note`,children:`未配置模板 —— 用默认「继续调用 localtask get 直到 timeout」。`}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:S||u.length>=E,title:u.length>=E?`最多 ${E} 条`:`新增一条「继续 get」指令`,onClick:()=>{d([...u,``]),m(u.length)},children:`添加一条…`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:S,onClick:w,children:`保存持续 get 设置`})]})]})]}):(0,_.jsxs)(`button`,{className:`setp-gl-off`,title:`开启持续 get(waitgoal)`,onClick:()=>s(!0),children:[(0,_.jsx)(`span`,{className:`dot`}),`持续 get`]})}function M(){let e=o()||{},t=a(),{dialog:n,node:s}=r(),c=e.prefs||{},l=e.patchPrefs||(()=>{}),d=e.model,f=e.repoData&&e.repoData.repos||[],[m,h]=(0,g.useState)(`pref`),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(!1),S=(0,g.useCallback)(async()=>{try{y(await p(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,g.useEffect)(()=>{S()},[S]);let C=e=>e().catch(e=>t(String(e.message||e))),w=e=>C(async()=>{x(!0);try{y(await p(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{x(!1)}}),E=e=>e.doc&&e.doc.path?{kind:`external`,docId:`path:`+e.doc.path,label:e.doc.path}:e.doc&&e.doc.rel?{kind:`own`,docId:`rel:`+e.doc.rel,label:e.doc.rel}:{kind:`default`,docId:`rel:`+(e.docRel||``),label:e.docRel||`(未创建)`},D=e=>{if(!d)return;let n=E(e);if(!n.docId||n.docId===`rel:`)return t(`这个项目还没有介绍文档`);u(d,{component:`doc`,name:e.name+` · 介绍`,config:{docId:n.docId},location:`center`})},A=r=>C(async()=>{let i=await n({title:`绑定外部介绍文档`,input:!0,placeholder:`D:\\vault\\nx\\nx-kv.md(只读引用,不进导出包)`});i&&(await p(`/api/docs/bind`,{method:`POST`,body:{repo:r.key,path:i.trim()}}),t(`已绑定:${i.trim()}`),e.refreshRepos&&e.refreshRepos())}),j=n=>C(async()=>{await p(`/api/docs/bind`,{method:`POST`,body:{repo:n.key,reset:!0}}),t(`已解除绑定(回到约定路径)`),e.refreshRepos&&e.refreshRepos()}),M={pref:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`侧边栏默认收起`}),(0,_.jsxs)(`button`,{className:`toggle`+(c.defaultFolded?` on`:``),onClick:()=>l({defaultFolded:!c.defaultFolded}),children:[(0,_.jsx)(`span`,{className:`dot`}),c.defaultFolded?`开`:`关`]})]}),(c.hidden||[]).length>0&&(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsxs)(`span`,{children:[`隐藏仓库 `,c.hidden.length,` 个`]}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>l({hidden:[]}),children:`恢复显示`})]})]}),work:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`布局`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:async()=>{await n({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,_.jsxs)(`button`,{className:`toggle`+(v&&v.autoSyncAttachments?` on`:``),disabled:!v||b,onClick:()=>w({autoSyncAttachments:!v.autoSyncAttachments}),children:[(0,_.jsx)(`span`,{className:`dot`}),v&&v.autoSyncAttachments?`开`:`关`]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`附件目录`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>y(t=>({...t,attachmentsDir:e.target.value}))}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({attachmentsDir:v.attachmentsDir}),children:`保存`})]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`参考仓库存储根`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>y(t=>({...t,gitRepoRoot:e.target.value}))}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({gitRepoRoot:v.gitRepoRoot}),children:`保存`})]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`开发仓库克隆根`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>y(t=>({...t,gitDevRoot:e.target.value}))}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),prompts:(0,_.jsx)(T,{openTemplates:()=>{d&&u(d,{component:`templates`,name:`任务模板`,config:{},location:`center`})}}),project:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-projs`,children:[f.map(e=>(0,_.jsx)(k,{repo:e,docStateOf:E,openDoc:D,bindExternal:A,unbind:j},e.key)),!f.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})})};return(0,_.jsxs)(`div`,{className:`setp`,children:[(0,_.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:O.map(e=>(0,_.jsxs)(`button`,{className:`setp-navitem`+(m===e.id?` on`:``),"aria-current":m===e.id,onMouseEnter:()=>h(e.id),onClick:()=>h(e.id),children:[(0,_.jsx)(i,{name:e.icon,size:14}),(0,_.jsx)(`span`,{children:e.label})]},e.id))}),(0,_.jsxs)(`div`,{className:`setp-body`,children:[(0,_.jsx)(`div`,{className:`setp-h`,children:O.find(e=>e.id===m).label}),M[m]]}),s]})}export{M as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,o as r,r as i,s as a,u as o}from"./attach-v8BxRJ7p.js";import{A as s,B as c,C as l,E as u,F as d,I as f,J as p,L as m,M as h,N as g,P as _,R as v,T as y,V as ee,W as b,Y as x,_ as S,b as te,j as ne,m as re,q as C,w as ie,x as ae,y as oe,z as se}from"./index-
|
|
1
|
+
import{d as e,f as t,h as n,o as r,r as i,s as a,u as o}from"./attach-v8BxRJ7p.js";import{A as s,B as c,C as l,E as u,F as d,I as f,J as p,L as m,M as h,N as g,P as _,R as v,T as y,V as ee,W as b,Y as x,_ as S,b as te,j as ne,m as re,q as C,w as ie,x as ae,y as oe,z as se}from"./index-CHHRdALV.js";import{t as ce}from"./route-crumb-x1Za8gFU.js";import{i as le}from"./upload-BM8dlfZG.js";import{r as ue}from"./reopen-text-DSB76_rF.js";import{t as de}from"./md-edit-ops-Bl0Zx0aJ.js";import{a as fe,i as pe,n as me,o as w,r as he,t as ge}from"./md-history-H16pOkv6.js";var T=n(t(),1);function _e(e){let t=S(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim();if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
|
|
2
2
|
`:``)+a:r.feedbackText+=(r.feedbackText?`
|
|
3
3
|
`:``)+a)}),n.filter(e=>e.ackText!==``)}function E(e){let t=String(e?.ackText||``).split(`
|
|
4
4
|
`).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e.round} 轮 · ${n}`}var ve=x(),D=e(),O=[{op:`bold`,label:`B`,title:`粗体 Ctrl/⌘B`,cls:`b`},{op:`italic`,label:`I`,title:`斜体 Ctrl/⌘I`,cls:`i`},{op:`code`,label:`</>`,title:`行内代码 Ctrl/⌘E`,cls:`code`},{op:`link`,label:`链`,title:`链接 Ctrl/⌘K`,cls:`link`}],ye=[{op:`ul`,label:`列表`,title:`无序列表`,cls:`ul`},{op:`todo`,label:`待办`,title:`待办勾选`,cls:`todo`},{op:`quote`,label:`引用`,title:`引用`,cls:`quote`}];function k({f:e,onFormat:t}){return(0,D.jsx)(`button`,{type:`button`,className:`mdw-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label})}function A(){let[e,t]=(0,T.useState)(!1),[n,r]=(0,T.useState)({x:0,y:0}),i=(0,T.useRef)(null),a=(0,T.useRef)(null);return(0,T.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function j({menu:e,className:t=``,style:n,children:r}){return e.open?(0,ve.createPortal)((0,D.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function M(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function be({mode:e,onMode:t,showMark:n,submitLabel:r,onImg:i,onAtt:o,onShortcuts:s,onImport:c,onNew:l,onMark:u,onDraft:d,onSubmit:f,onDelete:p,onProg:m,onSource:h,onOverview:g,onFormat:_,onTurn:v}){let y=e===`edit`||e===`split`,ee=e!==`preview`,b=A(),x=A();(0,T.useEffect)(()=>{b.setOpen(!1),x.setOpen(!1)},[e]);let S=[e!==`split`&&{id:`import`,label:`导入`,run:c},{id:`new`,label:`新任务`,run:l},n&&{id:`mark`,label:`评论`,run:u},e!==`split`&&{id:`draft`,label:`存草稿`,run:d},p&&{id:`delete`,label:`删除`,run:p,danger:!0},{id:`overview`,label:`总览`,run:g}].filter(Boolean);return(0,D.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,D.jsxs)(`div`,{className:`mdw-toolbar-left`,children:[(0,D.jsx)(w,{mode:e,onChange:t}),y&&(0,D.jsxs)(`div`,{className:`mdw-fmt`,role:`group`,"aria-label":`格式`,children:[O.map(e=>(0,D.jsx)(k,{f:e,onFormat:_},e.op)),(0,D.jsx)(`span`,{className:`mdw-fmt-sep`,"aria-hidden":!0}),(0,D.jsx)(`div`,{className:`mdw-fmt-turn`,role:`group`,"aria-label":`转变为`,children:de.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`mdw-fmt-btn turn`,title:`${e.label}(${e.key})`,onMouseDown:e=>e.preventDefault(),onClick:()=>v?.(e.id),children:[(0,D.jsx)(`kbd`,{children:e.key}),(0,D.jsx)(`span`,{className:`mdw-fmt-turn-lab`,children:e.label})]},e.id))}),(0,D.jsxs)(`div`,{className:`mdw-fmt-more`,ref:b.ref,children:[(0,D.jsx)(`button`,{type:`button`,className:`mdw-fmt-btn more${b.open?` on`:``}`,title:`更多格式`,"aria-expanded":b.open,"aria-haspopup":`menu`,onClick:e=>M(b,e),children:`···`}),(0,D.jsxs)(j,{menu:b,children:[ye.map(e=>(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{_?.(e.op),b.setOpen(!1)},children:[e.label,(0,D.jsx)(`span`,{className:`hint`,children:e.title})]},e.op)),(0,D.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),de.map(e=>(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{v?.(e.id),b.setOpen(!1)},children:[e.key,` `,e.label,(0,D.jsx)(`span`,{className:`hint`,children:`转变`})]},e.id))]})]})]}),ee&&(0,D.jsxs)(`div`,{className:`mdw-tools`,role:`group`,"aria-label":`编辑工具`,children:[(0,D.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`插入图片`,"aria-label":`插入图片`,onClick:i,children:(0,D.jsx)(a,{name:`pin`,size:14})}),(0,D.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`添加附件`,"aria-label":`添加附件`,onClick:o,children:(0,D.jsx)(a,{name:`list`,size:14})}),(0,D.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`快捷键`,"aria-label":`快捷键速查`,onClick:s,children:(0,D.jsx)(a,{name:`help`,size:14})})]})]}),(0,D.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[(0,D.jsx)(`div`,{className:`mdw-actions-wide`,children:S.map(e=>(0,D.jsx)(`button`,{type:`button`,className:`btn ghost sm`+(e.danger?` danger`:``),onClick:e.run,children:e.label},e.id))}),(0,D.jsxs)(`div`,{className:`mdw-actions-more`,ref:x.ref,children:[(0,D.jsx)(`button`,{type:`button`,className:`btn ghost sm${x.open?` on`:``}`,title:`更多操作`,"aria-expanded":x.open,"aria-haspopup":`menu`,onClick:e=>M(x,e,`right`),children:`更多`}),(0,D.jsx)(j,{menu:x,className:`mdw-act-menu`,children:S.map(e=>(0,D.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(e.danger?` danger`:``),onClick:()=>{e.run?.(),x.setOpen(!1)},children:e.label},e.id))})]}),(0,D.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:f,children:r}),(0,D.jsx)(`span`,{className:`sep`,"aria-hidden":!0}),h&&(0,D.jsx)(`button`,{type:`button`,className:`btn ghost sm`,title:`在右侧并排打开评论锚定的原文(Ctrl/⌘⇧O)`,onClick:h,children:`原文`}),(0,D.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:m,children:`进程`})]})]})}var N=`nx-kv-ack-rail-pos`;function P(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Math.max(s,r-a-s),l=Math.max(s,i-o-s);return{x:Math.min(c,Math.max(s,t)),y:Math.min(l,Math.max(s,n))}}function xe(){try{let e=JSON.parse(localStorage.getItem(N)||`null`);if(!e||typeof e!=`object`)return null;let t=Number(e.x),n=Number(e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}catch{return null}}function F(e){try{e?localStorage.setItem(N,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(N)}catch{}}var I=4;function L(e,t,n){if(!e||t<0)return null;let r=e.querySelector(`.mdw-lp-block[data-i="${t}"]`);if(r)return r;let i=[...e.querySelectorAll(`h2`)].filter(e=>(e.textContent||``).trim()===`上一轮完成总结`);return i[n]?i[n]:null}function Se({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,T.useState)(!1),[a,o]=(0,T.useState)(0),[s,c]=(0,T.useState)(xe),[l,u]=(0,T.useState)(!1),d=(0,T.useRef)(null),f=(0,T.useRef)(null),p=(0,T.useRef)(!1);(0,T.useEffect)(()=>{let e=d.current,t=e&&e.parentElement;if(!e||!t)return;let n=()=>{c(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=P({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return n(),window.addEventListener(`resize`,n,{passive:!0}),()=>window.removeEventListener(`resize`,n)},[]);let m=(0,T.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=d.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();r?t.style.bottom=r:t.style.bottom=``;let a=n.getBoundingClientRect();f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-a.left,startTop:i.top-a.top,parentW:a.width,parentH:a.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),h=(0,T.useCallback)(e=>{let t=f.current;if(!t||e.pointerId!==t.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.moved){if(Math.hypot(n,r)<I)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=P({x:t.startLeft+n,y:t.startTop+r,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});i&&(t.last=i,c(i))},[]),g=(0,T.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,F(t.last)))},[]),_=(0,T.useCallback)(()=>{c(null),F(null)},[]),v=(0,T.useMemo)(()=>(e||[]).map(e=>({...e,title:E(e)})),[e]);(0,T.useEffect)(()=>{let e=t;if(!e||!v.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of v){let i=L(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,v]);let y=(0,T.useCallback)(e=>{let r=t,i=r?L(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return v.length?(0,D.jsxs)(`aside`,{ref:d,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:s?{left:s.x,top:s.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(p.current){p.current=!1;return}i(e=>!e)},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onDoubleClick:_,children:[(0,D.jsx)(`span`,{}),(0,D.jsx)(`span`,{}),(0,D.jsx)(`span`,{})]}),(0,D.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:v.map(e=>(0,D.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>y(e)},e.round))}),r&&(0,D.jsx)(`div`,{className:`doc-rail-panel`,children:(0,D.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,D.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),v.map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>y(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}function Ce({attachments:e,onRemove:t}){return e?.length?(0,D.jsxs)(`div`,{className:`mdw-attach`,children:[(0,D.jsx)(`div`,{className:`lab`,children:`附件 / 图片`}),(0,D.jsx)(`div`,{className:`list`,children:e.map(e=>(0,D.jsxs)(`div`,{className:`att`,children:[e.type===`image`&&e.url?(0,D.jsx)(`img`,{src:e.url,alt:``}):(0,D.jsx)(`div`,{className:`ico`,children:(0,D.jsx)(a,{name:`list`,size:14})}),(0,D.jsxs)(`div`,{className:`meta`,children:[(0,D.jsx)(`div`,{className:`n`,children:e.name}),(0,D.jsx)(`div`,{className:`s`,children:e.size})]}),(0,D.jsx)(`button`,{type:`button`,className:`x`,"aria-label":`移除`,onClick:()=>t(e.id),children:`×`})]},e.id))})]}):null}var R=[{op:`bold`,label:`B`,title:`粗体`,cls:`b`},{op:`italic`,label:`I`,title:`斜体`,cls:`i`},{op:`code`,label:`</>`,title:`代码`,cls:`code`},{op:`link`,label:`链`,title:`链接`,cls:`link`}];function we({at:e,onFormat:t,onComment:n,onCopy:r,onCompose:i,onClose:a}){let[o,s]=(0,T.useState)(!1),[c,l]=(0,T.useState)(``),u=(0,T.useRef)(null);if((0,T.useEffect)(()=>{s(!!e?.comment),l(``)},[e?.text,e?.x,e?.y,e?.comment]),(0,T.useEffect)(()=>{if(!o)return;let e=requestAnimationFrame(()=>u.current?.focus());return()=>cancelAnimationFrame(e)},[o]),!e)return null;let d=e.kind||`task`,f=d===`format`||d===`both`,p=String(e.text||``),m=p.length>72?`${p.slice(0,72)}…`:p,h=e.mode===`redo`,g=h?`重做:写下要改的地方`:`划线评论`,_=()=>{s(!0),i?.()},v=()=>{s(!1),l(``),a?.()},y=()=>{let e=c.trim();e&&n?.(e)};return(0,D.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${o?`comment`:d}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input`)||e.preventDefault()},children:o?(0,D.jsxs)(`div`,{className:`mdw-sel-comment`,children:[(0,D.jsx)(`div`,{className:`mdw-sel-comment-cap`,children:g}),p?(0,D.jsx)(`div`,{className:`mdw-sel-quote`,title:p,children:m}):null,(0,D.jsx)(`textarea`,{ref:u,className:`mdw-sel-comment-ta`,rows:3,value:c,placeholder:h?`写下要改的地方…`:`对此处提出问题…`,"aria-label":`评论文本`,onChange:e=>l(e.target.value),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),v();return}e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())}}),(0,D.jsxs)(`div`,{className:`mdw-sel-comment-acts`,children:[(0,D.jsx)(`button`,{type:`button`,className:`ghost`,onClick:v,children:`取消`}),(0,D.jsx)(`button`,{type:`button`,className:`primary`,disabled:!c.trim(),onClick:y,children:h?`重开此任务`:`提交为任务`})]}),(0,D.jsx)(`div`,{className:`mdw-sel-comment-hint`,children:`Ctrl/⌘+Enter 提交`})]}):(0,D.jsx)(D.Fragment,{children:f?(0,D.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[R.map(e=>(0,D.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,D.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,D.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:r,children:`复制`}),(0,D.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,D.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`划线评论 → 新任务`,onClick:_,children:`评论`})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`cap`,children:`选区`}),(0,D.jsx)(`button`,{type:`button`,onClick:_,children:`评论`}),(0,D.jsx)(`div`,{className:`sep`}),(0,D.jsx)(`button`,{type:`button`,onClick:r,children:`复制选区`})]})})})}var z=[{title:`格式`,items:[[`Ctrl/⌘ B`,`粗体`],[`Ctrl/⌘ I`,`斜体`],[`Ctrl/⌘ E`,`行内代码`],[`Ctrl/⌘ K`,`链接`],[`1 – 6`,`正文 / 标题 / 小标题 / 列表 / 待办 / 引用`]]},{title:`编辑`,items:[[`/`,`行首唤起命令菜单`],[`Tab / ⇧Tab`,`缩进 / 反缩进`],[`Enter`,`新建块(列表自动续行)`],[`⇧Enter`,`块内软换行`],[`Ctrl/⌘ Z`,`撤销`],[`Ctrl/⌘ ⇧Z`,`重做`]]},{title:`导航与文件`,items:[[`Ctrl/⌘ F`,`查找(Enter 下一个,F3 继续)`],[`Ctrl/⌘ S`,`保存并同步`],[`Ctrl/⌘ ⇧ O`,`评论任务:右侧并排打开原文`],[`Ctrl/⌘ /`,`打开 / 关闭本速查`],[`Enter(标题内)`,`跳到正文`]]}];function Te({onClose:e}){return(0,D.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,D.jsx)(`div`,{className:`mdw-sheet-cols`,children:z.map(e=>(0,D.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,D.jsx)(`h4`,{children:e.title}),(0,D.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,D.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,D.jsx)(`dt`,{children:(0,D.jsx)(`kbd`,{children:e})}),(0,D.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var Ee=`nx-kv-md-attachments-v1`;function De(){try{return JSON.parse(localStorage.getItem(Ee)||`{}`)||{}}catch{return{}}}function Oe(e){try{localStorage.setItem(Ee,JSON.stringify(e))}catch{}}function B(e,t){let n=De();n[e]=t,Oe(n)}function ke(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ae(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function je(e){let t=[],n=[];for(let r of[...e]){let e=`a`+Date.now()+Math.random().toString(16).slice(2,6),i=/^image\//.test(r.type),a={id:e,name:r.name,type:i?`image`:`file`,size:ke(r.size)};i&&(a.url=await Ae(r),n.push(`\n\n`)),t.push(a)}return{items:t,imageInserts:n,fileInserts:[]}}async function Me(e,t={}){let n=[...e||[]];if(!n.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await le(n,{...t.group?{group:t.group}:{},local:!0}),r=[],i=[],a=[];for(let t of e){let e=t.fileId||t.id,n=!!t.isImage;r.push({id:e,name:t.name,type:n?`image`:`file`,size:ke(Number(t.size)||0),url:`/api/file/content/${e}`});let o=t.markdown||{},s=n?o.image||``:o.file||`[${t.name}](${e})`;(n?i:a).push(`\n${s}\n`)}return{items:r,imageInserts:i,fileInserts:a}}catch{return je(e)}}function V({dirKey:e,task:t,beside:n=!1,tabId:i,model:a}){let x=b()||{},S=o(),{dialog:le,node:de}=r(),w=x.rows||[],E=x.refreshLocal,ve=x.tpl,O=!e||e===`__GLOBAL__`,ye=se(e),k=_(t),A=h(ye,t),j=(0,T.useMemo)(()=>O?w.find(e=>e.isGlobal)||null:w.find(t=>t.key===e)||null,[w,e,O]),M=(0,T.useMemo)(()=>(j?.tasks||[]).find(e=>String(e.id)===String(t))||null,[j,t]),N=c(),P=N[A]||null,[xe,F]=(0,T.useState)(null);(0,T.useEffect)(()=>{F(null)},[A]);let I=M?.timegoal||null,L=xe||{duration:I?.duration||``,prompt:I?.prompt||``},R=k||!!M&&M.status!==`consumed`,z=`nx-kv/review/${ye}/${t}`,[Ee,De]=(0,T.useState)(()=>{try{return localStorage.getItem(z)===`1`}catch{return!1}});(0,T.useEffect)(()=>{De(()=>{try{return localStorage.getItem(z)===`1`}catch{return!1}})},[z]);let Oe=()=>{try{localStorage.setItem(z,`1`)}catch{}De(!0),S(`已验收`)},ke=()=>{let e=Re.current,t=e?.closest?.(`.mdw`),n=e?.getBoundingClientRect(),r=t?.getBoundingClientRect(),i=n&&r?n.left-r.left+80:80,a=n&&r?n.top-r.top-190:120;G({kind:`task`,text:``,comment:!0,mode:`redo`,x:Math.min(window.innerWidth-320,Math.max(8,i)),y:Math.min(window.innerHeight-260,Math.max(8,a))})},Ae=e=>{if(W?.mode===`redo`){je(e);return}at(e)},je=n=>{let r=String(n||``).trim();if($(),!r){S(`写一下要改的地方`);return}let o=P?.title||`#${t}`;Z(async()=>{let n=ue({base:P?.body||``,feedback:r,ackSummary:M?.roundSummary||``}),s=await C(`/api/localtasks/reopen`,{method:`POST`,body:{...O?{key:ee}:{cwd:j?.cwd},id:Number(t),text:n}});if(s?.moved){let r=s.key||e,c=String(s.task?.id??t),u=h(se(r),c);m(A,u,{title:l(n),body:n}),a&&i&&a.doAction(p.updateNodeAttributes(i,{config:{dirKey:r,task:c}})),Y(!1),S(`已重开并改归属:「${o}」迁到「${s.name}」#${c}`),E();return}v(A,{title:l(n),body:n}),Y(!1),S(`已重开「${o}」——agent 可再次领取`),E()})},V=(0,T.useMemo)(()=>P?ie(P.body):{},[P&&P.body]),H=(0,T.useMemo)(()=>{if(n)return null;let r=String(V.parent||``).trim(),i=String(V.parentDir||e||``).trim();if(r&&!/^draft/i.test(r))return{dirKey:i||e,task:r,name:`#${r}`};let a=String(P?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!a)return null;let o=a[1].trim(),s=(j?.tasks||[]).find(e=>String(e.id)===String(t)?!1:l(e.text||``)===o||String(e.text||``).includes(`# ${o}`));return s?{dirKey:e,task:String(s.id),name:`#${s.id}`}:null},[n,V.parent,V.parentDir,P?.body,e,j,t]),U=(0,T.useMemo)(()=>{let e=V.board;if(!e)return null;let t=(x.repoData&&x.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=x.repoData&&x.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(Boolean).map(e=>({key:e.key,name:e.name}))}},[V.board,x.repoData]);(0,T.useEffect)(()=>{N[A]||(k?g(A,{title:``,body:ve?ve.defaultBody():``}):M&&g(A,{title:l(M.text),body:M.text}))},[A,k,M]);let[W,G]=(0,T.useState)(null),[Ne,Pe]=(0,T.useState)(!1),Fe=(0,T.useRef)(null),Ie=(0,T.useRef)(null),Le=(0,T.useRef)(null),Re=(0,T.useRef)(null),ze=(0,T.useRef)(null),K=(0,T.useRef)(null),q=(0,T.useRef)(``),J=(0,T.useRef)(new Map),[Be,Y]=(0,T.useState)(!1),[X,Ve]=(0,T.useState)(!1),[He,Ue]=(0,T.useState)(!1),We=String(M?.roundSummary||``).length>140;(0,T.useEffect)(()=>{Ve(!1),Ue(!1)},[A,M?.roundSummary]),(0,T.useLayoutEffect)(()=>{let e=ze.current;if(!e){Ue(!1);return}let t=()=>{X||Ue(e.scrollHeight>e.clientHeight+1)};t();let n=requestAnimationFrame(t),r=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return r?.observe(e),()=>{cancelAnimationFrame(n),r?.disconnect()}},[X,M?.roundSummary,M?.completedAt]);let Ge=(0,T.useMemo)(()=>P?oe(ae(P.body),P.attachments):``,[P]),Ke=(0,T.useMemo)(()=>M?.roundSummary?oe(M.roundSummary):``,[M?.roundSummary]),qe=(0,T.useMemo)(()=>P?_e(P.body):[],[P&&P.body]),[Je,Ye]=(0,T.useState)(null);(0,T.useEffect)(()=>{let e=Le.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Ye(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Ye(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[P&&P.mode]),(0,T.useEffect)(()=>{G(null),q.current=``},[A]),(0,T.useEffect)(()=>{let e=()=>G(e=>e?.comment?e:null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]);let Z=e=>e().catch(e=>S(String(e.message||e))),Xe=()=>{let n=a||x.model;if(!n)return;let r=V&&V.board?String(V.board):``;ne(n,{component:`progress`,name:`进程`,config:r?{groupKey:r,task:t==null?void 0:String(t)}:{dirKey:e||`__GLOBAL__`,task:t==null?void 0:String(t)},location:`right`})},Ze=(0,T.useCallback)(()=>{if(!H){S(`这条任务没有可定位的原文`);return}let e=a||x.model;e&&s(e,{component:`page`,name:H.name||`原文 ${H.task}`,config:{dirKey:H.dirKey,task:String(H.task)}})},[H,a,x.model,S]),Qe=(0,T.useCallback)(()=>{let e=a||x.model;e&&i&&e.doAction(p.deleteTab(i))},[a,x.model,i]),Q=(0,T.useCallback)(()=>Y(!0),[]),$e=(e,t)=>{let n=(e||``).trim()||`未命名任务`,r=ie(t),i=Object.keys(r).length>0,a=y(t);return a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?u(a,r):a},et=()=>{let e=(L.duration||``).trim(),t=(L.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!R)return{};if(!k){let n=I?.duration||``,r=I?.prompt||``;return e===n&&t===r?{}:e?{duration:e,goalPrompt:t}:{clearGoal:!0}}return e?{duration:e,goalPrompt:t}:{}},tt=()=>Z(async()=>{if(!P)return;let n=(P.title||``).trim()||`未命名任务`,r=ie(P.body),o=$e(n,P.body),s=r.project?w.find(e=>!e.isGlobal&&e.repo&&e.repo.key===r.project):null,c=!!(U&&r.project&&U.members.some(e=>e.key===r.project)),l=et();if(l.error){S(l.error);return}if(!k){let r=await C(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:O?s?s.cwd:void 0:j?.cwd,key:O&&!s?ee:void 0,id:Number(t),text:o,...l}});if(r?.moved){let s=r.key||e,c=String(r.task?.id??t),l=h(se(s),c);B(c,P.attachments),m(A,l,{title:n,body:r.task?.text||o}),a&&i&&a.doAction(p.updateNodeAttributes(i,{config:{dirKey:s,task:c}})),Y(!1),ge(J.current,l),S(`已改归属项目:任务迁到「${r.name}」#${c}`),E();return}B(t,P.attachments),v(A,{title:n,body:o}),Y(!1),ge(J.current,A),S(l.clearGoal?`已同步 MD · 时间目标已清除`:l.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),E();return}let u=await C(`/api/localtasks`,{method:`POST`,body:{...c?{text:o,board:U.board.id,project:r.project}:r.project?{text:o,project:r.project}:O?{global:!0,text:o}:{cwd:j?.cwd,text:o},...l}}),d=u?.task?.id??u?.id;if(d!=null){let t=u?.key||e,r=se(t);B(d,P.attachments);let s=h(r,String(d));m(A,s,{title:n,body:o}),a&&i&&a.doAction(p.updateNodeAttributes(i,{config:{dirKey:t,task:String(d)}})),Y(!1),ge(J.current,s)}S(`已提交:${te(n)}`),E()}),nt=async t=>{let n=await t.text(),r=t.name.replace(/\.md$/i,``);await Z(async()=>{let i=n.startsWith(`#`)?n:`# ${r}\n\n${n}`,a=await C(`/api/localtasks`,{method:`POST`,body:O?{global:!0,text:i}:{cwd:j.cwd,text:i}});S(`已导入:${t.name}`),E();let o=a?.task?.id??a?.id;o!=null&&x.openPage&&x.openPage({dirKey:e,task:String(o),name:`#${o}`})})},rt=async()=>{if(!P||k)return;let e=P.title||`#${t}`;await le({title:`删除任务「${e}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&Z(async()=>{await C(`/api/localtasks/item`,{method:`DELETE`,body:O?{key:ee,id:Number(t)}:{cwd:j.cwd,id:Number(t)}}),S(`已删除「${e}」`),a&&i&&a.doAction(p.deleteTab(i)),E()})},it=async(e,n={})=>{if(!P)return;let{items:r,imageInserts:i,fileInserts:a}=await Me(e),o=f(A)||P,s=o.body||``,c=i.join(``),u=s,d=null;if(c){let e=re(s,c,n);u=e.body,d=e.insertAt+c.length}a.length&&(u=re(u,a.join(``),{}).body);let p={};if(u!==s&&(p.body=u),r.length&&(p.attachments=[...o.attachments||[],...r]),Object.keys(p).length){if(v(A,p),n.mode===`edit`&&d!=null&&requestAnimationFrame(()=>{K.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(d,d)}catch{}}),!k){p.attachments&&B(t,p.attachments);let e=$e(o.title,p.body||u);v(A,{body:e,title:l(e)});try{await C(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:O?void 0:j?.cwd,key:O?ee:void 0,id:Number(t),text:e}}),Y(!1),E(),S(r.length?`已添加附件并同步(${r.length})`:`已同步附件`)}catch(e){Q(),S(`附件已插入,同步失败:${e.message||e}`)}return}Q()}},$=()=>{G(null),q.current=``},at=n=>{let r=q.current||``,i=String(n||``).trim();if(!r){S(`先划选一段再评论`);return}if(!i){S(`写一下要提的问题`);return}let a=P?.title||j?.name||``,o=`问题:${i.slice(0,28)}`,s=`# ${o}\n\n> 锚定自「${a}」:\n> ${r.replace(/\n/g,`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{s as r}from"./index-
|
|
1
|
+
import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{s as r}from"./index-CHHRdALV.js";var i=n(t(),1),a=e();function o({body:e,values:t,onSave:n,disabled:o=!1}){let s=(0,i.useMemo)(()=>r(e),[e]),[c,l]=(0,i.useState)(()=>({...t||{}})),[u,d]=(0,i.useState)(!1),f=s.join(`|`)+`::`+JSON.stringify(t||{}),[p,m]=(0,i.useState)(f);if(f!==p&&(m(f),l({...t||{}}),d(!1)),!s.length)return(0,a.jsx)(`div`,{className:`pp-slots-empty`,children:`这个模板正文没有可填槽位——骨架里没有插槽。`});let h=(e,t)=>{l(n=>({...n,[e]:t})),d(!0)};return(0,a.jsxs)(`div`,{className:`pp-slots`,children:[s.map(e=>(0,a.jsxs)(`label`,{className:`pp-slots-row`,children:[(0,a.jsx)(`span`,{className:`pp-slots-name`,title:`骨架插槽「${e}」`,children:e}),(0,a.jsx)(`input`,{className:`pp-slots-input`,value:c[e]??``,disabled:o,placeholder:`这一处写什么(留空 = 空白)`,onChange:t=>h(e,t.target.value)})]},e)),(0,a.jsxs)(`div`,{className:`pp-slots-acts`,children:[(0,a.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:o||!u,onClick:()=>{n?.(c),d(!1)},children:`保存槽位`}),(0,a.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:o||!u,onClick:()=>{l({...t||{}}),d(!1)},children:`撤销改动`})]})]})}export{o as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{W as o,y as s}from"./index-
|
|
1
|
+
import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{W as o,y as s}from"./index-CHHRdALV.js";import{t as c}from"./route-crumb-x1Za8gFU.js";import{f as l}from"./md-edit-ops-Bl0Zx0aJ.js";import{t as u}from"./template-slots-DTd6DvJ3.js";var d=n(t(),1),f=e(),p=[{op:`bold`,label:`B`,title:`粗体 Ctrl/⌘B`,cls:`b`},{op:`italic`,label:`I`,title:`斜体 Ctrl/⌘I`,cls:`i`},{op:`code`,label:`</>`,title:`行内代码 Ctrl/⌘E`,cls:`code`},{op:`link`,label:`链`,title:`链接 Ctrl/⌘K`,cls:`link`},{op:`ul`,label:`列表`,title:`无序列表`,cls:`ul`},{op:`todo`,label:`待办`,title:`待办勾选`,cls:`todo`},{op:`quote`,label:`引用`,title:`引用`,cls:`quote`},{op:`h2`,label:`H2`,title:`二级标题`,cls:`h2`},{op:`h3`,label:`H3`,title:`三级标题`,cls:`h3`}],m={b:`bold`,i:`italic`,e:`code`,k:`link`},h=[{id:`split`,label:`并排`},{id:`edit`,label:`源码`},{id:`preview`,label:`预览`}];function g({value:e,onChange:t,onSubmit:n,placeholder:r=`模板正文(Markdown)`,rows:i=10}){let a=(0,d.useRef)(null),[o,c]=(0,d.useState)(`split`),u=(0,d.useMemo)(()=>s(e),[e]),g=e=>{let n=l(a.current,e);n&&(t(n.value),requestAnimationFrame(()=>{let e=a.current;if(e){e.focus();try{e.setSelectionRange(n.start,n.end)}catch{}}}))};return(0,f.jsxs)(`div`,{className:`mdw-tpl-ed`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-ed-bar`,children:[p.map(e=>(0,f.jsx)(`button`,{type:`button`,className:`mdw-fmt-btn ${e.cls}`,title:e.title,onMouseDown:e=>e.preventDefault(),onClick:()=>g(e.op),children:e.label},e.op)),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`div`,{className:`mdw-tpl-ed-modes`,role:`group`,"aria-label":`编辑视图`,children:h.map(e=>(0,f.jsx)(`button`,{type:`button`,className:`mdw-tpl-ed-mode`+(o===e.id?` on`:``),"aria-pressed":o===e.id,onClick:()=>c(e.id),children:e.label},e.id))})]}),(0,f.jsxs)(`div`,{className:`mdw-tpl-ed-panes mode-${o}`,children:[o!==`preview`&&(0,f.jsx)(`textarea`,{ref:a,className:`mdw-tpl-ed-src`,value:e,rows:i,spellCheck:!1,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase();if(t===`enter`){e.preventDefault(),n?.();return}let r=m[t];r&&(e.preventDefault(),g(r))}}),o!==`edit`&&(0,f.jsx)(`div`,{className:`mdw-tpl-ed-prev`,dangerouslySetInnerHTML:{__html:u}})]})]})}function _(){let e=(o()||{}).tpl,t=a(),{dialog:n,node:s}=r(),[l,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)({name:``,body:``}),T=(0,d.useRef)(null);if(!e)return(0,f.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,f.jsx)(c,{}),(0,f.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});let E=(e,n)=>async()=>{if(!_){v(!0);try{await e(),t(n)}catch(e){t(String(e.message||e))}finally{v(!1)}}},D=E(async()=>{if(!(l||``).trim()){t(`先给模板起个名字`),T.current?.focus();return}await e.add(l.trim(),m,!1),p(``),h(``),T.current?.focus()},`已新增模板`),O=e=>{S(e.id),w({name:e.name,body:e.body})},k=()=>S(null),A=E(async()=>{if(!(C.name||``).trim()){t(`模板名不能为空`);return}await e.update(x,{name:C.name.trim(),body:C.body}),S(null)},`已保存模板`),j=t=>E(()=>e.setDefault(t.id),`默认模板已设为「${t.name}」`)(),M=(t,n)=>E(()=>e.update(t.id,{values:n}),`已保存「${t.name}」的槽位内容`)(),N=async t=>{await n({title:`删除模板「${t.name}」`,danger:!0,okText:`删除`})&&E(()=>e.remove(t.id),`已删除「${t.name}」`)()},P=e.templates||[],F=P.find(t=>t.id===e.defaultId)?.name||`内置骨架`,I=e.templates==null,L=e.unsupported?`本机面板服务较旧,没有模板接口 —— 重启面板(nx-kv serve)后重试`:`模板列表加载失败 —— 服务暂时无响应,可点「重试」再试一次`;return(0,f.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[s,(0,f.jsxs)(`div`,{className:`mdw-tpl-panel-inner`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-panel-head`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-panel-title`,children:`任务模板`}),(0,f.jsx)(`span`,{className:`mdw-tpl-panel-sub`+(I?` bad`:``),children:I?L:`新建页默认使用「${F}」`}),(0,f.jsx)(`span`,{className:`grow`}),!I&&(0,f.jsxs)(`span`,{className:`mdw-tpl-panel-count`,children:[P.length,` 个模板`]})]}),(0,f.jsx)(`div`,{className:`mdw-tpl-panel-note`,children:`模板 = 新建任务页的起始正文。这里的改动即时生效:目录面板的「模板 ▾」与「+ 新建页」用的就是这份列表。`}),(0,f.jsxs)(`div`,{className:`mdw-tpl-list`,children:[P.map(t=>x===t.id?(0,f.jsxs)(`div`,{className:`mdw-tpl-row editing`,children:[(0,f.jsx)(`input`,{className:`mdw-tpl-name-in`,value:C.name,autoFocus:!0,placeholder:`模板名`,onChange:e=>w(t=>({...t,name:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&A()}}),(0,f.jsx)(g,{value:C.body,onChange:e=>w(t=>({...t,body:e})),onSubmit:A,rows:12}),(0,f.jsxs)(`div`,{className:`mdw-tpl-acts end`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-hint`,children:`Ctrl/⌘ + Enter 保存`}),(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:k,children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:_,onClick:A,children:`保存`})]})]},t.id):(0,f.jsxs)(`div`,{className:`mdw-tpl-row`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-main`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-name`,children:[t.name,t.id===e.defaultId&&(0,f.jsx)(`span`,{className:`mdw-tpl-def`,children:`默认`}),t.builtin&&(0,f.jsx)(`span`,{className:`mdw-tpl-builtin`,children:`内置`})]}),(0,f.jsx)(`div`,{className:`mdw-tpl-prev`,children:String(t.body||``).trim()||`(空)`})]}),(0,f.jsxs)(`div`,{className:`mdw-tpl-acts`,children:[(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,title:`填槽位(正文里 {{名字}} 处的内容)`,onClick:()=>b(y===t.id?null:t.id),children:y===t.id?`收起槽位`:`填槽位`}),t.id!==e.defaultId&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:()=>j(t),children:`设为默认`}),!t.builtin&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:()=>O(t),children:`编辑`}),!t.builtin&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm danger`,disabled:_,title:`删除此模板`,onClick:()=>N(t),children:(0,f.jsx)(i,{name:`trash`,size:12})})]}),y===t.id&&(0,f.jsxs)(`div`,{className:`mdw-tpl-slots`,children:[(0,f.jsx)(u,{body:t.body,values:t.values,disabled:_,onSave:e=>M(t,e)}),(0,f.jsx)(`div`,{className:`mdw-tpl-note`,children:`槽位从正文里扫出来;新建任务时正文按这里的值渲染(内置模板只改槽位,骨架不可改)。`})]})]},t.id)),I&&(0,f.jsx)(`div`,{className:`mdw-tpl-empty`,children:(0,f.jsx)(`div`,{className:`mdw-tpl-retry`,children:(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e.refetch(),children:`重试`})})}),!I&&!P.length&&(0,f.jsx)(`div`,{className:`mdw-tpl-empty`,children:`还没有自定义模板;下面加一个,或直接用内置的。`})]}),!I&&(0,f.jsxs)(`div`,{className:`mdw-tpl-add`,children:[(0,f.jsx)(`div`,{className:`mdw-tpl-add-h`,children:`新增模板`}),(0,f.jsx)(`input`,{ref:T,className:`mdw-tpl-name-in`,value:l,placeholder:`模板名,如 缺陷修复 / 周报`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,f.jsx)(g,{value:m,onChange:h,onSubmit:D,rows:12,placeholder:`模板正文(Markdown)。
|
|
2
2
|
留空则用内置骨架(## 背景 / ## 验收 / ## 约束 / ## 附件)。`}),(0,f.jsxs)(`div`,{className:`mdw-tpl-add-acts`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-hint`,children:"首行写 `# 标题`,提交时它就是任务标题;Ctrl/⌘ + Enter 快速添加。"}),(0,f.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:_,onClick:D,children:`添加`})]})]})]})]})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as e}from"./index-
|
|
1
|
+
import{q as e}from"./index-CHHRdALV.js";var t={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`,"image/bmp":`.bmp`,"image/svg+xml":`.svg`,"application/pdf":`.pdf`,"text/plain":`.txt`,"text/markdown":`.md`,"text/csv":`.csv`,"application/zip":`.zip`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`.docx`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`.xlsx`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`.pptx`},n=e=>String(e).padStart(2,`0`),r=()=>{let e=new Date;return`${e.getFullYear()}${n(e.getMonth()+1)}${n(e.getDate())}-${n(e.getHours())}${n(e.getMinutes())}${n(e.getSeconds())}`};function i(e){let t=e.clipboardData;if(!t)return[];let n=[];if(t.items)for(let e of t.items){if(e.kind!==`file`)continue;let t=e.getAsFile();t&&n.push(t)}return!n.length&&t.files&&n.push(...Array.from(t.files)),n}function a(e){let t=e.dataTransfer;return t?Array.from(t.files||[]).filter(e=>e&&e.size>0):[]}function o(e,n=0){let i=String(e.name||``).trim();if(!(!i||/^image\.(png|jpe?g)$/i.test(i)||/^blob$/i.test(i)))return i;let a=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)):``,o=t[e.type]||a||`.bin`;return`粘贴图片-${r()}${n>0?`-${n+1}`:``}${o}`}function s(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`读取文件失败: ${e.name||`(无名)`}`)),r.onload=()=>t(String(r.result||``)),r.readAsDataURL(e)})}async function c(t,{group:n,index:r=0,local:i=!1}={}){let a=o(t,r),c=await s(t);return{...await e(`/api/file`,{method:`POST`,body:{name:a,content:c,contentType:t.type||``,group:n,local:i}}),name:a}}async function l(e,{group:t,onProgress:n,local:r=!1}={}){let i=[];for(let a=0;a<e.length;a++)n&&n(a+1,e.length,e[a]),i.push(await c(e[a],{group:t,index:a,local:r}));return i}function u(e){return e.map(e=>e.isImage?e.markdown.image:e.markdown.file).join(` `)}export{l as i,a as n,u as r,i as t};
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
|
|
13
13
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
|
14
14
|
<link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-CHHRdALV.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/attach-v8BxRJ7p.js">
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/attach-BZrdOH46.css">
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index--c-rj9Y8.css">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,m as r,o as i,u as a}from"./attach-v8BxRJ7p.js";import{C as o,D as s,W as c,b as l,j as u,p as d,q as f,y as p}from"./index-DMp4lRKl.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./md-history-CwtrJcZo.js";var b=r({default:()=>w,useWikiNav:()=>C}),x=n(t(),1),S=e();function C(e){let t=c()||{},n=a(),r=e||t.model,i=(0,x.useRef)(null),o=(0,x.useCallback)(async()=>{if(!i.current)try{i.current=(await f(`/api/docs/index`)).index||[]}catch{i.current=[]}return i.current},[]),l=(0,x.useCallback)(async(e,t,n={})=>{let i=(t||await o()).find(t=>t.docId===e);u(r,{component:`doc`,name:i?i.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[r,o]),d=(0,x.useCallback)(async e=>{let t=await o(),r=s(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> 创建`)},[o,l,n]);return{nav:d,onClick:(0,x.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),d(t.getAttribute(`data-wl`)))},[d]),ensureIndex:o,openByDocId:l}}function w({docId:e,repoKey:t,boardKey:n,boardName:r,model:s}){let c=a(),{dialog:u,node:b}=i(),w=(0,x.useRef)(new Map),E=(0,x.useRef)(null),D=(0,x.useRef)(null),{onClick:O,openByDocId:k}=C(s),A=t?`repo`:n?`board`:``,j=t||n||``,M=(0,x.useMemo)(()=>t?{repoKey:t}:n?{boardKey:n,boardName:r||``}:{},[t,n,r]),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(``),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(`split`),[V,H]=(0,x.useState)([]),[U,W]=(0,x.useState)(null),G=(0,x.useCallback)(async()=>{I(``);try{let t=await f(`/api/docs/item?ref=`+encodeURIComponent(e||``));P(t),R(!1)}catch(e){I(String(e.message||e)),P(null)}},[e]);(0,x.useEffect)(()=>{P(null),G()},[G]);let K=(0,x.useCallback)(()=>{if(!j){H([]);return}if(A===`repo`){f(`/api/repos/docs?id=`+encodeURIComponent(j)).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/${j}.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}),H(n)}).catch(()=>H(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}f(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===j||e.key===j),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})}H(r)}).catch(()=>H(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[j,A,e]);(0,x.useEffect)(()=>{K()},[K]);let[q,J]=(0,x.useState)(null);(0,x.useEffect)(()=>{f(`/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());J(t)}).catch(()=>{})},[]);let Y=!!(N&&N.writable),X=(0,x.useMemo)(()=>N?p(N.body,[],Y?q:null):``,[N,q,Y]),te=(0,x.useMemo)(()=>N?d(N.body):[],[N]);(0,x.useEffect)(()=>{let e=D.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;W(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>W(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[N,z,X]);let Z=e=>e().catch(e=>c(String(e.message||e))),ne=(0,x.useCallback)(e=>k(e,null,M),[k,M]),re=()=>{j&&Z(async()=>{let t=await u({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(t===null)return;let n=l(String(t).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?T(e):A===`repo`?`repo/${j}`:`board/${r||j}`}/reference/${n}.md`;await f(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(t).trim()||n}\n\n(待补)\n`}});try{A===`repo`?await f(`/api/repos/docs`,{method:`POST`,body:{id:j,rel:i}}):await f(`/api/docs/link`,{method:`POST`,body:{board:j,doc:i}})}catch{}c(`已补充:${i}`),K(),k(`rel:`+i,null,M)})},Q=()=>Z(async()=>{if(!N||!Y)return;let t=await f(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:N.body}});P(e=>({...e,body:N.body,summary:t.summary})),R(!1),y(w.current,e),c(t.summary?`已保存,摘要已回写`:`已保存`)}),ie=(t,n=`op`)=>{N&&(g(w.current,e,{body:N.body},n),R(!0),P(e=>({...e,body:t,title:o(t,e.title)})))},ae=(t,n=`typing`)=>{if(!N)return;g(w.current,e,{body:N.body},n),R(!0);let r=/^#\s+/m.test(N.body)?N.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${N.body}`;P(e=>({...e,body:r,title:t}))},oe=()=>{if(!N)return;let t=h(w.current,e,{body:N.body});t&&(P(e=>({...e,body:t.body,title:o(t.body,e.title)})),R(!0),requestAnimationFrame(()=>E.current?.caretFromDiff?.(N.body,t.body)))},se=()=>{if(!N)return;let t=v(w.current,e,{body:N.body});t&&(P(e=>({...e,body:t.body,title:o(t.body,e.title)})),R(!0),requestAnimationFrame(()=>E.current?.caretFromDiff?.(N.body,t.body)))},ce=()=>Z(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 f(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n}\n\n(待补)\n`}}),c(`已创建:${t}`),await G()});if(N&&N.dir)return(0,S.jsxs)(`div`,{className:`mdw docp`,children:[(0,S.jsxs)(`div`,{className:`docp-head`,children:[(0,S.jsx)(`span`,{className:`docp-path mono`,children:N.path}),(0,S.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,S.jsxs)(`div`,{className:`docp-files`,children:[N.files.map(e=>(0,S.jsx)(`button`,{className:`docp-file`,onClick:()=>k(`path:`+e,null),children:e},e)),!N.files.length&&(0,S.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(F)return(0,S.jsx)(`div`,{className:`mdw docp`,children:(0,S.jsxs)(`div`,{className:`pad stack`,children:[(0,S.jsx)(`div`,{children:(0,S.jsx)(`strong`,{children:`文档打开失败`})}),(0,S.jsx)(`div`,{className:`hint`,children:F})]})});if(!N)return(0,S.jsx)(`div`,{className:`mdw`,children:(0,S.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(N.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,S.jsxs)(`div`,{className:`mdw docp`,children:[(0,S.jsx)(`div`,{className:`docp-head`,children:(0,S.jsx)(`span`,{className:`docp-path mono`,children:N.rel||N.path||e})}),(0,S.jsxs)(`div`,{className:`pad stack`,children:[(0,S.jsx)(`div`,{children:(0,S.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,S.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,S.jsx)(`div`,{children:(0,S.jsx)(`button`,{className:`btn sm`,onClick:ce,children:`创建骨架`})})]})]})}let $=Y?z:`preview`;return(0,S.jsxs)(`div`,{className:`mdw docp`,"data-mode":$,onClick:O,ref:D,children:[(0,S.jsxs)(`div`,{className:`mdw-main`,children:[(0,S.jsxs)(`div`,{className:`docp-head`,children:[(0,S.jsx)(`span`,{className:`docp-path mono`,title:N.rel||N.path,children:N.rel||N.path}),L&&(0,S.jsx)(`span`,{className:`docp-dirty`,children:`未保存`}),!Y&&(0,S.jsx)(`span`,{className:`docp-tag ext`,children:`外部绑定 · 只读`}),(0,S.jsx)(`span`,{className:`grow`}),Y&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{mode:$,onChange:B}),(0,S.jsx)(`button`,{className:`btn sm docp-save`,onClick:Q,children:`保存`})]})]}),N.summary&&Y&&(0,S.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,N.summary]}),(0,S.jsx)(m,{mode:$,title:N.title,body:N.body,previewHtml:X,onTitle:Y?ae:null,onBody:Y?ie:null,attachments:[],docKey:e,editorApiRef:E,onSave:Y?Q:null,onUndo:Y?oe:null,onRedo:Y?se:null}),(0,S.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,S.jsx)(ee,{headings:te,scrollRoot:U,links:V,activeDocId:e,onOpenDoc:j?ne:null,onAddRef:j?re:null}),b]})}function T(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 E(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 D(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function O({kind:e,owner:t,model:n}){let{openByDocId:r}=C(n),i=e===`board`?`组介绍`:`项目介绍`,a=e===`board`?t&&(t.id||t.key):t&&t.key,o=t&&t.name,s=(0,x.useMemo)(()=>E(t,e),[t,e]),[c,u]=(0,x.useState)([]),[d,p]=(0,x.useState)(0),m=(0,x.useCallback)(()=>p(e=>e+1),[]);(0,x.useEffect)(()=>{let n=!0;if(!a){u([]);return}if(e===`repo`)f(`/api/repos/docs?id=`+encodeURIComponent(a)).then(e=>{if(!n)return;let t=[];if(e.main){let n=D(e.main);n&&t.push({docId:n,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.links||[]){let e=D(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([])});else{let e=()=>{let e=[];s&&e.push({docId:s,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let n of t?.docLinks||[]){let t=D(n);t&&e.push({docId:t,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}return e};f(`/api/boards/`+encodeURIComponent(String(a))).then(t=>{if(!n)return;let r=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!r){u(e());return}let i=[];s&&i.push({docId:s,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of r){let t=D(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())})}return()=>{n=!1}},[e,a,t,s,d]);let h=(0,x.useMemo)(()=>e===`repo`&&a?{repoKey:a}:e===`board`&&a?{boardKey:a,boardName:o||``}:{},[e,a,o]);return{kind:e,label:i,ownerKey:a,docRef:s,links:c,openMain:(0,x.useCallback)(()=>{s&&r(s,null,h)},[s,r,h]),openDoc:(0,x.useCallback)(e=>r(e,null,h),[r,h]),addRef:(0,x.useCallback)(async(t,n)=>{if(!a||!s.startsWith(`rel:`))return n&&n(`当前简介无法补充(需要自有树路径)`),null;let i=await t({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(i===null)return null;let c=typeof i==`string`?i:i&&i.value||``,u=typeof i==`object`&&i&&i.tag||``,d=l(String(c).trim()||`note`).replace(/\.md$/i,``),p=`${T(s)||(e===`repo`?`repo/${a}`:`board/${o||a}`)}/reference/${d}.md`;await f(`/api/docs/item`,{method:`POST`,body:{rel:p,body:`# ${String(c).trim()||d}\n\n(待补)\n`}});try{e===`repo`?await f(`/api/repos/docs`,{method:`POST`,body:{id:a,rel:p,tag:u||void 0}}):await f(`/api/docs/link`,{method:`POST`,body:{board:a,doc:p,tag:u||void 0}})}catch{}return n&&n(`已补充:${p}${u?` [${u}]`:``}`),m(),r(`rel:`+p,null,h),p},[a,s,e,o,r,h,m]),setLinkTag:(0,x.useCallback)(async(t,n,r)=>{if(!a)throw Error(`缺少归属`);let i=String(t||``).startsWith(`path:`)?{path:String(t).slice(5)}:{rel:String(t||``).startsWith(`rel:`)?String(t).slice(4):String(t||``)},o=r&&r.note||``;e===`repo`?await f(`/api/repos/docs`,{method:`POST`,body:{id:a,...i,note:o||void 0,tag:n||void 0}}):await f(`/api/docs/link`,{method:`POST`,body:{board:a,doc:i.path||i.rel,note:o||void 0,tag:n||void 0}}),m()},[a,e,m]),reload:m,canEdit:!!s}}function k(e){return e<=1?18:e===2?12:8}function ee({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(``),u=(0,x.useMemo)(()=>e||[],[e]),d=(0,x.useMemo)(()=>n||[],[n]);(0,x.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,x.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,S.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,S.jsx)(`span`,{}),(0,S.jsx)(`span`,{}),(0,S.jsx)(`span`,{})]}),(0,S.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${k(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,S.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,S.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,S.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,S.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,S.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,S.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,S.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,S.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function A({kind:e,owner:t,model:n}){let r=a(),{dialog:o,node:s}=i(),{label:c,docRef:l,links:u,openMain:d,openDoc:f,addRef:p,setLinkTag:m,canEdit:h}=O({kind:e,owner:t,model:n});if(!t||!l)return null;let g=l.startsWith(`rel:`)?l.slice(4):l,_=u.filter(e=>!e.main),v=()=>p(o,r).catch(e=>r(String(e.message||e))),y=e=>{(async()=>{let t=await o({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 m(e.docId,n,e),r(n?`标签已设为 [${n}]`:`标签已清除`)})().catch(e=>r(String(e.message||e)))};return(0,S.jsxs)(`div`,{className:`nx-intro`,children:[(0,S.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,S.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${c}(新页签阅读 / 编辑)`,onClick:d,children:c}),(0,S.jsx)(`span`,{className:`nx-intro-path mono`,children:g}),(0,S.jsx)(`span`,{className:`nx-intro-spacer`}),h&&l.startsWith(`rel:`)&&(0,S.jsx)(`button`,{type:`button`,className:`nx-intro-btn`,title:`补充一篇介绍文档(reference)`,onClick:v,children:`+ ref`})]}),_.length>0&&(0,S.jsxs)(`div`,{className:`nx-intro-links`,children:[(0,S.jsx)(`span`,{className:`nx-intro-links-lab`,children:`补充`}),_.map(e=>(0,S.jsxs)(`span`,{className:`nx-intro-link-item`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`nx-intro-link`+(e.docId.startsWith(`path:`)?` ext`:``),title:e.note?`${e.label} — ${e.note}`:e.label,onClick:()=>f(e.docId),children:[(0,S.jsx)(`span`,{className:`nx-intro-link-label`,children:e.label}),e.tag?(0,S.jsx)(`span`,{className:`nx-intro-link-tag`,title:`标签:${e.tag}`,children:e.tag}):null,e.note?(0,S.jsx)(`span`,{className:`nx-intro-link-note`,children:e.note}):null,e.docId.startsWith(`path:`)?(0,S.jsx)(`span`,{className:`nx-intro-link-tag`,children:`外部`}):null]}),h&&!e.ref&&(0,S.jsx)(`button`,{type:`button`,className:`nx-intro-tag-btn`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,"aria-label":`标签:${e.label}`,onClick:()=>y(e),children:`#`})]},e.docId))]}),s]})}export{b as n,C as r,A as t};
|