nx-kv 0.35.0 → 0.37.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 +24 -0
- package/package.json +1 -1
- package/src/web/frontend/components/md/attach-modal.jsx +3 -2
- package/src/web/frontend/components/md/composer-panel.jsx +164 -1
- package/src/web/frontend/page/dir/task.jsx +3 -2
- package/src/web/frontend/page/repos/index.jsx +6 -6
- package/src/web/public/assets/{Introduction-DO6_gTk-.js → Introduction-ChO8BjCo.js} +1 -1
- package/src/web/public/assets/{bar-DoiwB4eA.js → bar-DIcUTKGF.js} +1 -1
- package/src/web/public/assets/{cloud-DSu1a2Dn.js → cloud-B_Zurubz.js} +1 -1
- package/src/web/public/assets/composer-launch-DFD4_RlG.js +1 -0
- package/src/web/public/assets/composer-panel-C_TqQ6UQ.js +1 -0
- package/src/web/public/assets/{dag-_5FWJlq5.js → dag-cynQzBs4.js} +1 -1
- package/src/web/public/assets/{dir-GUpDi0kq.js → dir-BZ_B_vda.js} +1 -1
- package/src/web/public/assets/{group-BzC_R2k-.js → group-plgfiTpl.js} +1 -1
- package/src/web/public/assets/{index-B_HPAoNR.js → index-BmANFdAR.js} +2 -2
- package/src/web/public/assets/{md-panes-BvQXV_C9.js → md-panes-sRhT7DNc.js} +2 -2
- package/src/web/public/assets/{overview-sLaedHVZ.js → overview-BMItQoK-.js} +1 -1
- package/src/web/public/assets/{progress-DOI2YFEi.js → progress-BJaEAKUn.js} +1 -1
- package/src/web/public/assets/{refs-D97SxNRW.js → refs-_aYVi9zo.js} +1 -1
- package/src/web/public/assets/{repos-fp0D_GDq.js → repos-_KRfq-H_.js} +2 -2
- package/src/web/public/assets/{route-crumb-C5LPu1Qx.js → route-crumb-DHYbpsO8.js} +1 -1
- package/src/web/public/assets/{settings-D13mfwe0.js → settings-3UzVUmIA.js} +1 -1
- package/src/web/public/assets/{status-tag-D4wxIj1q.js → status-tag-CdoKlRNG.js} +1 -1
- package/src/web/public/assets/{task-Cu-rh5jA.js → task-DoX0agEw.js} +7 -7
- package/src/web/public/assets/{templates-xbR-qZMs.js → templates-MVbMU84b.js} +1 -1
- package/src/web/public/assets/{tool-bar-CHoZSF6T.js → tool-bar-BwMNTrR1.js} +1 -1
- package/src/web/public/index.html +1 -1
- package/src/web/public/assets/composer-launch-D-b7HKk5.js +0 -1
- package/src/web/public/assets/composer-panel-CJuaj0Jp.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{S as e,_ as t,f as n,g as r,l as i,p as a,v as o,y as s}from"./task-status-BP6y8MVu.js";import{_ as c,c as l,d as u,f as d,g as f,h as p,i as m,p as ee,u as te,v as ne}from"./md-parse-C2bDc3IZ.js";import{n as h,t as g}from"./board-view-t8CKtq17.js";import{E as re,M as ie,O as ae,c as oe,d as se,f as ce,h as le,k as ue,l as de,m as fe,p as _,s as pe,u as me}from"./index-
|
|
1
|
+
import{S as e,_ as t,f as n,g as r,l as i,p as a,v as o,y as s}from"./task-status-BP6y8MVu.js";import{_ as c,c as l,d as u,f as d,g as f,h as p,i as m,p as ee,u as te,v as ne}from"./md-parse-C2bDc3IZ.js";import{n as h,t as g}from"./board-view-t8CKtq17.js";import{E as re,M as ie,O as ae,c as oe,d as se,f as ce,h as le,k as ue,l as de,m as fe,p as _,s as pe,u as me}from"./index-BmANFdAR.js";import{o as he,t as ge}from"./md-panes-sRhT7DNc.js";import{t as _e}from"./status-tag-CdoKlRNG.js";import{a as ve,i as ye,n as be,o as xe}from"./composer-launch-DFD4_RlG.js";import{t as Se}from"./route-crumb-DHYbpsO8.js";import{i as Ce,n as we,r as Te,t as Ee}from"./reopen-text-BylkngqC.js";import{n as De,u as Oe}from"./tool-bar-BwMNTrR1.js";import{i as ke,n as Ae,r as je,t as Me}from"./md-history-Uo6U7hYS.js";var v=e(s(),1),y=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,b=/完成总结/,x=/反馈/,S=/第\s*(\d+)\s*轮/;function C(e){let t=String(e??``).split(`
|
|
2
2
|
`),n=t.length&&String(t[0]).match(y);if(!n)return null;let r=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
|
|
3
|
-
`);return{title:String(n[1]??``).trim(),body:r}}function
|
|
3
|
+
`);return{title:String(n[1]??``).trim(),body:r}}function Ne(e){let t=l(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=C(a);if(o&&b.test(o.title)){let e=Number((o.title.match(S)||[])[1]);r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&x.test(o.title)){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
|
|
4
4
|
`:``)+a:r.feedbackText+=(r.feedbackText?`
|
|
5
|
-
`:``)+a)}),n.filter(e=>e.ackText!==``)}function
|
|
6
|
-
`).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 Pe=`nx-kv-ack-rail-pos`;function w(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 T(){try{let e=JSON.parse(localStorage.getItem(Pe)||`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 Fe(e){try{e?localStorage.setItem(Pe,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(Pe)}catch{}}var E=o(),D=4;function O(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=[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1);return i[n]?i[n]:null}function Ie({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(0),[s,c]=(0,v.useState)(T),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(!1);(0,v.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=w({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,v.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{}},[]),ee=(0,v.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)<D)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=w({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))},[]),te=(0,v.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,Fe(t.last)))},[]),ne=(0,v.useCallback)(()=>{c(null),Fe(null)},[]),h=(0,v.useMemo)(()=>(e||[]).map(e=>({...e,title:Ne(e)})),[e]);(0,v.useEffect)(()=>{let e=t;if(!e||!h.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of h){let i=O(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,h]);let g=(0,v.useCallback)(e=>{let r=t,i=r?O(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return h.length?(0,E.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,E.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:ee,onPointerUp:te,onPointerCancel:te,onDoubleClick:ne,children:[(0,E.jsx)(`span`,{}),(0,E.jsx)(`span`,{}),(0,E.jsx)(`span`,{})]}),(0,E.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:h.map(e=>(0,E.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:()=>g(e)},e.round))}),r&&(0,E.jsx)(`div`,{className:`doc-rail-panel`,children:(0,E.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,E.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),h.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>g(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}function Le({attachments:e,onRemove:t}){return e?.length?(0,E.jsxs)(`div`,{className:`mdw-attach`,children:[(0,E.jsx)(`div`,{className:`lab`,children:`附件 / 图片`}),(0,E.jsx)(`div`,{className:`list`,children:e.map(e=>(0,E.jsxs)(`div`,{className:`att`,children:[e.type===`image`&&e.url?(0,E.jsx)(`img`,{src:e.url,alt:``}):(0,E.jsx)(`div`,{className:`ico`,children:(0,E.jsx)(a,{name:`list`,size:14})}),(0,E.jsxs)(`div`,{className:`meta`,children:[(0,E.jsx)(`div`,{className:`n`,children:e.name}),(0,E.jsx)(`div`,{className:`s`,children:e.size})]}),(0,E.jsx)(`button`,{type:`button`,className:`x`,"aria-label":`移除`,onClick:()=>t(e.id),children:`×`})]},e.id))})]}):null}var k=[{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 Re({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,E.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,E.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[k.map(e=>(0,E.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,E.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,E.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,E.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,E.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`cap`,children:`选区`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,E.jsx)(`div`,{className:`sep`}),(0,E.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`sep`}),(0,E.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var A=[{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 ze({onClose:e}){return(0,E.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,E.jsx)(`div`,{className:`mdw-sheet-cols`,children:A.map(e=>(0,E.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,E.jsx)(`h4`,{children:e.title}),(0,E.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,E.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,E.jsx)(`dt`,{children:(0,E.jsx)(`kbd`,{children:e})}),(0,E.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var j={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function Be({nodes:e=[],onOpenNode:t}){return e.length?(0,E.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=j[n.kind]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,E.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,E.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,E.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,E.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,E.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,E.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,E.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,E.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,E.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Ve({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,E.jsxs)(i,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,E.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,E.jsx)(Be,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function M({dirKey:e,groupId:i,task:o,beside:s=!1,tabId:y,model:b,historyId:x=null}){let S=ue()||{},C=r(),{dialog:Ne,node:Pe}=n(),w=S.rows||[],T=S.refreshLocal,Fe=S.tpl,D=!(!i||e),O=(0,v.useMemo)(()=>D?h(w,S.repoData&&S.repoData.boards||[],i,o):null,[D,w,S.repoData,i,o]),k=O&&O.topic&&O.topic.key||e||``,A=!D&&(!k||k===`__GLOBAL__`),j=de(o),Be=fe(D&&j?i:k),M=pe(Be,o),N=(0,v.useMemo)(()=>D?O&&O.topic||null:A?w.find(e=>e.isGlobal)||null:w.find(e=>e.key===k)||null,[w,k,A,D,O]),P=(0,v.useMemo)(()=>(N?.tasks||[]).find(e=>String(e.id)===String(o))||null,[N,o]),We=le(),F=We[M]||null,Ge=F&&F.mode===`edit`?`edit`:`split`,[Ke,qe]=(0,v.useState)(null);(0,v.useEffect)(()=>{qe(null)},[M]);let I=P?.timegoal||null,L=Ke||{duration:I?.duration||``,prompt:I?.prompt||``},Je=j||!!P&&P.status===`pending`,Ye=!j&&!!I&&o!=null,[R,Xe]=(0,v.useState)({busy:!1,error:``,data:null}),Ze=(0,v.useCallback)(()=>{if(j||!k||o==null)return;Xe(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(o),key:String(k)});t(`/api/localtasks/timegoal-log?${e.toString()}`).then(e=>Xe(t=>({...t,data:e,busy:!1}))).catch(e=>Xe(t=>({...t,busy:!1,error:String(e.message||e)})))},[j,k,o]);(0,v.useEffect)(()=>{Ye&&Ze()},[Ye,Ze]);let[z,Qe]=(0,v.useState)(()=>localStorage.getItem(`nxkv.taskDockOpen`)!==`0`),[B,$e]=(0,v.useState)(()=>localStorage.getItem(`nxkv.taskDockTab`)||`attach`),[et,tt]=(0,v.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.taskDockH`));return Number.isFinite(e)&&e>=96?e:176}),nt=(0,v.useRef)(et);nt.current=et;let rt=(0,v.useRef)(null),[it,at]=(0,v.useState)(!1),ot=(0,v.useRef)(176);(0,v.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockOpen`,z?`1`:`0`)},[z]),(0,v.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockTab`,B)},[B]);let V=(0,v.useCallback)(e=>{$e(e),Qe(!0)},[]),st=(0,v.useCallback)(e=>{if(!z)return;e.preventDefault(),at(!1);let t=e.clientY,n=nt.current,r=rt.current?.parentElement?.clientHeight||window.innerHeight,i=e=>Math.max(96,Math.min(Math.round(r*.62),Math.round(e))),a=e=>{let r=i(n-(e.clientY-t));nt.current=r,tt(r)},o=()=>{window.removeEventListener(`mousemove`,a),window.removeEventListener(`mouseup`,o),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.taskDockH`,String(nt.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,a),window.addEventListener(`mouseup`,o)},[z]),ct=(0,v.useCallback)(()=>{V(`check`),Ze()},[V,Ze]),lt=(0,v.useCallback)(()=>{if(it){tt(ot.current),at(!1);return}ot.current=nt.current;let e=rt.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));nt.current=t,tt(t),at(!0)},[it]),ut=(0,v.useCallback)(()=>{V(`attach`),setTimeout(()=>xt.current?.open(),0)},[V]),dt=()=>{let t=b||S.model;t&&be(t,{mode:`feedback`,taskLabel:o==null?``:`#`+o,taskTitle:String(F?.title||``).replace(/^#+\s*/,``),prevQuote:String(P?.roundSummary||``).trim()||String(F?.body||``).trim().slice(0,400),src:{dirKey:k||e||`__GLOBAL__`,task:String(o),name:`原文 #${o}`},onSubmit:e=>pt(e)})},ft=async()=>{if(j||o==null||/^draft/i.test(String(o)))return null;let e=A?`key=${encodeURIComponent(g)}&id=${Number(o)}`:`cwd=${encodeURIComponent(N?.cwd||``)}&id=${Number(o)}`;return t(`/api/localtasks/item?${e}`).catch(()=>null)},pt=({text:e,attachments:n=[],inserts:r=``}={})=>{let a=String(e||``).trim();if($(),!a&&!(n&&n.length)){C(`写一下反馈`);return}let s=F?.title||`#${o}`;J(async()=>{let e=await ft(),c=String(e?.text??``).trim()||String(F?.body??``).trim();if(!c&&!j){C(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let l=a||`(见附件)`;r&&(l=`${l}${r}`);let u=Te({base:c,feedback:l,ackSummary:e?.roundSummary||P?.roundSummary||``,feedbackHeading:Ce,bold:!0}),d=!j&&o!=null&&!/^draft/i.test(String(o))?{forkOf:String(o),forkKind:`reopen`}:{},f=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:u,...d}:{cwd:N?.cwd,text:u,...d}}),m=String(f?.task?.id??f?.id??``);if(!m){C(`反馈已提交,但未拿到新任务编号`),T();return}let ee=f?.key||k;_(pe(fe(ee),m),{title:p(u),body:u}),n?.length&&ve(m,n),C(`已反馈「${s}」→ 新任务 #${m}`),T(),S.openPage&&(D?S.openPage({groupId:i,task:m,name:`${s.slice(0,24)}(反馈)`}):S.openPage({dirKey:ee,task:m,name:`${s.slice(0,24)}(反馈)`}))})},mt=({text:e,attachments:n=[],inserts:r=``,quote:i}={})=>{let a=String(e||``).trim(),s=String(i||q.current||``).trim();if($(),!a&&!(n&&n.length)){C(`写一下要提的问题`);return}if(!s&&!a){C(`先划选一段再评论`);return}if(j||o==null||/^draft/i.test(String(o))){C(`草稿先提交成任务再评论`);return}let c=F?.title||`#${o}`;J(async()=>{let e=!Dt&&!r&&!(n&&n.length),i;if(!e){let e=await ft(),t=String(e?.text??``).trim()||String(F?.body??``).trim();if(!t){C(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let n=[Se(s),a||`(见附件)`,r].filter(Boolean).join(`
|
|
5
|
+
`:``)+a)}),n.filter(e=>e.ackText!==``)}function Pe(e){let t=String(e?.ackText||``).split(`
|
|
6
|
+
`).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 Fe=`nx-kv-ack-rail-pos`;function w(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 T(){try{let e=JSON.parse(localStorage.getItem(Fe)||`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 Ie(e){try{e?localStorage.setItem(Fe,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(Fe)}catch{}}var E=o(),D=4;function O(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=[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1);return i[n]?i[n]:null}function Le({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(0),[s,c]=(0,v.useState)(T),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(!1);(0,v.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=w({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,v.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{}},[]),ee=(0,v.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)<D)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=w({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))},[]),te=(0,v.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,Ie(t.last)))},[]),ne=(0,v.useCallback)(()=>{c(null),Ie(null)},[]),h=(0,v.useMemo)(()=>(e||[]).map(e=>({...e,title:Pe(e)})),[e]);(0,v.useEffect)(()=>{let e=t;if(!e||!h.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of h){let i=O(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,h]);let g=(0,v.useCallback)(e=>{let r=t,i=r?O(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return h.length?(0,E.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,E.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:ee,onPointerUp:te,onPointerCancel:te,onDoubleClick:ne,children:[(0,E.jsx)(`span`,{}),(0,E.jsx)(`span`,{}),(0,E.jsx)(`span`,{})]}),(0,E.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:h.map(e=>(0,E.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:()=>g(e)},e.round))}),r&&(0,E.jsx)(`div`,{className:`doc-rail-panel`,children:(0,E.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,E.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),h.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>g(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var k=[{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 Re({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,E.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,E.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[k.map(e=>(0,E.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,E.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,E.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,E.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,E.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`cap`,children:`选区`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,E.jsx)(`div`,{className:`sep`}),(0,E.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`sep`}),(0,E.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var A=[{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 ze({onClose:e}){return(0,E.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,E.jsx)(`div`,{className:`mdw-sheet-cols`,children:A.map(e=>(0,E.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,E.jsx)(`h4`,{children:e.title}),(0,E.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,E.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,E.jsx)(`dt`,{children:(0,E.jsx)(`kbd`,{children:e})}),(0,E.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var j={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function Be({nodes:e=[],onOpenNode:t}){return e.length?(0,E.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=j[n.kind]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,E.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,E.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,E.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,E.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,E.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,E.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,E.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,E.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,E.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Ve({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,E.jsxs)(i,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,E.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,E.jsx)(Be,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function M({dirKey:e,groupId:i,task:o,beside:s=!1,tabId:y,model:b,historyId:x=null}){let S=ue()||{},C=r(),{dialog:Pe,node:Fe}=n(),w=S.rows||[],T=S.refreshLocal,Ie=S.tpl,D=!(!i||e),O=(0,v.useMemo)(()=>D?h(w,S.repoData&&S.repoData.boards||[],i,o):null,[D,w,S.repoData,i,o]),k=O&&O.topic&&O.topic.key||e||``,A=!D&&(!k||k===`__GLOBAL__`),j=de(o),Be=fe(D&&j?i:k),M=pe(Be,o),N=(0,v.useMemo)(()=>D?O&&O.topic||null:A?w.find(e=>e.isGlobal)||null:w.find(e=>e.key===k)||null,[w,k,A,D,O]),P=(0,v.useMemo)(()=>(N?.tasks||[]).find(e=>String(e.id)===String(o))||null,[N,o]),We=le(),F=We[M]||null,Ge=F&&F.mode===`edit`?`edit`:`split`,[Ke,qe]=(0,v.useState)(null);(0,v.useEffect)(()=>{qe(null)},[M]);let I=P?.timegoal||null,L=Ke||{duration:I?.duration||``,prompt:I?.prompt||``},Je=j||!!P&&P.status===`pending`,Ye=!j&&!!I&&o!=null,[R,Xe]=(0,v.useState)({busy:!1,error:``,data:null}),Ze=(0,v.useCallback)(()=>{if(j||!k||o==null)return;Xe(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(o),key:String(k)});t(`/api/localtasks/timegoal-log?${e.toString()}`).then(e=>Xe(t=>({...t,data:e,busy:!1}))).catch(e=>Xe(t=>({...t,busy:!1,error:String(e.message||e)})))},[j,k,o]);(0,v.useEffect)(()=>{Ye&&Ze()},[Ye,Ze]);let[z,Qe]=(0,v.useState)(()=>localStorage.getItem(`nxkv.taskDockOpen`)!==`0`),[B,$e]=(0,v.useState)(()=>localStorage.getItem(`nxkv.taskDockTab`)||`attach`),[et,tt]=(0,v.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.taskDockH`));return Number.isFinite(e)&&e>=96?e:176}),nt=(0,v.useRef)(et);nt.current=et;let rt=(0,v.useRef)(null),[it,at]=(0,v.useState)(!1),ot=(0,v.useRef)(176);(0,v.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockOpen`,z?`1`:`0`)},[z]),(0,v.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockTab`,B)},[B]);let V=(0,v.useCallback)(e=>{$e(e),Qe(!0)},[]),st=(0,v.useCallback)(e=>{if(!z)return;e.preventDefault(),at(!1);let t=e.clientY,n=nt.current,r=rt.current?.parentElement?.clientHeight||window.innerHeight,i=e=>Math.max(96,Math.min(Math.round(r*.62),Math.round(e))),a=e=>{let r=i(n-(e.clientY-t));nt.current=r,tt(r)},o=()=>{window.removeEventListener(`mousemove`,a),window.removeEventListener(`mouseup`,o),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.taskDockH`,String(nt.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,a),window.addEventListener(`mouseup`,o)},[z]),ct=(0,v.useCallback)(()=>{V(`check`),Ze()},[V,Ze]),lt=(0,v.useCallback)(()=>{if(it){tt(ot.current),at(!1);return}ot.current=nt.current;let e=rt.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));nt.current=t,tt(t),at(!0)},[it]),ut=(0,v.useCallback)(()=>{V(`attach`),setTimeout(()=>xt.current?.open(),0)},[V]),dt=()=>{let t=b||S.model;t&&be(t,{mode:`feedback`,taskLabel:o==null?``:`#`+o,taskTitle:String(F?.title||``).replace(/^#+\s*/,``),prevQuote:String(P?.roundSummary||``).trim()||String(F?.body||``).trim().slice(0,400),src:{dirKey:k||e||`__GLOBAL__`,task:String(o),name:`原文 #${o}`},onSubmit:e=>pt(e)})},ft=async()=>{if(j||o==null||/^draft/i.test(String(o)))return null;let e=A?`key=${encodeURIComponent(g)}&id=${Number(o)}`:`cwd=${encodeURIComponent(N?.cwd||``)}&id=${Number(o)}`;return t(`/api/localtasks/item?${e}`).catch(()=>null)},pt=({text:e,attachments:n=[],inserts:r=``}={})=>{let a=String(e||``).trim();if($(),!a&&!(n&&n.length)){C(`写一下反馈`);return}let s=F?.title||`#${o}`;J(async()=>{let e=await ft(),c=String(e?.text??``).trim()||String(F?.body??``).trim();if(!c&&!j){C(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let l=a||`(见附件)`;r&&(l=`${l}${r}`);let u=Ee({base:c,feedback:l,ackSummary:e?.roundSummary||P?.roundSummary||``,feedbackHeading:we,bold:!0}),d=!j&&o!=null&&!/^draft/i.test(String(o))?{forkOf:String(o),forkKind:`reopen`}:{},f=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:u,...d}:{cwd:N?.cwd,text:u,...d}}),m=String(f?.task?.id??f?.id??``);if(!m){C(`反馈已提交,但未拿到新任务编号`),T();return}let ee=f?.key||k;_(pe(fe(ee),m),{title:p(u),body:u}),n?.length&&ve(m,n),C(`已反馈「${s}」→ 新任务 #${m}`),T(),S.openPage&&(D?S.openPage({groupId:i,task:m,name:`${s.slice(0,24)}(反馈)`}):S.openPage({dirKey:ee,task:m,name:`${s.slice(0,24)}(反馈)`}))})},mt=({text:e,attachments:n=[],inserts:r=``,quote:i}={})=>{let a=String(e||``).trim(),s=String(i||q.current||``).trim();if($(),!a&&!(n&&n.length)){C(`写一下要提的问题`);return}if(!s&&!a){C(`先划选一段再评论`);return}if(j||o==null||/^draft/i.test(String(o))){C(`草稿先提交成任务再评论`);return}let c=F?.title||`#${o}`;J(async()=>{let e=!Dt&&!r&&!(n&&n.length),i;if(!e){let e=await ft(),t=String(e?.text??``).trim()||String(F?.body??``).trim();if(!t){C(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let n=[Ce(s),a||`(见附件)`,r].filter(Boolean).join(`
|
|
7
7
|
|
|
8
|
-
`);i=
|
|
9
|
-
`).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),t=Array.isArray(P.history)?P.history:[];if(t.length){let n=t.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return n.push({historyId:null,kind:`current`,at:P.lastReopenedAt||P.createdAt||``,excerpt:e,attachmentCount:0,current:!0}),n}let n=Array.isArray(Y?.ancestors)?[...Y.ancestors].reverse():[],r=Array.isArray(Y?.children)?Y.children:[];if(!n.length&&!r.length&&!P.forkOf)return[];let i=[];for(let e of n)e.missing||i.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});i.push({historyId:null,kind:`current`,at:P.createdAt||``,excerpt:e,attachmentCount:0,current:!0,taskId:Number(o),dirKey:k||`__GLOBAL__`});for(let e of r)i.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return i},[j,P,Y,o,k]),X=(0,v.useMemo)(()=>{if(x==null||!P)return null;let e=Number(x);return(P.history||[]).find(t=>Number(t.id)===e)||null},[x,P]),Gt=Array.isArray(Y?.children)?Y.children:[],Kt=Gt.length===0,Z=Gt.length?Gt[Gt.length-1]:null,qt=(0,v.useCallback)(()=>{Z&&S.openPage&&(D?S.openPage({groupId:i,task:String(Z.id),name:`#${Z.id}`}):S.openPage({dirKey:String(Z.key||k||`__GLOBAL__`),task:String(Z.id),name:`#${Z.id}`}))},[Z,S.openPage,D,i,k]),Q=(0,v.useCallback)(()=>Ot(!0),[]),Jt=(e,t)=>{let n=(e||``).trim()||`未命名任务`,r=f(t),i=Object.keys(r).length>0,a=c(t);return a=d(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?ne(a,r):a},[Yt,Xt]=(0,v.useState)(null),Zt=(0,v.useCallback)(()=>{Xt({busy:!0});let e={cwd:A?N?.cwd||void 0:N?.cwd,key:A?g:k,...j?{text:Jt((F?.title||``).trim()||`未命名任务`,F?.body||``)}:{id:Number(o)}};t(`/api/localtasks/preview`,{method:`POST`,body:e}).then(e=>Xt({data:e})).catch(e=>Xt({error:String(e.message||e)}))},[A,N?.cwd,k,j,F?.title,F?.body,o]),Qt=()=>{let e=(L.duration||``).trim(),t=(L.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!Je)return{};if(!j){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}:{}},$t=()=>J(async()=>{if(!F)return;let e=(F.title||``).trim()||`未命名任务`,n=f(F.body),r=Jt(e,F.body),a=n.project?w.find(e=>!e.isGlobal&&e.repo&&e.repo.key===n.project):null,s=!!(W&&n.project&&W.members.some(e=>e.key===n.project)),c=Qt();if(c.error){C(c.error);return}if(!j){let n=await t(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:A?a?a.cwd:void 0:N?.cwd,key:A&&!a?g:void 0,id:Number(o),text:r,...c}});if(n?.moved){let t=n.key||k,a=String(n.task?.id??o),s=pe(fe(t),a);ve(a,F.attachments),ce(M,s,{title:e,body:n.task?.text||r}),b&&y&&b.doAction(ie.updateNodeAttributes(y,{config:D?{groupId:i,task:a}:{dirKey:t,task:a}})),S.onNavigate&&S.onNavigate(D?`#/group/${encodeURIComponent(i||``)}?task=${encodeURIComponent(a)}`:`#/dir/${encodeURIComponent(t||``)}?task=${encodeURIComponent(a)}`),Ot(!1),je(Et.current,s),C(`已改归属项目:任务迁到「${n.name}」#${a}`),T();return}ve(o,F.attachments),_(M,{title:e,body:r}),Ot(!1),je(Et.current,M),C(c.clearGoal?`已同步 MD · 时间目标已清除`:c.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),T();return}let l=await t(`/api/localtasks`,{method:`POST`,body:{...s?{text:r,board:W.board.id,project:n.project}:n.project?{text:r,project:n.project}:A?{global:!0,text:r}:{cwd:N?.cwd,text:r},...c}}),d=l?.task?.id??l?.id;if(d!=null){let t=l?.key||k,n=fe(t);ve(d,F.attachments);let a=pe(n,String(d));ce(M,a,{title:e,body:r}),b&&y&&b.doAction(ie.updateNodeAttributes(y,{config:D?{groupId:i,task:String(d)}:{dirKey:t,task:String(d)}})),S.onNavigate&&S.onNavigate(D?`#/group/${encodeURIComponent(i||``)}?task=${encodeURIComponent(String(d))}`:`#/dir/${encodeURIComponent(t||``)}?task=${encodeURIComponent(String(d))}`),Ot(!1),je(Et.current,a)}C(`已提交:${u(e)}`),T()}),en=async e=>{let n=await e.text(),r=e.name.replace(/\.md$/i,``);await J(async()=>{let a=n.startsWith(`#`)?n:`# ${r}\n\n${n}`,o=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:a}:D&&H.project?{project:H.project,text:a}:{cwd:N?.cwd,text:a}});C(`已导入:${e.name}`),T();let s=o?.task?.id??o?.id;s!=null&&S.openPage&&(D?S.openPage({groupId:i,task:String(s),name:`#${s}`}):S.openPage({dirKey:k,task:String(s),name:`#${s}`}))})},tn=async()=>{if(!F||j)return;let e=F.title||`#${o}`;await Ne({title:`删除任务「${e}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&J(async()=>{await t(`/api/localtasks/item`,{method:`DELETE`,body:A?{key:g,id:Number(o)}:{cwd:N.cwd,id:Number(o)}}),C(`已删除「${e}」`),b&&y&&b.doAction(ie.deleteTab(y)),T()})},nn=!j&&!!P&&P.status===`pending`,rn=e=>{nn&&J(async()=>{let n=F?.title||`#${o}`,r=A?{key:g}:{cwd:N?.cwd};if(e===`done`){let e=await Ne({title:`标为完成「${n}」`,message:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(e==null)return;await t(`/api/localtasks/items/close`,{method:`POST`,body:{...r,ids:[Number(o)],status:`done`,summary:String(e).trim()}}),C(`已标为完成 #${o}`)}else{if(!await Ne({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await t(`/api/localtasks/items/close`,{method:`POST`,body:{...r,ids:[Number(o)],status:`cancelled`}}),C(`已取消 #${o}`)}T()})},an=async(e,n={})=>{if(!F)return;let{items:r,imageInserts:i,fileInserts:a}=await ye(e),s=se(M)||F,c=s.body||``,l=i.join(``),u=c,d=null;if(l){let e=m(c,l,n);u=e.body,d=e.insertAt+l.length}a.length&&(u=m(u,a.join(``),{}).body);let f={};if(u!==c&&(f.body=u),r.length&&(f.attachments=[...s.attachments||[],...r]),Object.keys(f).length){if(_(M,f),n.mode===`edit`&&d!=null&&requestAnimationFrame(()=>{Tt.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(d,d)}catch{}}),!j){f.attachments&&ve(o,f.attachments);let e=Jt(s.title,f.body||u);_(M,{body:e,title:p(e)});try{await t(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:A?void 0:N?.cwd,key:A?g:void 0,id:Number(o),text:e}}),Ot(!1),T(),C(r.length?`已添加附件并同步(${r.length})`:`已同步附件`)}catch(e){Q(),C(`附件已插入,同步失败:${e.message||e}`)}return}Q()}},$=()=>{K(null),q.current=``},on=()=>{let e=me(),t=pe(fe(D?i:k),e),n={};W&&W.board&&W.board.id&&(n.board=W.board.id),H.project&&(n.project=H.project),_(t,{title:``,body:ne(Fe?Fe.defaultBody():``,n)}),S.openPage&&S.openPage(D?{groupId:i,task:e,name:`新任务`}:{dirKey:k,task:e,name:`新任务`})},sn=()=>{if(j||o==null||/^draft/i.test(String(o))){C(`草稿没有可克隆的队列任务`);return}J(async()=>{let e=await t(`/api/localtasks/clone`,{method:`POST`,body:A?{id:Number(o)}:{id:Number(o),cwd:N?.cwd}});C(`已克隆为新任务 #${e.task?.id??e.id}`),T();let n=e?.task?.id??e?.id;n!=null&&S.openPage&&(D?S.openPage({groupId:i,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(克隆)`}):S.openPage({dirKey:k,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(克隆)`}))})},cn=()=>{if(j||o==null||/^draft/i.test(String(o))){C(`草稿没有可 Fork 的队列任务`);return}J(async()=>{let e=await t(`/api/localtasks/fork`,{method:`POST`,body:A?{id:Number(o)}:{id:Number(o),cwd:N?.cwd}});C(`已 Fork 为新任务 #${e.task?.id??e.id}(保留任务链)`),T();let n=e?.task?.id??e?.id;n!=null&&S.openPage&&(D?S.openPage({groupId:i,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(Fork)`}):S.openPage({dirKey:k,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(Fork)`}))})},ln=()=>{let t=String(window.getSelection()||``).trim()||(G?.text?String(G.text):``);if(!t){C(`先划选一段再评论`);return}q.current=t;let n=b||S.model;n&&(be(n,{mode:`comment`,quote:t,taskLabel:o==null?``:`#`+o,taskTitle:String(F?.title||``).replace(/^#+\s*/,``),src:{dirKey:k||e||`__GLOBAL__`,task:String(o),name:`原文 #${o}`},onSubmit:e=>mt({...e,quote:t})}),$())},un=(e,t=`typing`)=>{if(!F)return;ke(Et.current,M,{title:F.title,body:F.body},t),Q();let n={title:e};Ge!==`split`&&/^# (?!#)/m.test(F.body)&&(n.body=F.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),_(M,n)},dn=(e,t=`op`)=>{if(!F)return;ke(Et.current,M,{title:F.title,body:F.body},t),Q();let n={body:e};Ge!==`split`&&(n.title=p(e)),_(M,n)},fn=()=>{if(!F)return;let e=Oe(Et.current,M,{title:F.title,body:F.body});e&&(_(M,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>Tt.current?.caretFromDiff?.(F.body,e.body)))},pn=()=>{if(!F)return;let e=Ae(Et.current,M,{title:F.title,body:F.body});e&&(_(M,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>Tt.current?.caretFromDiff?.(F.body,e.body)))},mn=(e,t,n,r,i={})=>{q.current=t,K({kind:e,text:t,...i,x:Math.min(window.innerWidth-300,Math.max(8,n)),y:Math.min(window.innerHeight-240,Math.max(8,r))})},hn=e=>{if(!e?.text||e.text.length<1){K(null);return}q.current=e.text,K({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},gn=e=>{if(!F||Ge===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){K(null);return}if(!St.current?.contains(t.anchorNode)){K(null);return}let r=e=>e?.nodeType===3?e.parentElement:e,i=r(t.anchorNode)?.closest?.(`.mdw-lp-block`),a=r(t.focusNode)?.closest?.(`.mdw-lp-block`),o=null;if(i&&a&&i!==a&&St.current?.contains(a)){let e=Number(i.getAttribute(`data-i`)),t=Number(a.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(o=[Math.min(e,t),Math.max(e,t)])}let s=t.getRangeAt(0),c=s.getClientRects(),l=c.length?c[c.length-1]:s.getBoundingClientRect();mn(`task`,n,l.right-60,l.bottom+8,o?{blockRange:o}:{})},_n=e=>{bt.current.accept=e,bt.current?.click()};if((0,v.useEffect)(()=>{if(!U||s)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),Bt())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[U,s,Bt]),x!=null){let e={origin:`起点`,reopen:`反馈`,comment:`评论`}[X?.kind]||`节点`,t=X?te(X.text||``,X.attachments||[]):``;return(0,E.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,E.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,E.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,e,` #`,x]}),(0,E.jsx)(`span`,{className:`grow`}),(0,E.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:Ht,children:`×`})]}),(0,E.jsx)(`div`,{className:`mdw-hist-ro`,children:X?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,E.jsx)(`span`,{children:X.at||`—`}),X.quote?(0,E.jsxs)(`span`,{children:[`锚定:`,X.quote.slice(0,80)]}):null,X.feedback?(0,E.jsxs)(`span`,{children:[`反馈:`,X.feedback.slice(0,80)]}):null,X.summary?(0,E.jsxs)(`span`,{children:[`上轮总结:`,X.summary.slice(0,80)]}):null]}),(0,E.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:t||`<p class="muted">(空)</p>`}})]}):(0,E.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,x]})})]})}if(!F)return S.localReady===!1||j?(0,E.jsx)(`div`,{className:`mdw`,children:(0,E.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,E.jsx)(`div`,{className:`mdw`,children:(0,E.jsxs)(`div`,{className:`pad stack`,children:[(0,E.jsx)(`div`,{children:(0,E.jsxs)(`strong`,{children:[`找不到任务 #`,o]})}),(0,E.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,E.jsx)(`div`,{children:(0,E.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>S.onNavigate&&S.onNavigate(D?`#/group/`+encodeURIComponent(i||``):A?`#/global`:`#/dir/`+encodeURIComponent(e||``)),children:`回到目录`})})]})});let vn=(L.duration||``).trim(),yn=(L.prompt||``).trim(),bn=vn||yn?{label:`⏱ ${vn||`目标`}`,title:yn||(Je?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,声明不可改`)}:null,xn=Je||I?(0,E.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,E.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),Je?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`input`,{className:`mdw-goal-dur mono`,value:L.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:e=>{qe({...L,duration:e.target.value}),Q()}}),(0,E.jsx)(`input`,{className:`mdw-goal-prompt`,value:L.prompt,placeholder:`附加要求(可选,随 check 指令一起固化)`,onChange:e=>{qe({...L,prompt:e.target.value}),Q()}})]}):(0,E.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:I?.prompt||`已领取计时,声明不可改`,children:[I?.duration||`—`,` · 已领取计时`]}),I&&o!=null?(0,E.jsx)(`button`,{type:`button`,className:`ghost`,onClick:ct,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null;return(0,E.jsxs)(`div`,{className:`mdw${s?` is-beside`:``}`,"data-mode":Ge,onMouseUp:gn,children:[Pe,Yt&&(0,E.jsx)(He,{state:Yt,onClose:()=>Xt(null)}),(0,E.jsx)(Ve,{open:_t,nodes:Wt,onOpenNode:Vt,onClose:()=>vt(!1)}),s&&(0,E.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,E.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,E.jsx)(`span`,{className:`grow`}),(0,E.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:Ht,children:`×`})]}),(0,E.jsxs)(`div`,{className:`mdw-main`,children:[(0,E.jsxs)(`div`,{className:`mdw-top`,children:[(0,E.jsx)(xe,{}),(0,E.jsxs)(`div`,{className:`mdw-head`,children:[(0,E.jsx)(`div`,{className:`mdw-title`,children:j?F.title||`新 MD 任务`:F.title||`任务`}),(0,E.jsxs)(`div`,{className:`mdw-path`,children:[A?`全局任务池`:N?.cwd||N?.name||`—`,j?` / (${o})`:` / #${o}`,Dt?` · 未保存`:``]})]})]}),W&&(0,E.jsxs)(`div`,{className:`mdw-goal`,children:[(0,E.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),Je?(0,E.jsx)(`select`,{className:`mdw-proj-pick`,value:H.project||``,onChange:e=>{_(M,{body:ne(F.body,{...H,board:W.board.id,project:e.target.value})}),Q()},children:W.members.map(e=>(0,E.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,E.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(W.members.find(e=>e.key===H.project)||{}).name||H.project||`—`})]}),(0,E.jsx)(Ee,{mode:Ge,onMode:e=>_(M,{mode:e}),showMark:Ge!==`edit`,submitLabel:j?`提交为任务`:`保存并同步`,onNew:on,onSubmit:$t,onChain:j?null:()=>vt(!0),onPreview:Zt,onImg:()=>_n(`image/*`),onAtt:()=>j?_n(`image/*,.pdf,.zip,.txt,.json,.csv`):ut(),onImport:()=>yt.current?.click(),onClone:j?null:sn,onFork:j?null:cn,onComplete:nn?()=>rn(`done`):null,onCancelTask:nn?()=>rn(`cancel`):null,onMark:ln,onDraft:()=>C(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:j?null:tn,onOverview:()=>S.onNavigate&&S.onNavigate(`#/overview`),onProg:zt,onSource:U?Bt:null,onShortcuts:()=>gt(!0),goalBadge:bn,goalMenu:xn}),(0,E.jsx)(ge,{ref:St,mode:Ge,title:F.title,body:F.body,previewHtml:Pt,onTitle:un,onBody:dn,attachments:F.attachments,docKey:M,editorApiRef:Tt,onFiles:an,onTextSel:hn,onSave:$t,onUndo:fn,onRedo:pn,onCloseSelMenu:$,attachHost:j?null:{host:`task`,hostId:Number(o),hostKey:A?g:void 0,hostCwd:A?void 0:N?.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(N.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),z&&(0,E.jsxs)(`div`,{className:`mdw-dock`,ref:rt,style:{height:`${et}px`},children:[(0,E.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:st,onDoubleClick:lt}),(0,E.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,E.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,E.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":B===`attach`,className:`mdw-dock-tab${B===`attach`?` is-on`:``}`,onClick:()=>V(`attach`),children:`附件`}),Ye?(0,E.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":B===`check`,className:`mdw-dock-tab${B===`check`?` is-on`:``}`,onClick:ct,children:[`check`,(0,E.jsx)(`span`,{className:`mdw-dock-tab-num`,children:R.data?.count??0})]}):null,(0,E.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":B===`feedback`,className:`mdw-dock-tab${B===`feedback`?` is-on`:``}`,onClick:()=>V(`feedback`),children:`反馈`})]}),(0,E.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,E.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:lt,title:it?`还原面板高度`:`最大化面板高度`,"aria-label":it?`还原面板高度`:`最大化面板高度`,children:(0,E.jsx)(a,{name:it?`collapse`:`expand`})}),(0,E.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>Qe(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,E.jsx)(a,{name:`x`})})]})]}),(0,E.jsxs)(`div`,{className:`mdw-dock-body`,children:[B===`attach`?j?(0,E.jsx)(Le,{attachments:F.attachments,onRemove:e=>{let t=(F.attachments||[]).filter(t=>t.id!==e);Q(),_(M,{attachments:t}),j||ve(o,t)}}):N?(0,E.jsx)(De,{ref:xt,host:`task`,hostId:Number(o),hostKey:A?`__GLOBAL__`:void 0,hostCwd:A?void 0:N.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(N.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:T,onOpenTask:e=>{S.openPage&&e&&e.seq!=null&&S.openPage({dirKey:e.key||k,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=he(e);b&&t&&ae(b,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,B===`check`?(0,E.jsxs)(`div`,{className:`mdw-dock-check`,children:[R.busy&&!R.data?(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,R.error?(0,E.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,R.error]}):null,R.data?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${R.data.duration||`—`}`,R.data.startedAt?` · 开始 ${R.data.startedAt}`:``,R.data.deadline?` · 截止 ${R.data.deadline}`:` · 尚未开始计时`,R.data.archived?` · 已归档`:``,` · ${R.data.count||0} 轮`]}),(R.data.count||0)>0?(0,E.jsx)(`div`,{className:`mdw-goal-log`,children:R.data.entries.map((e,t)=>(0,E.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,E.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,Ue(e.elapsedSec),` · 剩余 `,Ue(e.remainingSec)]}),e.summary?(0,E.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,E.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,B===`feedback`?!j&&P?.completedAt?(0,E.jsxs)(`div`,{className:`mdw-review`,ref:Ct,children:[(0,E.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,E.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,E.jsx)(`span`,{className:`mdw-review-at mono`,children:P.completedAt}),P.roundSummary?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{ref:wt,className:`mdw-review-sum${kt?` is-open`:``}`,title:kt||!(jt||Nt)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:Ft}}),(jt||Nt||kt)&&(0,E.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>At(e=>!e),children:kt?`收起`:`展开全文`})]}):null]}),(0,E.jsx)(`div`,{className:`mdw-review-acts`,children:Kt?(0,E.jsx)(`button`,{type:`button`,className:`ghost`,onClick:dt,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),Z?(0,E.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:qt,title:`到最新一轮 #${Z.id} 反馈`,children:[`去最新一轮 #`,Z.id]}):null]})})]}):(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]}),(0,E.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${z&&B===`attach`?` is-on`:``}`,onClick:()=>V(`attach`),title:`附件(点击展开信息面板)`,children:[(0,E.jsx)(a,{name:`list`}),(0,E.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),Ye?(0,E.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${z&&B===`check`?` is-on`:``}`,onClick:ct,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,E.jsx)(a,{name:`clock`}),(0,E.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,E.jsx)(`span`,{className:`mdw-sbar-num`,children:R.data?.count??0})]}):null,(0,E.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${z&&B===`feedback`?` is-on`:``}`,onClick:()=>V(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,E.jsx)(a,{name:`edit`}),(0,E.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,E.jsx)(`span`,{className:`mdw-sbar-grow`}),!j&&P?(0,E.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,E.jsx)(_e,{t:P})}):null,(0,E.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${z?` is-open`:``}`,onClick:()=>Qe(e=>!e),title:z?`收起信息面板`:`展开信息面板`,"aria-expanded":z,"aria-label":z?`收起信息面板`:`展开信息面板`,children:(0,E.jsx)(a,{name:`chevron`})})]})]}),(0,E.jsx)(Ie,{nodes:It,scrollRoot:Lt}),(0,E.jsx)(Re,{at:G,onFormat:e=>{Tt.current?.format?.(e),$()},onCompose:()=>{let t=b||S.model;if(!t)return;let n=String(G?.text||q.current||``);be(t,{mode:`comment`,quote:n,taskLabel:o==null?``:`#`+o,taskTitle:String(F?.title||``).replace(/^#+\s*/,``),src:{dirKey:k||e||`__GLOBAL__`,task:String(o),name:`原文 #${o}`},onSubmit:e=>mt({...e,quote:n})}),$()},onCopy:()=>{let e=G?.blockRange,t=``;if(e&&F){let n=l(F.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
|
|
8
|
+
`);i=Ee({base:t,feedback:n,ackSummary:``,feedbackHeading:Te,bold:!1})}let l=await t(`/api/localtasks/reopen`,{method:`POST`,body:{...A?{key:g}:{cwd:N?.cwd},id:Number(o),...i?{text:i}:{},kind:`comment`,quote:s,feedback:a,attachments:(n||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}}),u=l?.key||k,d=String(l?.task?.id??o),f=String(l?.task?.text??i??``);f&&_(pe(fe(u),d),{title:p(f),body:f}),n?.length&&ve(d,[...F?.attachments||[],...n]),b&&y&&u!==k&&b.doAction(ie.updateNodeAttributes(y,{config:{dirKey:u,task:d}})),Ot(!1),C(`已回写评论「${c}」#${d}`),T()})},H=(0,v.useMemo)(()=>F?f(F.body):{},[F&&F.body]),U=(0,v.useMemo)(()=>{if(s)return null;let e=String(H.parent||``).trim(),t=String(H.parentDir||k||``).trim();if(e&&!/^draft/i.test(e))return{dirKey:t||k,task:e,name:`#${e}`};let n=String(F?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!n)return null;let r=n[1].trim(),i=(N?.tasks||[]).find(e=>String(e.id)===String(o)?!1:p(e.text||``)===r||String(e.text||``).includes(`# ${r}`));return i?{dirKey:k,task:String(i.id),name:`#${i.id}`}:null},[s,H.parent,H.parentDir,F?.body,k,N,o]),W=(0,v.useMemo)(()=>{let e=H.board;if(!e)return null;let t=(S.repoData&&S.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=S.repoData&&S.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}))}},[H.board,S.repoData]);(0,v.useEffect)(()=>{We[M]||(j?oe(M,{title:``,body:Ie?D?ne(Ie.defaultBody(),{board:i}):Ie.defaultBody():``}):P&&oe(M,{title:p(P.text),body:P.text}))},[M,j,P,D,i]);let[G,K]=(0,v.useState)(null),[ht,gt]=(0,v.useState)(!1),[_t,vt]=(0,v.useState)(!1),yt=(0,v.useRef)(null),bt=(0,v.useRef)(null),xt=(0,v.useRef)(null),St=(0,v.useRef)(null),Ct=(0,v.useRef)(null),wt=(0,v.useRef)(null),Tt=(0,v.useRef)(null),q=(0,v.useRef)(``),Et=(0,v.useRef)(new Map),[Dt,Ot]=(0,v.useState)(!1),[kt,At]=(0,v.useState)(!1),[jt,Mt]=(0,v.useState)(!1),Nt=String(P?.roundSummary||``).length>140;(0,v.useEffect)(()=>{At(!1),Mt(!1)},[M,P?.roundSummary]),(0,v.useLayoutEffect)(()=>{let e=wt.current;if(!e){Mt(!1);return}let t=()=>{kt||Mt(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()}},[kt,P?.roundSummary,P?.completedAt,B,z]);let Pt=(0,v.useMemo)(()=>F?te(ee(F.body),F.attachments):``,[F]),Ft=(0,v.useMemo)(()=>P?.roundSummary?te(P.roundSummary):``,[P?.roundSummary]),It=(0,v.useMemo)(()=>F?Ne(F.body):[],[F&&F.body]),[Lt,Rt]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=St.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Rt(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Rt(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[F&&F.mode]),(0,v.useEffect)(()=>{K(null),q.current=``},[M]),(0,v.useEffect)(()=>{let e=()=>K(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]);let J=e=>e().catch(e=>C(String(e.message||e))),zt=()=>{let e=b||S.model;if(!e)return;let t=H&&H.board?String(H.board):``;ae(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:o==null?void 0:String(o)}:{dirKey:k||`__GLOBAL__`,task:o==null?void 0:String(o)},location:`right`})},Bt=(0,v.useCallback)(()=>{if(!U){C(`这条任务没有可定位的原文`);return}let e=b||S.model;e&&re(e,{component:`page`,name:U.name||`原文 ${U.task}`,config:{dirKey:U.dirKey,task:String(U.task)}})},[U,b,S.model,C]),Vt=(0,v.useCallback)(e=>{let t=b||S.model;if(t&&!j){if(e?.current){C(`当前节点就是本页`);return}if(e?.historyId!=null){re(t,{component:`page`,name:`链 #${o} · ${e.kind||e.historyId}`,config:{dirKey:k||`__GLOBAL__`,task:String(o),historyId:Number(e.historyId)}});return}if(e?.taskId!=null&&e?.dirKey){re(t,{component:`page`,name:e.excerpt?String(e.excerpt).slice(0,24):`#${e.taskId}`,config:{dirKey:String(e.dirKey),task:String(e.taskId)}});return}C(`这个节点没有可打开的内容`)}},[b,S.model,j,k,o,C]),Ht=(0,v.useCallback)(()=>{let e=b||S.model;e&&y&&e.doAction(ie.deleteTab(y))},[b,S.model,y]),[Y,Ut]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(j||o==null||/^draft/i.test(String(o))){Ut(null);return}let e=!1,n=A?`key=${encodeURIComponent(g)}&id=${Number(o)}`:`cwd=${encodeURIComponent(N?.cwd||``)}&id=${Number(o)}`;return t(`/api/localtasks/chain?${n}`).then(t=>{e||Ut(t)}).catch(()=>{e||Ut(null)}),()=>{e=!0}},[j,o,A,N?.cwd,P?.history?.length,P?.forkOf,P?.reopenCount]);let Wt=(0,v.useMemo)(()=>{if(j||!P)return[];let e=(String(P.text||``).split(`
|
|
9
|
+
`).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),t=Array.isArray(P.history)?P.history:[];if(t.length){let n=t.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return n.push({historyId:null,kind:`current`,at:P.lastReopenedAt||P.createdAt||``,excerpt:e,attachmentCount:0,current:!0}),n}let n=Array.isArray(Y?.ancestors)?[...Y.ancestors].reverse():[],r=Array.isArray(Y?.children)?Y.children:[];if(!n.length&&!r.length&&!P.forkOf)return[];let i=[];for(let e of n)e.missing||i.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});i.push({historyId:null,kind:`current`,at:P.createdAt||``,excerpt:e,attachmentCount:0,current:!0,taskId:Number(o),dirKey:k||`__GLOBAL__`});for(let e of r)i.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return i},[j,P,Y,o,k]),X=(0,v.useMemo)(()=>{if(x==null||!P)return null;let e=Number(x);return(P.history||[]).find(t=>Number(t.id)===e)||null},[x,P]),Gt=Array.isArray(Y?.children)?Y.children:[],Kt=Gt.length===0,Z=Gt.length?Gt[Gt.length-1]:null,qt=(0,v.useCallback)(()=>{Z&&S.openPage&&(D?S.openPage({groupId:i,task:String(Z.id),name:`#${Z.id}`}):S.openPage({dirKey:String(Z.key||k||`__GLOBAL__`),task:String(Z.id),name:`#${Z.id}`}))},[Z,S.openPage,D,i,k]),Q=(0,v.useCallback)(()=>Ot(!0),[]),Jt=(e,t)=>{let n=(e||``).trim()||`未命名任务`,r=f(t),i=Object.keys(r).length>0,a=c(t);return a=d(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?ne(a,r):a},[Yt,Xt]=(0,v.useState)(null),Zt=(0,v.useCallback)(()=>{Xt({busy:!0});let e={cwd:A?N?.cwd||void 0:N?.cwd,key:A?g:k,...j?{text:Jt((F?.title||``).trim()||`未命名任务`,F?.body||``)}:{id:Number(o)}};t(`/api/localtasks/preview`,{method:`POST`,body:e}).then(e=>Xt({data:e})).catch(e=>Xt({error:String(e.message||e)}))},[A,N?.cwd,k,j,F?.title,F?.body,o]),Qt=()=>{let e=(L.duration||``).trim(),t=(L.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!Je)return{};if(!j){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}:{}},$t=()=>J(async()=>{if(!F)return;let e=(F.title||``).trim()||`未命名任务`,n=f(F.body),r=Jt(e,F.body),a=n.project?w.find(e=>!e.isGlobal&&e.repo&&e.repo.key===n.project):null,s=!!(W&&n.project&&W.members.some(e=>e.key===n.project)),c=Qt();if(c.error){C(c.error);return}if(!j){let n=await t(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:A?a?a.cwd:void 0:N?.cwd,key:A&&!a?g:void 0,id:Number(o),text:r,...c}});if(n?.moved){let t=n.key||k,a=String(n.task?.id??o),s=pe(fe(t),a);ve(a,F.attachments),ce(M,s,{title:e,body:n.task?.text||r}),b&&y&&b.doAction(ie.updateNodeAttributes(y,{config:D?{groupId:i,task:a}:{dirKey:t,task:a}})),S.onNavigate&&S.onNavigate(D?`#/group/${encodeURIComponent(i||``)}?task=${encodeURIComponent(a)}`:`#/dir/${encodeURIComponent(t||``)}?task=${encodeURIComponent(a)}`),Ot(!1),Me(Et.current,s),C(`已改归属项目:任务迁到「${n.name}」#${a}`),T();return}ve(o,F.attachments),_(M,{title:e,body:r}),Ot(!1),Me(Et.current,M),C(c.clearGoal?`已同步 MD · 时间目标已清除`:c.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),T();return}let l=await t(`/api/localtasks`,{method:`POST`,body:{...s?{text:r,board:W.board.id,project:n.project}:n.project?{text:r,project:n.project}:A?{global:!0,text:r}:{cwd:N?.cwd,text:r},...c}}),d=l?.task?.id??l?.id;if(d!=null){let t=l?.key||k,n=fe(t);ve(d,F.attachments);let a=pe(n,String(d));ce(M,a,{title:e,body:r}),b&&y&&b.doAction(ie.updateNodeAttributes(y,{config:D?{groupId:i,task:String(d)}:{dirKey:t,task:String(d)}})),S.onNavigate&&S.onNavigate(D?`#/group/${encodeURIComponent(i||``)}?task=${encodeURIComponent(String(d))}`:`#/dir/${encodeURIComponent(t||``)}?task=${encodeURIComponent(String(d))}`),Ot(!1),Me(Et.current,a)}C(`已提交:${u(e)}`),T()}),en=async e=>{let n=await e.text(),r=e.name.replace(/\.md$/i,``);await J(async()=>{let a=n.startsWith(`#`)?n:`# ${r}\n\n${n}`,o=await t(`/api/localtasks`,{method:`POST`,body:A?{global:!0,text:a}:D&&H.project?{project:H.project,text:a}:{cwd:N?.cwd,text:a}});C(`已导入:${e.name}`),T();let s=o?.task?.id??o?.id;s!=null&&S.openPage&&(D?S.openPage({groupId:i,task:String(s),name:`#${s}`}):S.openPage({dirKey:k,task:String(s),name:`#${s}`}))})},tn=async()=>{if(!F||j)return;let e=F.title||`#${o}`;await Pe({title:`删除任务「${e}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&J(async()=>{await t(`/api/localtasks/item`,{method:`DELETE`,body:A?{key:g,id:Number(o)}:{cwd:N.cwd,id:Number(o)}}),C(`已删除「${e}」`),b&&y&&b.doAction(ie.deleteTab(y)),T()})},nn=!j&&!!P&&P.status===`pending`,rn=e=>{nn&&J(async()=>{let n=F?.title||`#${o}`,r=A?{key:g}:{cwd:N?.cwd};if(e===`done`){let e=await Pe({title:`标为完成「${n}」`,message:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(e==null)return;await t(`/api/localtasks/items/close`,{method:`POST`,body:{...r,ids:[Number(o)],status:`done`,summary:String(e).trim()}}),C(`已标为完成 #${o}`)}else{if(!await Pe({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await t(`/api/localtasks/items/close`,{method:`POST`,body:{...r,ids:[Number(o)],status:`cancelled`}}),C(`已取消 #${o}`)}T()})},an=async(e,n={})=>{if(!F)return;let{items:r,imageInserts:i,fileInserts:a}=await ye(e),s=se(M)||F,c=s.body||``,l=i.join(``),u=c,d=null;if(l){let e=m(c,l,n);u=e.body,d=e.insertAt+l.length}a.length&&(u=m(u,a.join(``),{}).body);let f={};if(u!==c&&(f.body=u),r.length&&(f.attachments=[...s.attachments||[],...r]),Object.keys(f).length){if(_(M,f),n.mode===`edit`&&d!=null&&requestAnimationFrame(()=>{Tt.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(d,d)}catch{}}),!j){f.attachments&&ve(o,f.attachments);let e=Jt(s.title,f.body||u);_(M,{body:e,title:p(e)});try{await t(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:A?void 0:N?.cwd,key:A?g:void 0,id:Number(o),text:e}}),Ot(!1),T(),C(r.length?`已添加附件并同步(${r.length})`:`已同步附件`)}catch(e){Q(),C(`附件已插入,同步失败:${e.message||e}`)}return}Q()}},$=()=>{K(null),q.current=``},on=()=>{let e=me(),t=pe(fe(D?i:k),e),n={};W&&W.board&&W.board.id&&(n.board=W.board.id),H.project&&(n.project=H.project),_(t,{title:``,body:ne(Ie?Ie.defaultBody():``,n)}),S.openPage&&S.openPage(D?{groupId:i,task:e,name:`新任务`}:{dirKey:k,task:e,name:`新任务`})},sn=()=>{if(j||o==null||/^draft/i.test(String(o))){C(`草稿没有可克隆的队列任务`);return}J(async()=>{let e=await t(`/api/localtasks/clone`,{method:`POST`,body:A?{id:Number(o)}:{id:Number(o),cwd:N?.cwd}});C(`已克隆为新任务 #${e.task?.id??e.id}`),T();let n=e?.task?.id??e?.id;n!=null&&S.openPage&&(D?S.openPage({groupId:i,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(克隆)`}):S.openPage({dirKey:k,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(克隆)`}))})},cn=()=>{if(j||o==null||/^draft/i.test(String(o))){C(`草稿没有可 Fork 的队列任务`);return}J(async()=>{let e=await t(`/api/localtasks/fork`,{method:`POST`,body:A?{id:Number(o)}:{id:Number(o),cwd:N?.cwd}});C(`已 Fork 为新任务 #${e.task?.id??e.id}(保留任务链)`),T();let n=e?.task?.id??e?.id;n!=null&&S.openPage&&(D?S.openPage({groupId:i,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(Fork)`}):S.openPage({dirKey:k,task:String(n),name:`${(F?.title||`任务`).slice(0,30)}(Fork)`}))})},ln=()=>{let t=String(window.getSelection()||``).trim()||(G?.text?String(G.text):``);if(!t){C(`先划选一段再评论`);return}q.current=t;let n=b||S.model;n&&(be(n,{mode:`comment`,quote:t,taskLabel:o==null?``:`#`+o,taskTitle:String(F?.title||``).replace(/^#+\s*/,``),src:{dirKey:k||e||`__GLOBAL__`,task:String(o),name:`原文 #${o}`},onSubmit:e=>mt({...e,quote:t})}),$())},un=(e,t=`typing`)=>{if(!F)return;Ae(Et.current,M,{title:F.title,body:F.body},t),Q();let n={title:e};Ge!==`split`&&/^# (?!#)/m.test(F.body)&&(n.body=F.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),_(M,n)},dn=(e,t=`op`)=>{if(!F)return;Ae(Et.current,M,{title:F.title,body:F.body},t),Q();let n={body:e};Ge!==`split`&&(n.title=p(e)),_(M,n)},fn=()=>{if(!F)return;let e=ke(Et.current,M,{title:F.title,body:F.body});e&&(_(M,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>Tt.current?.caretFromDiff?.(F.body,e.body)))},pn=()=>{if(!F)return;let e=je(Et.current,M,{title:F.title,body:F.body});e&&(_(M,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>Tt.current?.caretFromDiff?.(F.body,e.body)))},mn=(e,t,n,r,i={})=>{q.current=t,K({kind:e,text:t,...i,x:Math.min(window.innerWidth-300,Math.max(8,n)),y:Math.min(window.innerHeight-240,Math.max(8,r))})},hn=e=>{if(!e?.text||e.text.length<1){K(null);return}q.current=e.text,K({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},gn=e=>{if(!F||Ge===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){K(null);return}if(!St.current?.contains(t.anchorNode)){K(null);return}let r=e=>e?.nodeType===3?e.parentElement:e,i=r(t.anchorNode)?.closest?.(`.mdw-lp-block`),a=r(t.focusNode)?.closest?.(`.mdw-lp-block`),o=null;if(i&&a&&i!==a&&St.current?.contains(a)){let e=Number(i.getAttribute(`data-i`)),t=Number(a.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(o=[Math.min(e,t),Math.max(e,t)])}let s=t.getRangeAt(0),c=s.getClientRects(),l=c.length?c[c.length-1]:s.getBoundingClientRect();mn(`task`,n,l.right-60,l.bottom+8,o?{blockRange:o}:{})},_n=e=>{bt.current.accept=e,bt.current?.click()};if((0,v.useEffect)(()=>{if(!U||s)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),Bt())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[U,s,Bt]),x!=null){let e={origin:`起点`,reopen:`反馈`,comment:`评论`}[X?.kind]||`节点`,t=X?te(X.text||``,X.attachments||[]):``;return(0,E.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,E.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,E.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,e,` #`,x]}),(0,E.jsx)(`span`,{className:`grow`}),(0,E.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:Ht,children:`×`})]}),(0,E.jsx)(`div`,{className:`mdw-hist-ro`,children:X?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,E.jsx)(`span`,{children:X.at||`—`}),X.quote?(0,E.jsxs)(`span`,{children:[`锚定:`,X.quote.slice(0,80)]}):null,X.feedback?(0,E.jsxs)(`span`,{children:[`反馈:`,X.feedback.slice(0,80)]}):null,X.summary?(0,E.jsxs)(`span`,{children:[`上轮总结:`,X.summary.slice(0,80)]}):null]}),(0,E.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:t||`<p class="muted">(空)</p>`}})]}):(0,E.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,x]})})]})}if(!F)return S.localReady===!1||j?(0,E.jsx)(`div`,{className:`mdw`,children:(0,E.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,E.jsx)(`div`,{className:`mdw`,children:(0,E.jsxs)(`div`,{className:`pad stack`,children:[(0,E.jsx)(`div`,{children:(0,E.jsxs)(`strong`,{children:[`找不到任务 #`,o]})}),(0,E.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,E.jsx)(`div`,{children:(0,E.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>S.onNavigate&&S.onNavigate(D?`#/group/`+encodeURIComponent(i||``):A?`#/global`:`#/dir/`+encodeURIComponent(e||``)),children:`回到目录`})})]})});let vn=(L.duration||``).trim(),yn=(L.prompt||``).trim(),bn=vn||yn?{label:`⏱ ${vn||`目标`}`,title:yn||(Je?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,声明不可改`)}:null,xn=Je||I?(0,E.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,E.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),Je?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`input`,{className:`mdw-goal-dur mono`,value:L.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:e=>{qe({...L,duration:e.target.value}),Q()}}),(0,E.jsx)(`input`,{className:`mdw-goal-prompt`,value:L.prompt,placeholder:`附加要求(可选,随 check 指令一起固化)`,onChange:e=>{qe({...L,prompt:e.target.value}),Q()}})]}):(0,E.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:I?.prompt||`已领取计时,声明不可改`,children:[I?.duration||`—`,` · 已领取计时`]}),I&&o!=null?(0,E.jsx)(`button`,{type:`button`,className:`ghost`,onClick:ct,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null;return(0,E.jsxs)(`div`,{className:`mdw${s?` is-beside`:``}`,"data-mode":Ge,onMouseUp:gn,children:[Fe,Yt&&(0,E.jsx)(He,{state:Yt,onClose:()=>Xt(null)}),(0,E.jsx)(Ve,{open:_t,nodes:Wt,onOpenNode:Vt,onClose:()=>vt(!1)}),s&&(0,E.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,E.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,E.jsx)(`span`,{className:`grow`}),(0,E.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:Ht,children:`×`})]}),(0,E.jsxs)(`div`,{className:`mdw-main`,children:[(0,E.jsxs)(`div`,{className:`mdw-top`,children:[(0,E.jsx)(Se,{}),(0,E.jsxs)(`div`,{className:`mdw-head`,children:[(0,E.jsx)(`div`,{className:`mdw-title`,children:j?F.title||`新 MD 任务`:F.title||`任务`}),(0,E.jsxs)(`div`,{className:`mdw-path`,children:[A?`全局任务池`:N?.cwd||N?.name||`—`,j?` / (${o})`:` / #${o}`,Dt?` · 未保存`:``]})]})]}),W&&(0,E.jsxs)(`div`,{className:`mdw-goal`,children:[(0,E.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),Je?(0,E.jsx)(`select`,{className:`mdw-proj-pick`,value:H.project||``,onChange:e=>{_(M,{body:ne(F.body,{...H,board:W.board.id,project:e.target.value})}),Q()},children:W.members.map(e=>(0,E.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,E.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(W.members.find(e=>e.key===H.project)||{}).name||H.project||`—`})]}),(0,E.jsx)(De,{mode:Ge,onMode:e=>_(M,{mode:e}),showMark:Ge!==`edit`,submitLabel:j?`提交为任务`:`保存并同步`,onNew:on,onSubmit:$t,onChain:j?null:()=>vt(!0),onPreview:Zt,onImg:()=>_n(`image/*`),onAtt:()=>j?_n(`image/*,.pdf,.zip,.txt,.json,.csv`):ut(),onImport:()=>yt.current?.click(),onClone:j?null:sn,onFork:j?null:cn,onComplete:nn?()=>rn(`done`):null,onCancelTask:nn?()=>rn(`cancel`):null,onMark:ln,onDraft:()=>C(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:j?null:tn,onOverview:()=>S.onNavigate&&S.onNavigate(`#/overview`),onProg:zt,onSource:U?Bt:null,onShortcuts:()=>gt(!0),goalBadge:bn,goalMenu:xn}),(0,E.jsx)(ge,{ref:St,mode:Ge,title:F.title,body:F.body,previewHtml:Pt,onTitle:un,onBody:dn,attachments:F.attachments,docKey:M,editorApiRef:Tt,onFiles:an,onTextSel:hn,onSave:$t,onUndo:fn,onRedo:pn,onCloseSelMenu:$,attachHost:j?null:{host:`task`,hostId:Number(o),hostKey:A?g:void 0,hostCwd:A?void 0:N?.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(N.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),z&&(0,E.jsxs)(`div`,{className:`mdw-dock`,ref:rt,style:{height:`${et}px`},children:[(0,E.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:st,onDoubleClick:lt}),(0,E.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,E.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,E.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":B===`attach`,className:`mdw-dock-tab${B===`attach`?` is-on`:``}`,onClick:()=>V(`attach`),children:`附件`}),Ye?(0,E.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":B===`check`,className:`mdw-dock-tab${B===`check`?` is-on`:``}`,onClick:ct,children:[`check`,(0,E.jsx)(`span`,{className:`mdw-dock-tab-num`,children:R.data?.count??0})]}):null,(0,E.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":B===`feedback`,className:`mdw-dock-tab${B===`feedback`?` is-on`:``}`,onClick:()=>V(`feedback`),children:`反馈`})]}),(0,E.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,E.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:lt,title:it?`还原面板高度`:`最大化面板高度`,"aria-label":it?`还原面板高度`:`最大化面板高度`,children:(0,E.jsx)(a,{name:it?`collapse`:`expand`})}),(0,E.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>Qe(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,E.jsx)(a,{name:`x`})})]})]}),(0,E.jsxs)(`div`,{className:`mdw-dock-body`,children:[B===`attach`?j?(0,E.jsx)(xe,{attachments:F.attachments,onRemove:e=>{let t=(F.attachments||[]).filter(t=>t.id!==e);Q(),_(M,{attachments:t}),j||ve(o,t)}}):N?(0,E.jsx)(Oe,{ref:xt,host:`task`,hostId:Number(o),hostKey:A?`__GLOBAL__`:void 0,hostCwd:A?void 0:N.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(N.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:T,onOpenTask:e=>{S.openPage&&e&&e.seq!=null&&S.openPage({dirKey:e.key||k,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=he(e);b&&t&&ae(b,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,B===`check`?(0,E.jsxs)(`div`,{className:`mdw-dock-check`,children:[R.busy&&!R.data?(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,R.error?(0,E.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,R.error]}):null,R.data?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${R.data.duration||`—`}`,R.data.startedAt?` · 开始 ${R.data.startedAt}`:``,R.data.deadline?` · 截止 ${R.data.deadline}`:` · 尚未开始计时`,R.data.archived?` · 已归档`:``,` · ${R.data.count||0} 轮`]}),(R.data.count||0)>0?(0,E.jsx)(`div`,{className:`mdw-goal-log`,children:R.data.entries.map((e,t)=>(0,E.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,E.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,Ue(e.elapsedSec),` · 剩余 `,Ue(e.remainingSec)]}),e.summary?(0,E.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,E.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,B===`feedback`?!j&&P?.completedAt?(0,E.jsxs)(`div`,{className:`mdw-review`,ref:Ct,children:[(0,E.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,E.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,E.jsx)(`span`,{className:`mdw-review-at mono`,children:P.completedAt}),P.roundSummary?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{ref:wt,className:`mdw-review-sum${kt?` is-open`:``}`,title:kt||!(jt||Nt)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:Ft}}),(jt||Nt||kt)&&(0,E.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>At(e=>!e),children:kt?`收起`:`展开全文`})]}):null]}),(0,E.jsx)(`div`,{className:`mdw-review-acts`,children:Kt?(0,E.jsx)(`button`,{type:`button`,className:`ghost`,onClick:dt,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),Z?(0,E.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:qt,title:`到最新一轮 #${Z.id} 反馈`,children:[`去最新一轮 #`,Z.id]}):null]})})]}):(0,E.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]}),(0,E.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${z&&B===`attach`?` is-on`:``}`,onClick:()=>V(`attach`),title:`附件(点击展开信息面板)`,children:[(0,E.jsx)(a,{name:`list`}),(0,E.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),Ye?(0,E.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${z&&B===`check`?` is-on`:``}`,onClick:ct,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,E.jsx)(a,{name:`clock`}),(0,E.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,E.jsx)(`span`,{className:`mdw-sbar-num`,children:R.data?.count??0})]}):null,(0,E.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${z&&B===`feedback`?` is-on`:``}`,onClick:()=>V(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,E.jsx)(a,{name:`edit`}),(0,E.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,E.jsx)(`span`,{className:`mdw-sbar-grow`}),!j&&P?(0,E.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,E.jsx)(_e,{t:P})}):null,(0,E.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${z?` is-open`:``}`,onClick:()=>Qe(e=>!e),title:z?`收起信息面板`:`展开信息面板`,"aria-expanded":z,"aria-label":z?`收起信息面板`:`展开信息面板`,children:(0,E.jsx)(a,{name:`chevron`})})]})]}),(0,E.jsx)(Le,{nodes:It,scrollRoot:Lt}),(0,E.jsx)(Re,{at:G,onFormat:e=>{Tt.current?.format?.(e),$()},onCompose:()=>{let t=b||S.model;if(!t)return;let n=String(G?.text||q.current||``);be(t,{mode:`comment`,quote:n,taskLabel:o==null?``:`#`+o,taskTitle:String(F?.title||``).replace(/^#+\s*/,``),src:{dirKey:k||e||`__GLOBAL__`,task:String(o),name:`原文 #${o}`},onSubmit:e=>mt({...e,quote:n})}),$()},onCopy:()=>{let e=G?.blockRange,t=``;if(e&&F){let n=l(F.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
|
|
10
10
|
|
|
11
|
-
`))}navigator.clipboard?.writeText(t||q.current||G?.text||``),C(`已复制`),$()},onDelete:G?.blockRange?()=>{let e=G.blockRange;Tt.current?.deleteBlockRange?.(e[0],e[1])?C(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):C(`选区已失效`),$()}:null}),(0,E.jsx)(`input`,{ref:bt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=e.target.files;e.target.value=``,t
|
|
11
|
+
`))}navigator.clipboard?.writeText(t||q.current||G?.text||``),C(`已复制`),$()},onDelete:G?.blockRange?()=>{let e=G.blockRange;Tt.current?.deleteBlockRange?.(e[0],e[1])?C(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):C(`选区已失效`),$()}:null}),(0,E.jsx)(`input`,{ref:bt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&an(t)}}),(0,E.jsx)(`input`,{ref:yt,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&en(t)}}),ht&&(0,E.jsx)(ze,{onClose:()=>gt(!1)})]})}function He({state:e,onClose:t}){let n=r(),a=e?.data,o=async()=>{try{await navigator.clipboard.writeText(String(a?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},s=a?.switches||{},c=a?[`ack ${s.ack?.on?`开(${s.ack.count} 条)`:`关`}`,`交付上下文 ${s.deliveryTemplate?.custom?`自定义`:`内置默认`}`,`持续 get ${a.getLoop?.enabled?`开(${a.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,l=a?`预览:agent 执行 get 会收到的提示词${a.task?.id?` · #${a.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,E.jsxs)(i,{title:l,size:`wide`,onClose:t,footer:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,E.jsx)(`span`,{className:`grow`}),(0,E.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:o,disabled:!a,children:`复制原文`}),(0,E.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,E.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,E.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,E.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),a&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`pre`,{className:`mdw-prev-body`,children:a.rendered||``}),a.segments?.length?(0,E.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,E.jsxs)(`summary`,{children:[`段落来源(`,a.segments.length,` 段)`]}),(0,E.jsx)(`ol`,{children:a.segments.map((e,t)=>(0,E.jsxs)(`li`,{children:[(0,E.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,E.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,E.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,E.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,E.jsx)(`div`,{className:`mdw-prev-switch`,children:c})]})]})}function Ue(e){let t=Math.max(0,Number(e)||0);return t>=3600?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,g as t,v as n,y as r}from"./task-status-BP6y8MVu.js";import{u as i}from"./md-parse-C2bDc3IZ.js";import{D as a,M as o,i as s,k as c,t as l}from"./index-
|
|
1
|
+
import{S as e,g as t,v as n,y as r}from"./task-status-BP6y8MVu.js";import{u as i}from"./md-parse-C2bDc3IZ.js";import{D as a,M as o,i as s,k as c,t as l}from"./index-BmANFdAR.js";import{t as u}from"./md-panes-sRhT7DNc.js";import{t as d}from"./route-crumb-DHYbpsO8.js";import{i as f,n as p,r as m,t as h}from"./md-history-Uo6U7hYS.js";var g=e(r(),1),_=n(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:n,initialBody:r,isNew:a,onSave:o,onClose:s,busy:c}){let l=t(),[y,b]=(0,g.useState)(n||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(a?`new`:e),A=(0,g.useMemo)(()=>i(x||``),[x]),j=(e,t,n=`typing`)=>{p(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=f(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=m(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){l(`模板名不能为空(标题即名称)`);return}await o({name:y.trim(),body:x}),h(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(d,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:a?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:c,onClick:s,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:c||!T,onClick:I,children:a?`创建`:`保存`})]})]}),(0,_.jsx)(u,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:n,tabId:r}){let i=c()||{},u=i.tpl,f=t(),[p,m]=(0,g.useState)(!1),h=e||{},v=(h.mode||(h.id?`edit`:``))===`new`,b=h.id||``,x=()=>{let e=l();if(e&&i.onNavigate){i.onNavigate(e);return}if(i.onNavigate){i.onNavigate(`#/overview`);return}if(n&&r)try{n.doAction(o.deleteTab(r))}catch{}};if(!u)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(d,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(d,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{n&&a(n,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(u.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(d,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{m(!0);try{if(v){let n={};Array.isArray(h.scope)&&(n.scope=h.scope),h.topic&&(n.topic=h.topic),await u.add(e,t,!1,n),f(`已创建模板`)}else await u.update(b,{name:e,body:t}),f(`已保存模板`);x()}catch(e){f(String(e.message||e))}finally{m(!1)}},w=v?h.name||``:S.name,T=v?``:s(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:p,onSave:C,onClose:x},v?`new:${h.topic||``}:${(h.scope||[]).join(`,`)}`:b)}export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,g as t,l as n,v as r,y as i}from"./task-status-BP6y8MVu.js";import{N as a}from"./index-B_HPAoNR.js";import{a as o,c as s,i as c,n as l,r as u,s as d}from"./md-panes-BvQXV_C9.js";import{n as f,o as p}from"./upload-L1g-pfvZ.js";var m=e(i(),1),h=r(),g={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function _({host:e=`task`,hostId:r,hostKey:i,hostCwd:a,refId:o,allow:c={file:!0,url:!0,task:!1,ref:!1},taskOptions:_=[],docOptions:y,disabled:b=!1,disabledText:x=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:S,onChanged:C,onOpenTask:w,onOpenDoc:T}){let E=t(),[D,O]=(0,m.useState)([]),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(``),[N,P]=(0,m.useState)(!1),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(!1),[z,B]=(0,m.useState)(`position`),[V,H]=(0,m.useState)(null),[U,W]=(0,m.useState)(!1),[G,K]=(0,m.useState)(null),q=(0,m.useMemo)(()=>d(e,{hostId:r,hostKey:i,hostCwd:a,refId:o}),[e,r,i,a,o]),J=(0,m.useCallback)(async()=>{if(b){O([]);return}A(!0),M(``);try{let e=await q.list();O((e.attachments||[]).map(s))}catch(e){M(String(e&&e.message||e))}finally{A(!1)}},[q,b]);(0,m.useEffect)(()=>{J()},[J]),(0,m.useImperativeHandle)(S,()=>({open:()=>P(!0),refresh:J}),[J]),(0,m.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Y=(0,m.useMemo)(()=>[...D].sort(g[z]||g.position),[D,z]),X=Y.filter(e=>e.area===`inline`),Z=Y.filter(e=>e.area===`area`),Q=async(e,t)=>{if(b)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;R(!0);let i=0;for(let e of r)try{let t=await p(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await q.attach({fileId:n,name:t.name}),i+=1}catch(t){E(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}R(!1),i&&(E(`已挂到附件区 ${i} 个文件`),await J(),C?.())},$=async e=>{let t=V;if(t){W(!0);try{await q.detach(t.id,!!e),H(null),E(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await J(),C?.()}catch(e){E(`移除失败:${e&&e.message||e}`)}finally{W(!1)}}},ee=!k&&!j&&!D.length;return(0,h.jsxs)(`div`,{className:`att-area${b?` is-disabled`:``}`,onDragOver:e=>{!b&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!b&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),Q(null,e))},children:[(0,h.jsxs)(`div`,{className:`att-area-head`+(F&&!b?` is-over`:``),children:[(0,h.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,D.length?(0,h.jsx)(`span`,{className:`att-count`,children:D.length}):null,L?(0,h.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,h.jsxs)(`span`,{className:`att-area-acts`,children:[D.length?(0,h.jsxs)(`select`,{className:`att-sort`,value:z,onChange:e=>B(e.target.value),"aria-label":`附件排序`,children:[(0,h.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,h.jsx)(`option`,{value:`name`,children:`按名称`}),(0,h.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,h.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:b,onClick:()=>P(!0),children:`添加附件`})]})]}),b?(0,h.jsx)(`div`,{className:`att-empty`,children:x}):null,k?(0,h.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,j?(0,h.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,j]}):null,ee?(0,h.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,X.length?(0,h.jsxs)(`div`,{className:`att-section`,children:[(0,h.jsxs)(`div`,{className:`att-section-head`,children:[u.inline,(0,h.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),X.map(e=>v(e,{onRemove:H,onPreview:K,onOpenTask:w,onOpenDoc:T,key:e.id}))]}):null,Z.length?(0,h.jsxs)(`div`,{className:`att-section`,children:[(0,h.jsxs)(`div`,{className:`att-section-head`,children:[u.area,(0,h.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),Z.map(e=>v(e,{onRemove:H,onPreview:K,onOpenTask:w,onOpenDoc:T,key:e.id}))]}):null,(0,h.jsx)(l,{open:N,host:e,hostId:r,hostKey:i,hostCwd:a,refId:o,allow:c,taskOptions:_,docOptions:y,onClose:()=>P(!1),onDone:async()=>{await J(),C?.()}}),V?(0,h.jsx)(n,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>H(null),footer:(0,h.jsxs)(`div`,{className:`att-foot`,children:[(0,h.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>H(null),children:`取消`}),(0,h.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>$(!1),children:`只解除关联`}),(0,h.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:U,onClick:()=>$(!0),children:V.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,h.jsxs)(`div`,{className:`att-confirm`,children:[(0,h.jsx)(`div`,{className:`att-confirm-name`,children:V.name}),(0,h.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,G?(0,h.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,h.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,h.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,h.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,h.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,h.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,h.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function v(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i}){let a=e.kind===`image`?o(e.id):``;return(0,h.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,h.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:a,name:e.name}),title:`点击看大图`,children:(0,h.jsx)(`img`,{src:a,alt:e.name,loading:`lazy`})}):(0,h.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,h.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,h.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,h.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,h.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,h.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,h.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,h.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,h.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,h.jsxs)(`span`,{className:`att-item-acts`,children:[(0,h.jsx)(`a`,{className:`att-act`,href:o(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,h.jsx)(`a`,{className:`att-act`,href:o(e.id),download:e.name,children:`下载`})]}):null,(0,h.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var y=a(),b=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`tpl`,label:`模板`,section:`bar`},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],x=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`refs`,label:`查看列表`,section:`more`}],S=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],C=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],w=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],T=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],E={dir:Object.fromEntries(b.map(e=>[e.id,e])),group:Object.fromEntries(x.map(e=>[e.id,e])),task:Object.fromEntries(S.map(e=>[e.id,e])),doc:Object.fromEntries(C.map(e=>[e.id,e])),repos:Object.fromEntries(w.map(e=>[e.id,e])),"repos-row":Object.fromEntries(T.map(e=>[e.id,e]))};function D(e){return e===`group`?x:e===`task`?S:e===`doc`?C:e===`repos`?w:e===`repos-row`?T:b}function O(e,t){return E[e]&&E[e][t]||{}}function k(e,t){let n=O(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function A(e,t){return O(e,t.id).noHide?!0:t.visible===void 0?!k(e,t.id):t.visible!==!1}function j(e,t){return t.id===`more`||O(e,t.id).noHide?!1:!A(e,t)}function M(e,t){let n=D(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=O(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!k(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(k(e,a[t].id)&&!A(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function N(e){return M(e,D(e).map(t=>({id:t.id,visible:t.noHide?!0:!k(e,t.id)})))}var P=e=>`nx-kv-tb-${e}`;function F(e){let[t,n]=(0,m.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(P(e)));if(Array.isArray(t))return M(e,t)}catch{}return N(e)});return(0,m.useEffect)(()=>{try{localStorage.setItem(P(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(N(e))}}function I(e,t){return!!O(e,t).lockLast}function L(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function R(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||I(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=O(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>I(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function z(e,t,n,r){let i=t.filter(t=>A(e,t)&&!I(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return R(e,t,{id:n,anchorId:s.id,after:r>0})}function B({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,m.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(null),u=(0,m.useRef)(null),d=i.filter(t=>A(e,t)),f=i.filter(t=>j(e,t)),p=d.filter(t=>!I(e,t.id)),g=()=>{let t=u.current;return t&&!I(e,t.id)?t:null},_=(t,n)=>{I(e,n.id)||(u.current={id:n.id,onBar:A(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>R(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=g();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=g();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=g();n&&!O(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=g();v(),n&&!O(e,n.id).noHide&&a(e=>L(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},k=(e,t)=>{let n=g();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},M=(e,t)=>{let n=D(t);t.preventDefault();let r=g();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},P=t=>{O(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return L(n,t,{visible:!(r&&A(e,r))})})},F=(t,n)=>a(r=>z(e,r,t.id,n)),B=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),F(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),F(e,1)))},V=()=>{n(i),r()},H=()=>a(N(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,I(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,h.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,h.jsxs)(`div`,{className:`tlp-head`,children:[(0,h.jsx)(`b`,{children:`自定义工具栏`}),(0,h.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,h.jsxs)(`div`,{className:`tlp-body`,children:[(0,h.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,h.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,h.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,h.jsx)(`span`,{className:[`tlp-chip`,O(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!I(e,t.id),role:`listitem`,onDragStart:e=>_(e,t),onDragEnd:v,onDragOver:e=>k(t,e),onDrop:e=>M(t,e),children:O(e,t.id).label||t.id},t.id)})})]}),(0,h.jsxs)(`div`,{className:`tlp-section`,children:[(0,h.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,h.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>I(e,t.id))?(0,h.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=O(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,h.jsxs)(`div`,{className:U(t,!0),draggable:!I(e,t.id),"data-row-id":t.id,tabIndex:I(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>B(t,e),onDragStart:e=>_(e,t),onDragEnd:v,children:[(0,h.jsx)(`span`,{className:`tlp-hnd`,title:I(e,t.id)?`锁定`:`拖动排序`,children:I(e,t.id)?`·`:`⋮⋮`}),(0,h.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>P(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,h.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,h.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),I(e,t.id)?null:(0,h.jsxs)(`span`,{className:`tlp-acts`,children:[(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>F(t,-1),children:`↑`}),(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>F(t,1),children:`↓`})]})]},t.id)})]})]}),(0,h.jsxs)(`div`,{className:`tlp-section`,children:[(0,h.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,h.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=O(e,t.id);return(0,h.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>_(e,t),onDragEnd:v,children:[(0,h.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,h.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>P(t.id),title:`显示到工具栏`}),(0,h.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,h.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,h.jsxs)(`div`,{className:`tlp-foot`,children:[(0,h.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,h.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:V,children:`保存`})]})]})}var V=`task`,H=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function U(){let[e,t]=(0,m.useState)(!1),[n,r]=(0,m.useState)({x:0,y:0}),i=(0,m.useRef)(null),a=(0,m.useRef)(null);return(0,m.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 W({menu:e,className:t=``,style:n,children:r}){return e.open?(0,y.createPortal)((0,h.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 G(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 K({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:g,onMark:_,onDraft:v,onDelete:b,onOverview:x,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=U(),{layout:k,setLayout:M}=F(V),[N,P]=(0,m.useState)(!1);(0,m.useEffect)(()=>{D.setOpen(!1)},[e]);let I={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":g&&{label:`取消任务`,run:g,danger:!0},mark:n&&_&&{label:`评论`,run:_},delete:b&&{label:`删除`,run:b,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:x&&{label:`总览`,run:x},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},L=e=>e===`more`||!!I[e],R=k.filter(e=>A(V,e)&&L(e.id)),z=k.filter(e=>j(V,e)&&L(e.id)),K=e=>{I[e]?.run?.(),D.setOpen(!1)},q=e=>{if(e===`more`)return(0,h.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>G(D,e,`right`),children:`更多`})},`more`);let t=I[e];return t?(0,h.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>K(e),children:t.label},e):null},J=H.map(e=>({...e,items:z.filter(t=>O(V,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!O(V,e.id).menuGroup);return(0,h.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,h.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,h.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>G(D,e,`right`),children:T.label})}),(0,h.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>q(e.id)),(0,h.jsxs)(W,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,h.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,h.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,h.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=I[e.id],n=t?.danger||O(V,e.id).danger;return(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>K(e.id),children:[t?.label||O(V,e.id).label||e.id,t?.hint?(0,h.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=I[e.id];return(0,h.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||O(V,e.id).danger?` danger`:``),onClick:()=>K(e.id),children:t?.label||O(V,e.id).label||e.id},e.id)}),(0,h.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,h.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),N&&(0,y.createPortal)((0,h.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,h.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,h.jsx)(B,{kind:V,layout:k,setLayout:M,onClose:()=>P(!1)})})}),document.body)]})}export{B as a,O as c,U as i,A as l,K as n,F as o,G as r,j as s,W as t,_ as u};
|
|
1
|
+
import{S as e,g as t,l as n,v as r,y as i}from"./task-status-BP6y8MVu.js";import{N as a}from"./index-BmANFdAR.js";import{a as o,c as s,i as c,n as l,r as u,s as d}from"./md-panes-sRhT7DNc.js";import{n as f,o as p}from"./upload-L1g-pfvZ.js";var m=e(i(),1),h=r(),g={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function _({host:e=`task`,hostId:r,hostKey:i,hostCwd:a,refId:o,allow:c={file:!0,url:!0,task:!1,ref:!1},taskOptions:_=[],docOptions:y,disabled:b=!1,disabledText:x=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:S,onChanged:C,onOpenTask:w,onOpenDoc:T}){let E=t(),[D,O]=(0,m.useState)([]),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(``),[N,P]=(0,m.useState)(!1),[F,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(!1),[z,B]=(0,m.useState)(`position`),[V,H]=(0,m.useState)(null),[U,W]=(0,m.useState)(!1),[G,K]=(0,m.useState)(null),q=(0,m.useMemo)(()=>d(e,{hostId:r,hostKey:i,hostCwd:a,refId:o}),[e,r,i,a,o]),J=(0,m.useCallback)(async()=>{if(b){O([]);return}A(!0),M(``);try{let e=await q.list();O((e.attachments||[]).map(s))}catch(e){M(String(e&&e.message||e))}finally{A(!1)}},[q,b]);(0,m.useEffect)(()=>{J()},[J]),(0,m.useImperativeHandle)(S,()=>({open:()=>P(!0),refresh:J}),[J]),(0,m.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Y=(0,m.useMemo)(()=>[...D].sort(g[z]||g.position),[D,z]),X=Y.filter(e=>e.area===`inline`),Z=Y.filter(e=>e.area===`area`),Q=async(e,t)=>{if(b)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;R(!0);let i=0;for(let e of r)try{let t=await p(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await q.attach({fileId:n,name:t.name}),i+=1}catch(t){E(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}R(!1),i&&(E(`已挂到附件区 ${i} 个文件`),await J(),C?.())},$=async e=>{let t=V;if(t){W(!0);try{await q.detach(t.id,!!e),H(null),E(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await J(),C?.()}catch(e){E(`移除失败:${e&&e.message||e}`)}finally{W(!1)}}},ee=!k&&!j&&!D.length;return(0,h.jsxs)(`div`,{className:`att-area${b?` is-disabled`:``}`,onDragOver:e=>{!b&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!b&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),Q(null,e))},children:[(0,h.jsxs)(`div`,{className:`att-area-head`+(F&&!b?` is-over`:``),children:[(0,h.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,D.length?(0,h.jsx)(`span`,{className:`att-count`,children:D.length}):null,L?(0,h.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,h.jsxs)(`span`,{className:`att-area-acts`,children:[D.length?(0,h.jsxs)(`select`,{className:`att-sort`,value:z,onChange:e=>B(e.target.value),"aria-label":`附件排序`,children:[(0,h.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,h.jsx)(`option`,{value:`name`,children:`按名称`}),(0,h.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,h.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:b,onClick:()=>P(!0),children:`添加附件`})]})]}),b?(0,h.jsx)(`div`,{className:`att-empty`,children:x}):null,k?(0,h.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,j?(0,h.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,j]}):null,ee?(0,h.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,X.length?(0,h.jsxs)(`div`,{className:`att-section`,children:[(0,h.jsxs)(`div`,{className:`att-section-head`,children:[u.inline,(0,h.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),X.map(e=>v(e,{onRemove:H,onPreview:K,onOpenTask:w,onOpenDoc:T,key:e.id}))]}):null,Z.length?(0,h.jsxs)(`div`,{className:`att-section`,children:[(0,h.jsxs)(`div`,{className:`att-section-head`,children:[u.area,(0,h.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),Z.map(e=>v(e,{onRemove:H,onPreview:K,onOpenTask:w,onOpenDoc:T,key:e.id}))]}):null,(0,h.jsx)(l,{open:N,host:e,hostId:r,hostKey:i,hostCwd:a,refId:o,allow:c,taskOptions:_,docOptions:y,onClose:()=>P(!1),onDone:async()=>{await J(),C?.()}}),V?(0,h.jsx)(n,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>H(null),footer:(0,h.jsxs)(`div`,{className:`att-foot`,children:[(0,h.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>H(null),children:`取消`}),(0,h.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>$(!1),children:`只解除关联`}),(0,h.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:U,onClick:()=>$(!0),children:V.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,h.jsxs)(`div`,{className:`att-confirm`,children:[(0,h.jsx)(`div`,{className:`att-confirm-name`,children:V.name}),(0,h.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,G?(0,h.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,h.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,h.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,h.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,h.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,h.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,h.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function v(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i}){let a=e.kind===`image`?o(e.id):``;return(0,h.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,h.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:a,name:e.name}),title:`点击看大图`,children:(0,h.jsx)(`img`,{src:a,alt:e.name,loading:`lazy`})}):(0,h.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,h.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,h.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,h.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,h.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,h.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,h.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,h.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,h.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,h.jsxs)(`span`,{className:`att-item-acts`,children:[(0,h.jsx)(`a`,{className:`att-act`,href:o(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,h.jsx)(`a`,{className:`att-act`,href:o(e.id),download:e.name,children:`下载`})]}):null,(0,h.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var y=a(),b=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`tpl`,label:`模板`,section:`bar`},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],x=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`refs`,label:`查看列表`,section:`more`}],S=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],C=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],w=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],T=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],E={dir:Object.fromEntries(b.map(e=>[e.id,e])),group:Object.fromEntries(x.map(e=>[e.id,e])),task:Object.fromEntries(S.map(e=>[e.id,e])),doc:Object.fromEntries(C.map(e=>[e.id,e])),repos:Object.fromEntries(w.map(e=>[e.id,e])),"repos-row":Object.fromEntries(T.map(e=>[e.id,e]))};function D(e){return e===`group`?x:e===`task`?S:e===`doc`?C:e===`repos`?w:e===`repos-row`?T:b}function O(e,t){return E[e]&&E[e][t]||{}}function k(e,t){let n=O(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function A(e,t){return O(e,t.id).noHide?!0:t.visible===void 0?!k(e,t.id):t.visible!==!1}function j(e,t){return t.id===`more`||O(e,t.id).noHide?!1:!A(e,t)}function M(e,t){let n=D(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=O(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!k(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(k(e,a[t].id)&&!A(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function N(e){return M(e,D(e).map(t=>({id:t.id,visible:t.noHide?!0:!k(e,t.id)})))}var P=e=>`nx-kv-tb-${e}`;function F(e){let[t,n]=(0,m.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(P(e)));if(Array.isArray(t))return M(e,t)}catch{}return N(e)});return(0,m.useEffect)(()=>{try{localStorage.setItem(P(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(N(e))}}function I(e,t){return!!O(e,t).lockLast}function L(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function R(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||I(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=O(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>I(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function z(e,t,n,r){let i=t.filter(t=>A(e,t)&&!I(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return R(e,t,{id:n,anchorId:s.id,after:r>0})}function B({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,m.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(null),u=(0,m.useRef)(null),d=i.filter(t=>A(e,t)),f=i.filter(t=>j(e,t)),p=d.filter(t=>!I(e,t.id)),g=()=>{let t=u.current;return t&&!I(e,t.id)?t:null},_=(t,n)=>{I(e,n.id)||(u.current={id:n.id,onBar:A(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>R(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=g();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=g();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=g();n&&!O(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=g();v(),n&&!O(e,n.id).noHide&&a(e=>L(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},k=(e,t)=>{let n=g();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},M=(e,t)=>{let n=D(t);t.preventDefault();let r=g();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},P=t=>{O(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return L(n,t,{visible:!(r&&A(e,r))})})},F=(t,n)=>a(r=>z(e,r,t.id,n)),B=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),F(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),F(e,1)))},V=()=>{n(i),r()},H=()=>a(N(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,I(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,h.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,h.jsxs)(`div`,{className:`tlp-head`,children:[(0,h.jsx)(`b`,{children:`自定义工具栏`}),(0,h.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,h.jsxs)(`div`,{className:`tlp-body`,children:[(0,h.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,h.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,h.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,h.jsx)(`span`,{className:[`tlp-chip`,O(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!I(e,t.id),role:`listitem`,onDragStart:e=>_(e,t),onDragEnd:v,onDragOver:e=>k(t,e),onDrop:e=>M(t,e),children:O(e,t.id).label||t.id},t.id)})})]}),(0,h.jsxs)(`div`,{className:`tlp-section`,children:[(0,h.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,h.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>I(e,t.id))?(0,h.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=O(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,h.jsxs)(`div`,{className:U(t,!0),draggable:!I(e,t.id),"data-row-id":t.id,tabIndex:I(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>B(t,e),onDragStart:e=>_(e,t),onDragEnd:v,children:[(0,h.jsx)(`span`,{className:`tlp-hnd`,title:I(e,t.id)?`锁定`:`拖动排序`,children:I(e,t.id)?`·`:`⋮⋮`}),(0,h.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>P(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,h.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,h.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),I(e,t.id)?null:(0,h.jsxs)(`span`,{className:`tlp-acts`,children:[(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>F(t,-1),children:`↑`}),(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>F(t,1),children:`↓`})]})]},t.id)})]})]}),(0,h.jsxs)(`div`,{className:`tlp-section`,children:[(0,h.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,h.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=O(e,t.id);return(0,h.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>_(e,t),onDragEnd:v,children:[(0,h.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,h.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>P(t.id),title:`显示到工具栏`}),(0,h.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,h.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,h.jsxs)(`div`,{className:`tlp-foot`,children:[(0,h.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,h.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:V,children:`保存`})]})]})}var V=`task`,H=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function U(){let[e,t]=(0,m.useState)(!1),[n,r]=(0,m.useState)({x:0,y:0}),i=(0,m.useRef)(null),a=(0,m.useRef)(null);return(0,m.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 W({menu:e,className:t=``,style:n,children:r}){return e.open?(0,y.createPortal)((0,h.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 G(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 K({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:g,onMark:_,onDraft:v,onDelete:b,onOverview:x,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=U(),{layout:k,setLayout:M}=F(V),[N,P]=(0,m.useState)(!1);(0,m.useEffect)(()=>{D.setOpen(!1)},[e]);let I={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":g&&{label:`取消任务`,run:g,danger:!0},mark:n&&_&&{label:`评论`,run:_},delete:b&&{label:`删除`,run:b,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:x&&{label:`总览`,run:x},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},L=e=>e===`more`||!!I[e],R=k.filter(e=>A(V,e)&&L(e.id)),z=k.filter(e=>j(V,e)&&L(e.id)),K=e=>{I[e]?.run?.(),D.setOpen(!1)},q=e=>{if(e===`more`)return(0,h.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,h.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>G(D,e,`right`),children:`更多`})},`more`);let t=I[e];return t?(0,h.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>K(e),children:t.label},e):null},J=H.map(e=>({...e,items:z.filter(t=>O(V,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!O(V,e.id).menuGroup);return(0,h.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,h.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,h.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>G(D,e,`right`),children:T.label})}),(0,h.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>q(e.id)),(0,h.jsxs)(W,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,h.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,h.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,h.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=I[e.id],n=t?.danger||O(V,e.id).danger;return(0,h.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>K(e.id),children:[t?.label||O(V,e.id).label||e.id,t?.hint?(0,h.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=I[e.id];return(0,h.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||O(V,e.id).danger?` danger`:``),onClick:()=>K(e.id),children:t?.label||O(V,e.id).label||e.id},e.id)}),(0,h.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,h.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),N&&(0,y.createPortal)((0,h.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,h.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,h.jsx)(B,{kind:V,layout:k,setLayout:M,onClose:()=>P(!1)})})}),document.body)]})}export{B as a,O as c,U as i,A as l,K as n,F as o,G as r,j as s,W as t,_ as u};
|
|
@@ -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-BmANFdAR.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/task-status-BP6y8MVu.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/md-parse-C2bDc3IZ.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/board-view-t8CKtq17.js">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{O as e,w as t}from"./index-B_HPAoNR.js";import{a as n}from"./upload-L1g-pfvZ.js";var r=`nx-kv-md-attachments-v1`;function i(){try{return JSON.parse(localStorage.getItem(r)||`{}`)||{}}catch{return{}}}function a(e){try{localStorage.setItem(r,JSON.stringify(e))}catch{}}function o(e,t){let n=i();n[e]=t,a(n)}function s(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function c(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function l(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:s(r.size)};i&&(a.url=await c(r),n.push(`\n\n`)),t.push(a)}return{items:t,imageInserts:n,fileInserts:[]}}async function u(e,t={}){let r=[...e||[]];if(!r.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await n(r,{...t.group?{group:t.group}:{},local:!0}),i=[],a=[],o=[];for(let t of e){let e=t.fileId||t.id,n=!!t.isImage;i.push({id:e,name:t.name,type:n?`image`:`file`,size:s(Number(t.size)||0),url:`/api/file/content/${e}`});let r=t.markdown||{},c=n?r.image||``:r.file||`[${t.name}](${e})`;(n?a:o).push(`\n${c}\n`)}return{items:i,imageInserts:a,fileInserts:o}}catch{return l(e)}}var d=new Map;function f(n,r={}){if(!n)return null;let{mode:i=`comment`,quote:a=``,prevQuote:o=``,taskLabel:s=``,taskTitle:c=``,src:l=null,onSubmit:u=null,onFiles:f=null}=r,p=`cmp`+Date.now().toString(36)+Math.random().toString(36).slice(2,8),m=t(n);return d.set(p,{onSubmit:u,onFiles:f,prev:m}),e(n,{component:`compose`,name:i===`feedback`?`反馈`:`评论`,config:{token:p,mode:i,quote:a,prevQuote:o,taskLabel:s,taskTitle:c,src:l},location:`center`}),p}function p(n,r){let i=d.get(r);if(d.delete(r),!i||!i.prev||!n)return null;let a=t(n);return a&&a.component!==`compose`?null:e(n,i.prev)}function m(e){return d.get(e)||null}export{o as a,u as i,f as n,p as r,m as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,g as t,v as n,y as r}from"./task-status-BP6y8MVu.js";import{i}from"./md-parse-C2bDc3IZ.js";import{E as a,k as o}from"./index-B_HPAoNR.js";import{t as s}from"./md-panes-BvQXV_C9.js";import{i as c,r as l,t as u}from"./composer-launch-D-b7HKk5.js";var d=e(r(),1),f=n();function p({token:e,mode:n=`comment`,quote:r=``,prevQuote:p=``,taskLabel:m=``,taskTitle:h=``,src:g=null}){let _=o()||{},v=t(),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)([]),[C,w]=(0,d.useState)(!1),T=(0,d.useRef)(null),E=n===`feedback`,D=()=>{l(_.model,e)},O=async()=>{let t=String(y||``).trim();if(!t&&!x.length){v(E?`写一下要改的地方`:`写一下要提的问题`);return}let n=u(e);if(!n||!n.onSubmit){v(`提交入口已失效(来源页面已关闭)`);return}w(!0);try{await n.onSubmit({text:t,attachments:x,inserts:``}),D()}catch(e){v(String(e.message||e))}finally{w(!1)}},k=async e=>{if(!e||!e.length)return;let{items:t,imageInserts:n,fileInserts:r}=await c(e),a=[...n,...r].join(``);a&&b(e=>i(e,a,{}).body),t.length&&S(e=>[...e,...t])},A=()=>{let e=_.model;e&&g&&g.task&&a(e,{component:`page`,name:g.name||`原文`,config:{dirKey:g.dirKey,task:String(g.task)}})},j=!!(g&&g.task);return(0,f.jsxs)(`div`,{className:`cmp`,children:[(0,f.jsxs)(`div`,{className:`cmp-head`,children:[(0,f.jsx)(`span`,{className:`cmp-tag`+(E?` is-fb`:``),children:E?`反馈`:`评论`}),(0,f.jsx)(`div`,{className:`cmp-ctx`,children:E?(0,f.jsxs)(`span`,{className:`cmp-ctx-line`,title:h||``,children:[`反馈 `,m||``,` 的任务`,h?` · ${h}`:``]}):(0,f.jsx)(`span`,{className:`cmp-ctx-line`,children:`对本任务提出问题`})}),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:D,disabled:C,children:`关闭`}),(0,f.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:O,disabled:C,children:E?`提交反馈`:`提交评论`})]}),E?(0,f.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,f.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`之前的引用`,j&&(0,f.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:A,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),j?(0,f.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:A,title:`点击在右侧并排显示原文,方便对照`,children:p||`(这条任务还没有可引用的上轮总结)`}):(0,f.jsx)(`div`,{className:`cmp-quote`,children:p||`(这条任务还没有可引用的上轮总结)`})]}):r?(0,f.jsxs)(`div`,{className:`cmp-quote-wrap`,children:[(0,f.jsxs)(`div`,{className:`cmp-quote-cap`,children:[`引用`,j&&(0,f.jsx)(`button`,{type:`button`,className:`cmp-quote-cmp`,onClick:A,title:`在右侧并排显示原文,方便对照`,children:`对照原文 ↗`})]}),j?(0,f.jsx)(`button`,{type:`button`,className:`cmp-quote`,onClick:A,title:`点击在右侧并排显示原文,方便对照`,children:r}):(0,f.jsx)(`div`,{className:`cmp-quote`,children:r})]}):null,(0,f.jsx)(`div`,{className:`cmp-body`,children:(0,f.jsx)(s,{mode:`split`,title:``,body:y,onTitle:()=>{},onBody:b,attachments:x,docKey:`compose-`+e,editorApiRef:T,onFiles:k,onSave:O,hideTitle:!0})})]})}export{p as default};
|