nx-kv 0.55.2 → 0.55.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/assets/nx-kv/references/A02-/346/217/220/344/272/244/344/273/273/345/212/241.md +5 -0
- package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +1 -1
- package/package.json +1 -1
- package/src/web/frontend/components/md/attach-area.tsx +7 -1
- package/src/web/frontend/components/md/attach-common.ts +10 -2
- package/src/web/frontend/components/md/attach-modal.tsx +58 -5
- package/src/web/frontend/modules/md/styles/chrome.css +2 -2
- package/src/web/frontend/page/dir/task-dock-panel.tsx +1 -1
- package/src/web/frontend/page/dir/task.tsx +1 -1
- package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
- package/src/web/public/assets/{bar-BYNKx6rI.js → bar-CmzzOYQi.js} +1 -1
- package/src/web/public/assets/{composer-launch-DMiU1boX.js → composer-launch-h-8g0f8A.js} +1 -1
- package/src/web/public/assets/{composer-panel-NES6yM9k.js → composer-panel-BLcyMC2Z.js} +1 -1
- package/src/web/public/assets/{dir-DFH0cNx8.js → dir-C1TPCIdI.js} +1 -1
- package/src/web/public/assets/doc-CKkCGsZ4.js +6 -0
- package/src/web/public/assets/{group-B-oQF4yp.js → group-DobrfJ9c.js} +1 -1
- package/src/web/public/assets/{index-Doe0Kcld.js → index-Bij7tTb6.js} +2 -2
- package/src/web/public/assets/{index-B3LEHx5-.css → index-Dv-b0cgy.css} +1 -1
- package/src/web/public/assets/md-history-BF85zuFo.js +39 -0
- package/src/web/public/assets/{refs-Juq7gWce.js → refs-DvvwZmdl.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-CDZb_LS0.js → repo-form-modal-DxEqerLy.js} +1 -1
- package/src/web/public/assets/{repos-mtBb_wAJ.js → repos-CKbhG3cI.js} +1 -1
- package/src/web/public/assets/{settings-B143g0MN.js → settings-Jf-Ycgtb.js} +1 -1
- package/src/web/public/assets/{task-BHAhv8Bx.js → task-GirP7dr-.js} +2 -2
- package/src/web/public/assets/{task-utils-Bdx7ApC1.js → task-utils-WfeuGNak.js} +1 -1
- package/src/web/public/assets/{templates-B12d64mQ.js → templates-DYlKvFGW.js} +1 -1
- package/src/web/public/assets/use-rail-drag-B1RQzqcB.js +1 -0
- package/src/web/public/index.html +6 -6
- package/src/web/public/assets/doc-RM4avSIW.js +0 -6
- package/src/web/public/assets/md-history-DUv-eEJZ.js +0 -39
- package/src/web/public/assets/use-rail-drag-DN3e5kyQ.js +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{C as e,b as t,n,t as r,u as i,v as a,y as o}from"./frontmatter-DEIM0yF2.js";import{t as s,w as c}from"./workspace-C0PPPfA1.js";import{n as l}from"./app-context-CR7f0AtI.js";import{t as u}from"./status-tag-BKA9au1l.js";var d={inline:`正文内嵌`,area:`附件区`},f=e=>e===`attach`||e===`doc`?`area`:`inline`,p=/\.(png|jpe?g|gif|webp|bmp|svg)$/i;function m(e){let t=Number(e)||0;return t?t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(0)} KB`:`${(t/1024/1024).toFixed(1)} MB`:``}function h(e){return`/api/file/content/${encodeURIComponent(String(e))}`}function g(e){let t=String(e||``).replace(/\\/g,`/`);return/^(ref|path):/.test(t)?t:/^\/|[A-Za-z]:\//.test(t)?`path:${t}`:``}function _(e){let t=String(e.role||`inline`),n=e.kind===`file`&&(e.isImage===!0||/^image\//i.test(e.mime||``)||p.test(e.name||``)),r=typeof e.url==`string`?e.url:e.url&&e.url.href?String(e.url.href):``;return{...e,role:t,area:f(t),areaLabel:d[f(t)],kind:e.kind===`file`&&n?`image`:e.kind,sizeText:m(e.size),href:e.kind===`file`?h(e.id):e.kind===`mdfile`||e.kind===`folder`?``:e.href||r,targetSeq:e.targetSeq??(e.meta&&e.meta.seq)??null,targetKey:e.targetKey||e.meta&&e.meta.topicKey||``,targetRef:e.targetKey||e.meta&&e.meta.refId||``,locator:e.locator||e.meta&&e.meta.locator||``}}var v={image:`图片`,file:`文件`,url:`链接`,task:`任务`,ref:`文档`,mdfile:`md`,folder:`文件夹`},y=e=>v[e||``]||`附件`;function b(e,{hostId:t,hostKey:n,hostCwd:r,refId:i}){if(e===`task`){let e=n?{key:n}:r?{cwd:r}:{},i=new URLSearchParams({id:String(t)});return n?i.set(`key`,n):r&&i.set(`cwd`,r),{list:()=>a(`/api/localtasks/attachments?${i.toString()}`),attach:n=>a(`/api/localtasks/attach`,{method:`POST`,body:{id:Number(t),...e,...n,noEmbed:!0}}),detach:(n,r)=>a(`/api/localtasks/attach`,{method:`DELETE`,body:{id:Number(t),...e,attachment:n,purge:r}})}}let o=new URLSearchParams({ref:String(i||``)});return{list:()=>a(`/api/docs/attachments?${o.toString()}`),attach:e=>a(`/api/docs/attach`,{method:`POST`,body:{ref:i,...e,noEmbed:!0}}),detach:(e,t)=>a(`/api/docs/attach`,{method:`DELETE`,body:{ref:i,attachment:e,purge:t}})}}function x(e,t=`task`){if(e.source===`file`)return{fileId:e.fileId,name:e.name};if(e.source===`url`)return{url:e.url,name:e.name};if(e.source===`folder`)return{folder:e.folder,name:e.name};if(e.source===`task`)return{task:String(e.seq),name:e.name};if(e.source===`ref`){let n=t===`doc`?{doc:e.docRef,name:e.name}:{ref:e.docRef,name:e.name};return e.note&&(n.note=e.note),t!==`doc`&&e.inline&&(n.inline=!0),n}return{}}function S(e,t,n){return{value:e,start:t,end:n}}function C(e,t,n=t,r=``){if(!e)return null;let{value:i,selectionStart:a,selectionEnd:o}=e,s=i.slice(a,o)||r,c=i.slice(0,a)+t+s+n+i.slice(o),l=a+t.length;return S(c,l,l+s.length)}function w(e,t){if(!e)return null;let{value:n,selectionStart:r,selectionEnd:i}=e,a=n.lastIndexOf(`
|
|
2
|
+
`,r-1)+1,o=(()=>{let e=n.indexOf(`
|
|
3
|
+
`,i);return e===-1?n.length:e})(),s=n.slice(a,o),c=s.split(`
|
|
4
|
+
`),l=c.every(e=>e.startsWith(t)||e===``),u=c.map(e=>!e&&c.length>1?e:l?e.startsWith(t)?e.slice(t.length):e:e.startsWith(t)?e:t+e).join(`
|
|
5
|
+
`),d=n.slice(0,a)+u+n.slice(o),f=u.length-s.length;return S(d,r,Math.max(r,i+f))}var T=` `;function E(e,t=!1){if(!e)return null;let{value:n,selectionStart:r,selectionEnd:i}=e,a=n.lastIndexOf(`
|
|
6
|
+
`,r-1)+1,o=(()=>{let e=n.indexOf(`
|
|
7
|
+
`,Math.max(i-+(i>0&&n[i-1]===`
|
|
8
|
+
`),a));return e===-1?n.length:e})(),s=n.slice(a,o),c=s.split(`
|
|
9
|
+
`),l=0,u=c.map((e,n)=>t?e.startsWith(T)?(n===0&&(l=2),e.slice(2)):e.startsWith(` `)||e.startsWith(` `)?(n===0&&(l=1),e.slice(1)):e:T+e).join(`
|
|
10
|
+
`),d=n.slice(0,a)+u+n.slice(o);if(t){let e=Math.max(a,r-l);return S(d,e,Math.max(e,i-(s.length-u.length)))}return S(d,r+2,i+2*c.length)}function D(e){if(!e)return null;let{value:t,selectionStart:n,selectionEnd:r}=e;if(n!==r)return null;let i=t.lastIndexOf(`
|
|
11
|
+
`,n-1)+1,a=t.slice(i,n).match(/^(\s*)([-*+]|\d+\.)(\s+)(\[[ xX]\]\s+)?(.*)$/);if(!a)return null;let[,o=``,s=``,c=``,l=``,u=``]=a;if(!String(u||``).trim())return S(t.slice(0,i)+t.slice(n),i,i);let d=s;/^\d+\.$/.test(s)&&(d=`${Number(s.slice(0,-1))+1}.`);let f=`\n${o}${d}${c}${l||``}`,p=t.slice(0,n)+f+t.slice(r),m=n+f.length;return S(p,m,m)}var O={bold:e=>C(e,`**`,`**`,`粗体`),italic:e=>C(e,`*`,`*`,`斜体`),code:e=>C(e,"`","`",`code`),strike:e=>C(e,`~~`,`~~`,`删除线`),link:e=>{if(!e)return null;let{value:t,selectionStart:n,selectionEnd:r}=e,i=t.slice(n,r)||`链接文字`,a=`${t.slice(0,n)}[${i}](url)${t.slice(r)}`,o=n+i.length+3;return S(a,o,o+3)},h2:e=>w(e,`## `),h3:e=>w(e,`### `),ul:e=>w(e,`- `),todo:e=>w(e,`- [ ] `),quote:e=>w(e,`> `)};function k(e,t){let n=O[t];return n?n(e):null}function A(e){let t=String(e??``);return t!==``&&/^[ \t]*(?:[-*+][ \t]*|\d+\.[ \t]+)(?:\[[ xX]\][ \t]*)?$/.test(t)}function j(e,t){let n=/^([ \t]*-[ \t]+\[)([ xX])(\])/gm,r=0,i=String(e??``).replace(n,(e,n,i,a)=>r++===t?n+(/x/i.test(i)?` `:`x`)+a:e);return r>t?i:null}function M(e){let t=String(e||``);return{lines:t.length?t.split(`
|
|
12
|
+
`).length:0,chars:t.length,words:t.trim()?t.trim().split(/\s+/).length:0}}function N(e,t){let n=String(e||``),r=Math.max(0,Math.min(t??0,n.length)),i=n.slice(0,r);return{line:i.split(`
|
|
13
|
+
`).length,col:i.length-i.lastIndexOf(`
|
|
14
|
+
`)}}function P(e,t){if(!e||t==null)return null;let{value:n,selectionStart:r,selectionEnd:i}=e,a=n.slice(0,r)+t+n.slice(i),o=r+String(t).length;return S(a,o,o)}var F=[{id:`text`,ops:[`text`,`正文`,`p`,`paragraph`],label:`正文`,hint:`纯文本`,turn:`text`},{id:`h2`,ops:[`h2`,`标题`,`heading`,`h`],label:`标题`,hint:`##`,turn:`h2`},{id:`h3`,ops:[`h3`,`小标题`],label:`小标题`,hint:`###`,turn:`h3`},{id:`ul`,ops:[`ul`,`list`,`列表`],label:`列表`,hint:`- `,turn:`ul`},{id:`todo`,ops:[`todo`,`task`,`待办`],label:`待办`,hint:`- [ ]`,turn:`todo`},{id:`quote`,ops:[`quote`,`引用`],label:`引用`,hint:`> `,turn:`quote`},{id:`bold`,ops:[`bold`,`b`,`粗体`],label:`粗体`,hint:`**`,format:`bold`},{id:`code`,ops:[`code`,`代码`],label:`行内代码`,hint:"`",format:`code`},{id:`link`,ops:[`link`,`链接`],label:`链接`,hint:`[]()`,format:`link`}],I=[{key:`1`,id:`text`,label:`正文`,hint:`1`,apply:e=>R(e)},{key:`2`,id:`h2`,label:`标题`,hint:`2`,apply:e=>z(R(e),`## `)},{key:`3`,id:`h3`,label:`小标题`,hint:`3`,apply:e=>z(R(e),`### `)},{key:`4`,id:`ul`,label:`列表`,hint:`4`,apply:e=>z(R(e),`- `)},{key:`5`,id:`todo`,label:`待办`,hint:`5`,apply:e=>z(R(e),`- [ ] `)},{key:`6`,id:`quote`,label:`引用`,hint:`6`,apply:e=>z(R(e),`> `)}],L=/^(#{1,3}\s|>\s|-\s+(?:\[[ xX]\]\s+)?)/;function R(e){return String(e||``).split(`
|
|
15
|
+
`).map(e=>e.replace(L,``)).join(`
|
|
16
|
+
`)}function z(e,t){let n=String(e||``).split(`
|
|
17
|
+
`);return n.length?n.map((e,r)=>!e.trim()&&n.length>1?e:r===0||e.trim()?t+e.replace(L,``):e).join(`
|
|
18
|
+
`):t}function B(e,t){if(!e)return null;let n=I.find(e=>e.id===t||e.key===String(t));if(!n)return null;let r=n.apply(e.value);return{value:r,start:0,end:r.length}}function ee(e,t){if(!e)return null;let n=I.find(e=>e.id===t||e.key===String(t));if(!n)return null;let{value:r,selectionStart:i,selectionEnd:a}=e,o=r.lastIndexOf(`
|
|
19
|
+
`,i-1)+1,s=(()=>{let e=r.indexOf(`
|
|
20
|
+
`,a);return e===-1?r.length:e})(),c=r.slice(o,s),l=n.apply(c);return S(r.slice(0,o)+l+r.slice(s),o,o+l.length)}function V(e){if(!e)return null;let{value:t,selectionStart:n,selectionEnd:r}=e;if(n!==r)return null;let i=t.slice(0,n),a=i.lastIndexOf(`
|
|
21
|
+
`)+1,o=i.slice(a).match(/^\/([^\s\n]*)$/);return o?{start:a,end:n,query:o[1]||``}:null}function H(e){let t=String(e||``).toLowerCase();return t?F.filter(e=>e.ops.some(e=>e.startsWith(t)||e.includes(t))):F}function U(e,t){let n=V(e);if(!n||!t||!e)return null;let{value:r}=e,i={value:r.slice(0,n.start)+r.slice(n.end),selectionStart:n.start,selectionEnd:n.start};return t.turn?ee(i,t.turn):k(i,t.format||``)}function te(e,t){let n=String(t||``);if(!n)return[];let r=String(e||``).toLowerCase(),i=n.toLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let e=r.indexOf(i,o);if(e<0)break;a.push({start:e,end:e+n.length}),o=e+Math.max(1,i.length)}return a}function ne(e,t){if(!e)return;let n=String(e.value||``).slice(0,Math.max(0,t)).split(`
|
|
22
|
+
`).length,r=getComputedStyle(e),i=parseFloat(r.lineHeight);(!Number.isFinite(i)||i<=0)&&(i=(parseFloat(r.fontSize)||13)*1.7);let a=parseFloat(r.paddingTop)||0;e.scrollTop=Math.max(0,a+(n-2)*i-e.clientHeight/3)}function W(e){if(!e)return[];let t=[];if(e.files?.length)for(let n of e.files)n&&n.size>0&&t.push(n);if(!t.length&&e.items?.length)for(let n of e.items){if(n.kind!==`file`)continue;let e=n.getAsFile();e&&e.size>0&&t.push(e)}return t}function re(e,t){let n=String(e??``),r=String(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a+=1;return a}var G=/^[0-9a-fA-F]{16,}(\.[A-Za-z0-9]{1,8})?$/;function K(e){return G.test(String(e??``).trim())}function q({name:e,id:t,kind:n=`file`}={}){let r=String(e||t||``).replace(/[[\]]/g,``);return t?n===`image`?``:`[${r}](${t})`:``}function ie(e){if(!e)return null;let t=e.selectionStart;if(t!==e.selectionEnd||t<=0)return null;let n=e.value||``;if(n[t-1]!==`@`)return null;let r=t>=2?n[t-2]??``:``;return/[A-Za-z0-9_]/.test(r)?null:{at:t-1,caret:t}}function ae(e){if(!e)return``;let t=String(e.name||e.title||e.locator||`附件`).replace(/[[\]]/g,``),n=e.id;if(e.kind===`image`||e.isImage)return q({name:t,id:n,kind:`image`});if(e.kind===`file`)return q({name:t,id:n,kind:`file`});if(e.kind===`url`){let n=e.url||e.href||``;return n?`[${t}](${n})`:``}if(e.kind===`task`){let n=e.taskId||``;return n?`[${t}](nxkv://task/${n})`:e.href?`[${t}](${e.href})`:``}if(e.kind===`ref`){let n=e.refId||``;return n?`[${t}](nxkv://ref/${n})`:e.href?`[${t}](${e.href})`:``}if(e.kind===`mdfile`){let n=e.id||``;return n?`[${t}](nxkv://mdfile/${n})`:``}return``}function oe(e,t,n){let r=t&&!/\s/.test(t)?` `:``,i=n&&!/\s/.test(n)?` `:``;return{text:r+e+i,caretAt:r.length+e.length+i.length}}var se={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`,"image/bmp":`.bmp`,"image/svg+xml":`.svg`,"application/pdf":`.pdf`,"text/plain":`.txt`,"text/markdown":`.md`,"text/csv":`.csv`,"application/zip":`.zip`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`.docx`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`.xlsx`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`.pptx`},ce=e=>String(e).padStart(2,`0`),le=()=>{let e=new Date;return`${e.getFullYear()}${ce(e.getMonth()+1)}${ce(e.getDate())}-${ce(e.getHours())}${ce(e.getMinutes())}${ce(e.getSeconds())}`};function ue(e){let t=e.clipboardData;if(!t)return[];let n=[];if(t.items)for(let e of t.items){if(e.kind!==`file`)continue;let t=e.getAsFile();t&&n.push(t)}return!n.length&&t.files&&n.push(...Array.from(t.files)),n}function de(e){let t=e.dataTransfer;return t?Array.from(t.files||[]).filter(e=>e&&e.size>0):[]}function fe(e,t=0){let n=String(e.name||``).trim();if(!(!n||/^image\.(png|jpe?g)$/i.test(n)||/^blob$/i.test(n)))return n;let r=n.includes(`.`)?n.slice(n.lastIndexOf(`.`)):``,i=se[e.type]||r||`.bin`;return`粘贴图片-${le()}${t>0?`-${t+1}`:``}${i}`}function pe(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`读取文件失败: ${e.name||`(无名)`}`)),r.onload=()=>t(String(r.result||``)),r.readAsDataURL(e)})}async function me(e,{index:t=0}={}){let n=e,r=fe(n,t),i=await pe(n);return{...await a(`/api/file`,{method:`POST`,body:{name:r,content:i,contentType:n.type||``}}),name:r}}async function he(e,{onProgress:t}={}){let n=[];for(let r=0;r<e.length;r++){let i=e[r];t&&t(r+1,e.length,i),n.push(await me(i,{index:r}))}return n}function ge(e){return e.map(e=>e.isImage?e.markdown.image:e.markdown.file).join(` `)}var J=e(t(),1),Y=o(),_e=i,ve={file:`本机文件`,folder:`本地文件夹`,url:`外部链接`,task:`任务引用`,ref:`文档引用`},ye=e=>/^[A-Za-z]:[\\/]/.test(e)||/^\\\\/.test(e)||/^[/\\]/.test(e),be=0,xe=()=>`p${Date.now()}-${be+=1}`,Se=e=>(String(e&&(e.title||e.text)||``).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).trim().slice(0,80);function Ce({open:e,host:t=`task`,hostId:n,hostKey:r,hostCwd:i,refId:o,allow:s={file:!0,url:!0,folder:!0,task:!1,ref:!1},taskOptions:c=[],docOptions:l=null,replaceAttachment:d=null,replaceNote:f=``,onClose:p,onDone:h}){let[g,_]=(0,J.useState)([]),[v,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(``),[D,O]=(0,J.useState)(``),[k,A]=(0,J.useState)(``),[j,M]=(0,J.useState)(``),[N,P]=(0,J.useState)(``),[F,I]=(0,J.useState)(``),[L,R]=(0,J.useState)(l||[]),z=(0,J.useRef)(null),B=(0,J.useRef)(null),ee=(0,J.useMemo)(()=>b(t,{hostId:n,hostKey:r,hostCwd:i,refId:o}),[t,n,r,i,o]);(0,J.useEffect)(()=>{if(!e)return;_([]),S(!1),w(!1),E(``),O(``),A(``),M(``),P(``),I(``);let t=setTimeout(()=>B.current?.focus(),0);return()=>clearTimeout(t)},[e]),(0,J.useEffect)(()=>{if(!e||l||!s.ref)return;let t=!0;return a(`/api/docs`).then(e=>{if(!t)return;let n=(e.docs||[]).map(e=>{let t=e.refId?`ref:`+e.refId:e.docId||``,n=String(e.desc||``).trim(),r=String(e.title||e.name||``).trim();return{ref:t,title:n||r||`未命名文档`,sub:n&&r&&r!==n?r:``,desc:n}}).filter(e=>!!e.ref);R(n)}).catch(()=>{}),()=>{t=!1}},[e,l,s.ref]);let V=e=>{if(!s.file)return;let t=[...e||[]].filter(e=>e&&e.size>0);t.length&&_(e=>[...e,...t.map((e,t)=>{let n=fe(e,t);return{key:xe(),source:`file`,file:e,name:n,mime:e.type||``,size:e.size,status:`pending`}})])},H=()=>{let e=String(T||``).trim();if(!/^https?:\/\//i.test(e)){O(`需要 http(s) 绝对地址`);return}O(``),E(``),_(t=>[...t,{key:xe(),source:`url`,url:e,name:e,size:0,status:`pending`}])},U=()=>{let e=String(k||``).trim().replace(/^["']+|["']+$/g,``);if(!e){M(`需要文件夹的路径`);return}if(!ye(e)){M(`相对路径会按服务端工作目录解析,建议写绝对路径(如 D:\\repos\\ref)`);return}M(``),A(``);let t=e.replace(/[\\/]+$/,``)||e,n=t.split(/[\\/]/).filter(Boolean).pop()||t;_(e=>[...e,{key:xe(),source:`folder`,folder:t,name:n,size:0,status:`pending`}])},te=e=>{let t=Se(e);_(n=>[...n,{key:xe(),source:`task`,seq:Number(e.id),name:`#${e.id} ${t}`.trim(),size:0,status:`pending`}]),P(``)},ne=e=>{_(t=>[...t,{key:xe(),source:`ref`,docRef:e.ref,name:e.title||e.desc||e.name||e.ref,size:0,status:`pending`,note:``,inline:!1}]),I(``)},W=(e,t)=>_(n=>n.map(n=>n.key===e?{...n,...t}:n)),re=e=>_(t=>t.filter(t=>t.key!==e)),G=async e=>{_(t=>t.map(t=>t.key===e.key?{...t,status:`uploading`,error:``}:t));try{let n=e.fileId;if(e.source===`file`&&!n){let t=await me(e.file);if(n=t.fileId||t.id,!n)throw Error(`上传未返回 fileId`)}if(await ee.attach(x({...e,fileId:n,note:e.note||f||``},t)),d)try{await ee.detach(d,!1)}catch{}return _(t=>t.filter(t=>t.key!==e.key)),!0}catch(t){return _(n=>n.map(n=>n.key===e.key?{...n,status:`error`,error:String(t.message||t)}:n)),!1}},K=async e=>{if(C)return;let t=e?g.filter(t=>t.key===e):g;if(!t.length)return;w(!0);let n=!1,r=0;for(let e of t)await G(e)?n=!0:r+=1;w(!1),n&&h?.(),r||p?.()},q=(0,J.useMemo)(()=>{let e=N.trim().toLowerCase();return c.filter(e=>String(e.id)!==String(n)).filter(t=>!e||`${t.id} ${t.text||``}`.toLowerCase().includes(e)).slice(0,12)},[c,N,n]),ie=(0,J.useMemo)(()=>{let e=F.trim().toLowerCase();return L.filter(t=>!e||`${t.title||``} ${t.sub||``} ${t.desc||``} ${t.ref}`.toLowerCase().includes(e)).slice(0,12)},[L,F]),ae=e=>{let t=ue(e);t.length&&(e.preventDefault(),V(t))},oe=g.filter(e=>e.status!==`error`).length;return e?(0,Y.jsxs)(_e,{title:d?`更换文档绑定`:`添加附件`,size:`md`,onClose:C?void 0:p,busy:C,className:`att-modal`,footer:(0,Y.jsxs)(`div`,{className:`att-foot`,children:[(0,Y.jsx)(`span`,{className:`att-foot-hint`,children:g.length?`待确认 ${oe} 项${g.some(e=>e.status===`error`)?`(失败项可单独重试)`:``}`:`拖文件进来,或选择下面的来源`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:C,onClick:p,children:`取消`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn`,disabled:C||!oe,onClick:()=>K(),children:C?`提交中…`:`确认添加`})]}),children:[(0,Y.jsxs)(`div`,{ref:B,className:`att-drop`+(v?` is-over`:``),onDragOver:e=>{e.preventDefault(),S(!0)},onDragLeave:e=>{e.target===e.currentTarget&&S(!1)},onDrop:e=>{e.preventDefault(),S(!1),V(de(e))},onPaste:ae,onKeyDown:e=>{let t=e.target;e.key===`Enter`&&!e.defaultPrevented&&!/INPUT|TEXTAREA|SELECT|BUTTON/.test(t.tagName)&&(e.preventDefault(),K())},tabIndex:0,children:[(0,Y.jsx)(`div`,{className:`att-drop-title`,children:`拖拽文件到这里,或`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>z.current?.click(),children:`选择文件(可多选)`}),(0,Y.jsx)(`div`,{className:`att-drop-sub`,children:`支持截图直接粘贴(Ctrl/⌘ + V);文件夹请用下面的路径输入框`}),(0,Y.jsx)(`input`,{ref:z,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,V(t)}})]}),s.url&&(0,Y.jsxs)(`div`,{className:`att-row att-url-row`,children:[(0,Y.jsx)(`input`,{className:`pp-input`,placeholder:`添加 URL(http/https)`,value:T,onChange:e=>{E(e.target.value),O(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),H())},spellCheck:`false`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:H,children:`添加`}),D?(0,Y.jsx)(`span`,{className:`att-err-text`,children:D}):null]}),s.folder&&(0,Y.jsxs)(`div`,{className:`att-row att-url-row`,children:[(0,Y.jsx)(`input`,{className:`pp-input`,placeholder:`添加文件夹(本机绝对路径,如 D:\\\\repos\\\\ref)`,value:k,onChange:e=>{A(e.target.value),M(``)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),U())},spellCheck:`false`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:U,children:`添加`}),j?(0,Y.jsx)(`span`,{className:`att-err-text`,children:j}):null]}),s.task&&(0,Y.jsxs)(`div`,{className:`att-pick`,children:[(0,Y.jsx)(`div`,{className:`att-pick-head`,children:`关联任务(本主题)`}),(0,Y.jsx)(`input`,{className:`pp-input`,placeholder:`搜索任务编号或标题`,value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{let t=q[0];e.key===`Enter`&&t&&(e.preventDefault(),te(t))},spellCheck:`false`}),q.length?(0,Y.jsx)(`div`,{className:`att-pick-list`,children:q.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`att-pick-item`,onClick:()=>te(e),children:[(0,Y.jsxs)(`span`,{className:`att-pick-main`,children:[`#`,e.id,` `,Se(e)||`(无标题)`]}),(0,Y.jsx)(u,{t:e,className:`att-sbadge`,title:void 0})]},e.id))}):(0,Y.jsx)(`div`,{className:`att-empty-inline`,children:c.length?`没有匹配的任务`:`本主题暂无其它任务`})]}),s.ref&&(0,Y.jsxs)(`div`,{className:`att-pick`,children:[(0,Y.jsx)(`div`,{className:`att-pick-head`,children:`关联文档(ref)`}),(0,Y.jsx)(`input`,{className:`pp-input`,placeholder:`搜索描述或标题`,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>{let t=ie[0];e.key===`Enter`&&t&&(e.preventDefault(),ne(t))},spellCheck:`false`}),ie.length?(0,Y.jsx)(`div`,{className:`att-pick-list`,children:ie.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`att-pick-item`,onClick:()=>ne(e),children:[(0,Y.jsx)(`span`,{className:`att-pick-main`,children:e.title||e.ref}),e.sub?(0,Y.jsx)(`span`,{className:`att-pick-path`,children:e.sub}):null]},e.ref))}):(0,Y.jsx)(`div`,{className:`att-empty-inline`,children:L.length?`没有匹配的文档`:`文档库为空`})]}),g.length?(0,Y.jsxs)(`div`,{className:`att-pending`,children:[(0,Y.jsx)(`div`,{className:`att-pending-head`,children:`待确认清单`}),g.map(e=>(0,Y.jsxs)(`div`,{className:`att-pending-item`+(e.status===`error`?` is-error`:``),children:[(0,Y.jsx)(`span`,{className:`att-badge`,children:ve[e.source]}),(0,Y.jsx)(`span`,{className:`att-pending-name`,title:e.folder||e.name,children:e.source===`folder`&&e.folder||e.name}),(0,Y.jsx)(`span`,{className:`att-pending-type`,children:y(e.source===`file`?/^image\//i.test(e.mime||``)?`image`:`file`:e.source)}),e.size?(0,Y.jsx)(`span`,{className:`att-pending-size`,children:m(e.size)}):null,e.source===`ref`?(0,Y.jsxs)(`span`,{className:`att-pending-ref-opts`,children:[(0,Y.jsx)(`input`,{className:`att-pending-note`,type:`text`,value:e.note||``,placeholder:`说明(这一行里大概是什么)`,disabled:C,onChange:t=>W(e.key,{note:t.target.value})}),t===`task`?(0,Y.jsxs)(`label`,{className:`att-pending-inline`,title:`交付时把文档全文附进提示词,而不是只给路径`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:!!e.inline,disabled:C,onChange:t=>W(e.key,{inline:t.target.checked})}),`进原文`]}):null]}):null,e.status===`uploading`?(0,Y.jsx)(`span`,{className:`att-pending-state`,children:`上传中…`}):null,e.status===`error`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`att-err-text`,title:e.error,children:e.error||`失败`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost att-mini`,disabled:C,onClick:()=>K(e.key),children:`重试`})]}):null,(0,Y.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除待确认项`,disabled:C,onClick:()=>re(e.key),children:`×`})]},e.key))]}):null]}):null}function we({host:e,itemsOverride:t=null,onInsert:n}){let[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)([]),s=e?JSON.stringify({h:e.host,id:e.hostId,k:e.hostKey,c:e.hostCwd,r:e.refId}):``,c=(0,J.useCallback)(async()=>{if(!e){o([]),i(e=>e&&{...e,loading:!1,error:``});return}try{let t=await b(e.host,e).list();o((t.attachments||[]).map(_)),i(e=>e&&{...e,loading:!1,error:``})}catch(e){o([]),i(t=>t&&{...t,loading:!1,error:String(e.message||e)})}},[s]),l=(0,J.useCallback)(({index:e,ta:t,at:n,caret:r})=>{if(!t)return;let a=t.getBoundingClientRect(),o=N(t.value,r).line,s=Math.min(window.innerWidth-340,a.left+8),l=Math.min(window.innerHeight-360,a.top+o*20-t.scrollTop+8);i({index:e,at:n,caret:r,x:s,y:l,query:``,active:0,loading:!0,error:``}),c()},[s,c]),u=(0,J.useCallback)(()=>i(e=>e&&null),[]),d=t??a,f=(0,J.useMemo)(()=>{let e=String(r?.query||``).trim().toLowerCase();return e?d.filter(t=>String(t.name||t.title||t.locator||``).toLowerCase().includes(e)):d},[d,r?.query]);return{menu:r,items:f,active:f.length?Math.min(Math.max(0,r?.active??0),f.length-1):0,open:l,close:u,reload:c,move:(0,J.useCallback)((e,t)=>{i(n=>{if(!n)return n;let r=f.length;if(!r)return n;let i=t?e:((n.active+e)%r+r)%r;return{...n,active:i}})},[f.length]),setQuery:(0,J.useCallback)(e=>{i(t=>t&&{...t,query:e,active:0})},[]),pick:(0,J.useCallback)(e=>{let t=r;if(i(null),!e||!t)return;let a=ae(e);a&&n({index:t.index,embed:a,at:t.at,caret:t.caret})},[r,n])}}function Te({items:e,query:t,onQuery:n,active:r,onHover:i,onPick:a,loading:o,error:c,position:u,host:d=null,onReload:f=null,onAddFiles:p=null}){let m=(0,J.useRef)(null),h=(0,J.useRef)(null),_=(0,J.useRef)(null),v=l(),[y,b]=(0,J.useState)(!1);(0,J.useEffect)(()=>{h.current?.focus()},[]),(0,J.useEffect)(()=>{let e=m.current;e&&e.querySelector(`.mdw-atpick-item.on`)?.scrollIntoView?.({block:`nearest`})},[r,e]);let x=e=>{let t=v.model;if(t){if(e.kind===`task`&&e.topicKey&&e.seq){s(t,{component:`page`,name:`原文 #${e.seq}`,config:{dirKey:String(e.topicKey),task:String(e.seq)}});return}if(e.kind===`ref`){let n=e.refId?`ref:`+e.refId:g(e.locator||``);if(!n)return;s(t,{component:`doc`,name:e.title||e.name||`文档`,config:{docId:n}})}}},S=e=>e.kind===`task`?!!(e.topicKey&&e.seq):e.kind===`ref`&&!!(e.refId||e.locator);return(0,Y.jsxs)(`div`,{className:`mdw-atpick`,role:`dialog`,"aria-label":`选择附件`,style:u,children:[(0,Y.jsx)(`div`,{className:`mdw-atpick-search`,children:(0,Y.jsx)(`input`,{ref:h,value:t,onChange:e=>n(e.target.value),placeholder:`搜索附件…`,"aria-label":`搜索附件`,onKeyDown:t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),i(t.key===`ArrowDown`?1:-1);return}if(t.key===`Enter`){t.preventDefault();let n=e[r];n&&a(n);return}t.key===`Escape`&&(t.preventDefault(),a(null))}})}),o?(0,Y.jsx)(`div`,{className:`mdw-atpick-empty`,children:`读取附件…`}):c?(0,Y.jsxs)(`div`,{className:`mdw-atpick-empty`,children:[`读取失败:`,c]}):e.length?(0,Y.jsx)(`div`,{className:`mdw-atpick-list`,ref:m,children:e.map((e,t)=>{let n=(e.kind===`ref`?e.title||e.name:e.name||e.title)||e.locator||`附件`,o=S(e);return(0,Y.jsxs)(`div`,{className:`mdw-atpick-row`,children:[(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===r,className:`mdw-atpick-item${t===r?` on`:``}`,onMouseEnter:()=>i(t,!0),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,Y.jsx)(`span`,{className:`lab`,title:n,children:n}),(0,Y.jsx)(`span`,{className:`hint`,children:[e.kindLabel||e.badge,e.sizeText,e.areaLabel].filter(Boolean).join(` · `)})]}),o&&(0,Y.jsx)(`button`,{type:`button`,className:`mdw-atpick-open`,title:`在右侧并排显示原文,方便对照`,"aria-label":`查看原文:${n}`,onMouseDown:t=>{t.preventDefault(),x(e)},children:`↗`})]},e.id||e.url||e.refId||e.taskId||t)})}):(0,Y.jsx)(`div`,{className:`mdw-atpick-empty`,children:t?`没有匹配的附件`:`这条任务还没有附件`}),(0,Y.jsxs)(`div`,{className:`mdw-atpick-foot`,children:[(0,Y.jsx)(`span`,{className:`mdw-atpick-cap`,children:`↑↓ 选择 · Enter 引用 · Esc 取消`}),(0,Y.jsx)(`span`,{className:`grow`}),d?(0,Y.jsx)(`button`,{type:`button`,className:`mdw-atpick-add`,title:`添加附件(本机文件 / 外部链接 / 任务 / 文档)`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(!0),children:`+ 添加附件`}):p?(0,Y.jsx)(`button`,{type:`button`,className:`mdw-atpick-add`,title:`上传本机文件(草稿:先挂进会话草稿,提交任务时一并带上)`,onMouseDown:e=>e.preventDefault(),onClick:()=>_.current?.click(),children:`+ 添加附件`}):null]}),p&&(0,Y.jsx)(`input`,{ref:_,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);t.length&&p(t),_.current&&(_.current.value=``)}}),d&&(0,Y.jsx)(Ce,{open:y,host:d.host,hostId:d.hostId,hostKey:d.hostKey,hostCwd:d.hostCwd,refId:d.refId,allow:d.allow,taskOptions:d.taskOptions,docOptions:d.docOptions,onClose:()=>b(!1),onDone:async()=>{await f?.()}})]})}function Ee(e){return String(e||``).trim().replace(/\.md$/i,``).replace(/\s+/g,` `).toLowerCase()}function De(e,t){let n=Array.isArray(t)?t:[];if(!n.length)return null;let r=Ee(e);if(!r)return null;let i=r.replace(/\\/g,`/`),a=n.find(e=>e.path&&Ee(String(e.path).replace(/\\/g,`/`))===i);if(a)return{docId:a.docId};let o=i.split(`/`).pop()??``,s=n.filter(e=>e.name===o),c=s[0];return s.length===1&&c?{docId:c.docId}:s.length>1?{candidates:s.map(e=>e.docId)}:null}function Oe(e,t){let n=String(e||``).trim().toLowerCase().replace(/\s+/g,`-`).replace(/[^\w\u4e00-\u9fff-]+/g,``).slice(0,48)||`h`,r=n,i=2;for(;t&&t.has(r);)r=`${n}-${i}`,i+=1;return t&&t.add(r),r}function ke(e){let t=[],n=new Set,r=!1;for(let i of String(e||``).split(`
|
|
23
|
+
`)){if(i.startsWith("```")){r=!r;continue}if(r)continue;let e=i.match(/^(#{1,3})\s+(.+)$/);if(!e)continue;let a=(e[2]??``).trim();t.push({level:(e[1]??``).length,text:a,id:Oe(a,n)})}return t}var Ae={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`};function X(e){return String(e).replace(/[&<>"']/g,e=>Ae[e]??e)}function je(e,t){let n=Ee(e);if(!n)return!0;let r=n.split(`/`).pop()??``;return t.has(n)||t.has(r)}function Me(e,t,n){if(!n||!n.size)return t;let r=String(e||``).match(/^nxkv:\/\/ref\/([^)\s]+)$/i);if(!r)return t;let i=n.get(r[1]??``);return i?X(i):t}function Z(e,t,n){return X(e).replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<b>$1</b>`).replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(e,t,n)=>{let r=String(n??``).trim();return K(r)?`<img class="md-att-img" src="/api/file/content/${r}" alt="${t}">`:e}).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,t,n)=>{let r=String(n??``).trim();return K(r)?`<a class="md-att" href="/api/file/content/${r}" download="${t}" title="附件:${t}">${t}</a>`:e}).replace(/\[([^\]]+)\]\((nxkv:\/\/[^)\s]+)\)/g,(e,t,r)=>/^nxkv:\/\/(?:task|ref)\//i.test(r)?`<a class="md-wl" data-nxkv="${r}" title="内部资源:${r}">${Me(r,t,n)}</a>`:e).replace(/\[\[([^\[\]|]+)(?:\|([^\[\]]+))?\]\]/g,(e,n,r)=>{let i=n.trim(),a=(r||n).trim(),o=t&&!je(i,t);return`<a class="md-wl${o?` md-wl-miss`:``}" data-wl="${X(i)}" title="${o?`未解析:`:`双链:`}${X(i)}">${X(a)}</a>`})}function Ne(e,t=[],r=null){let i={},a=new Map;for(let e of t)if(e&&(e.type===`image`&&e.url&&(i[e.name??``]=e.url),e.kind===`ref`)){let t=String(e.refId||e.targetKey||e.targetRef||``),n=String(e.docTitle||e.title||e.name||``);t&&n&&a.set(t,n)}let o=n(e).split(`
|
|
24
|
+
`),s=``,c=!1,l=!1,u=new Set,d=()=>{c&&=(s+=`</ul>`,!1)};for(let e=0;e<o.length;e++){let t=o[e]??``;if(t.startsWith("```")){l?(s+=`</code></pre>`,l=!1):(d(),s+=`<pre class="mdw-code"><code>`,l=!0);continue}if(l){s+=`${X(t)}\n`;continue}let n=t.match(/^!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(n){d();let e=(n[2]??``).trim();if(K(e)){s+=`<p><img class="md-att-img" src="/api/file/content/${e}" alt="${X(n[1])}"></p>`;continue}let t=i[n[2]??``]||n[2]||``,r=/^(data:|blob:|https?:|#)/.test(t)?t:``;s+=r?`<p><img src="${r}" alt="${X(n[1])}"></p>`:`<p><code>![${X(n[1])}](${X(n[2])})</code></p>`;continue}if(t.startsWith(`>`)){d();let t=[],n=e;for(;n<o.length&&(o[n]??``).startsWith(`>`);)t.push((o[n]??``).replace(/^>[ \t]?/,``)),n+=1;e=n-1;let i=t[0],c=i?i.match(/^\[!([A-Za-z][\w-]*)\][ \t]*(.*)$/):null;if(c){let e=String(c[1]||``).toLowerCase(),n=String(c[2]||``).trim(),i=[],o=[];for(let e of t.slice(1)){if(!e.trim()){o.length&&(i.push(o),o=[]);continue}o.push(e)}o.length&&i.push(o);let l=i.map(e=>e.map(e=>Z(e,r,a)).join(`<br>`)).join(`<br><br>`);s+=`<div class="md-callout md-callout-${X(e)}">`+(n?`<div class="md-callout-t">${Z(n,r,a)}</div>`:``)+`<div class="md-callout-b">${l}</div></div>`;continue}s+=`<blockquote>${t.map(e=>Z(e,r,a)).join(`<br>`)}</blockquote>`;continue}if(t.startsWith(`### `)){d();{let e=t.slice(4),n=Oe(e.trim(),u);s+=`<h3 id="${X(n)}">${Z(e,r,a)}</h3>`}continue}if(t.startsWith(`## `)){d();{let e=t.slice(3),n=Oe(e.trim(),u);s+=`<h2 id="${X(n)}">${Z(e,r,a)}</h2>`}continue}if(t.startsWith(`# `)){d();{let e=t.slice(2),n=Oe(e.trim(),u);s+=`<h1 id="${X(n)}">${Z(e,r,a)}</h1>`}continue}let f=t.match(/^-\s+(\[[ xX]\])?\s*(.*)$/);if(f){c||=(s+=`<ul>`,!0);let e=f[1],t=!!e&&/x/i.test(e),n=f[2]??``;s+=e?`<li class="${t?`done`:`todo`}"><span class="mdw-cb" aria-hidden="true">${t?`☑`:`☐`}</span>${Z(n,r,a)}</li>`:`<li>${Z(n,r,a)}</li>`;continue}d(),t.trim()&&(s+=`<p>${Z(t,r,a)}</p>`)}l&&(s+=`</code></pre>`),d();let f=e=>!!e&&e.type!==`image`&&e.kind!==`ref`&&e.kind!==`task`&&e.kind!==`url`,p=t.filter(e=>f(e)&&!s.includes(String(e.id)));return p.length&&(s+=p.map(e=>`<div class="mdw-attach-chip">${X(e.name)}<span class="sz">${X(e.size||``)}</span></div>`).join(``)),s||`<p class="mdw-empty">(空文档)</p>`}function Pe(e){let t=String(e??``);return t.includes(``)?t.split(`
|
|
25
|
+
`).filter(e=>e!==``).join(`
|
|
26
|
+
`).replace(/\n{3,}/g,`
|
|
27
|
+
|
|
28
|
+
`).replace(/^\n+/,``):t}function Fe(e){return!String(e??``).replace(/\u200b/g,``).trim()}function Q(e){return String(e??``).replace(/\u200b/g,``)}function Ie(e){let t=String(e??``),n=t.match(/^[ \t]*# (?!#)(.*)$/m);if(!n)return t;let r=n.index??0,i=r+n[0].length;return(t.slice(0,r)+t.slice(i)).replace(/^\n+/,``)}function Le(e){let t=String(e??``);if(!t)return[``];let n=t.split(`
|
|
29
|
+
`),r=[],i=[],a=()=>{for(;i.length&&i[i.length-1]===``;)i.pop();if(!i.length)return;let e=i.join(`
|
|
30
|
+
`);r.push(Q(e)),i=[]};for(let e=0;e<n.length;e++){let t=n[e]??``;if(t===``){i.length&&a(),r.push(``);continue}if(!t.trim()){i.length&&a();continue}if(!r.length&&!i.length&&t.trim()===`---`){let t=e+1;for(;t<n.length&&(n[t]??``).trim()!==`---`;)t+=1;if(t<n.length){let i=n.slice(e,t+1).join(`
|
|
31
|
+
`);r.push(Fe(i)?``:Q(i)),e=t;continue}}let o=/^#{1,3}\s/.test(t);o&&i.length&&a(),i.push(t),o&&a()}return i.length&&a(),r.length?r:[``]}function $(e){return(e||[]).map(e=>{let t=Q(e).replace(/[\r\n]+$/g,``);return t?t.trim()?t:``+t:``}).join(`
|
|
32
|
+
|
|
33
|
+
`)}function Re(e){let t=Le(e),n=t.findIndex(e=>/^# (?!#)/.test(String(e).trim()));return n<0?t:t.filter((e,t)=>t!==n)}function ze(e){return Object.keys(r(String(e??``))).length>0}function Be(e){let t=String(e??``);if(!Object.keys(r(t)).length)return 0;let n=t.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);return n?(n[0]??``).length:0}function Ve(e,t){if(!t)return $(e);let n=[],r=0;return e[0]&&ze(e[0])&&(n.push(e[0]),r=1),n.push(t),n.push(...e.slice(r)),$(n)}function He(e,t,n={}){let r=String(t||``),i=String(e||``);if(!r)return{body:i,insertAt:i.length};if(n.mode===`live`){let e=Le(i),t=e.findIndex(e=>/^# (?!#)/.test(String(e).trim())),a=t>=0?e[t]??null:null,o=Re(i),s=n.focusIndex;if(s==null||s<0||!o.length){let e=r.replace(/^\n+/,``).replace(/\n+$/,``);o.push(e);let t=Ve(o,a);return{body:t,insertAt:Math.max(0,t.length-e.length)}}if(s=Math.min(s,o.length-1),ze(o[s])){let e=r.replace(/^\n+/,``).replace(/\n+$/,``);s+1<o.length?o[s+1]=e+(o[s+1]?`\n${o[s+1]}`:``):o.push(e);let t=Ve(o,a);return{body:t,insertAt:Be(t)}}let c=o[s]||``,l=n.caretInBlock,u=l==null?c.length:Math.min(Math.max(0,l),c.length);o[s]=c.slice(0,u)+r+c.slice(u);let d=Ve(o,a),f=[];return a&&o[0]&&ze(o[0])?f.push(o[0],a,...o.slice(1,s)):a?f.push(a,...o.slice(0,s)):f.push(...o.slice(0,s)),{body:d,insertAt:(f.length?`${$(f)}\n\n`:``).length+u}}let a=n.insertAt;if(a==null||a<0)return{body:i+r,insertAt:i.length};a=Math.min(Math.max(0,a),i.length);let o=Be(i);return a<o&&(a=o),{body:i.slice(0,a)+r+i.slice(a),insertAt:a}}var Ue={b:`bold`,i:`italic`,e:`code`,k:`link`},We=Ne;function Ge(e){let t=String(e||``).replace(/^\uFEFF/,``).trimStart();if(t.startsWith(`---`)){let e=t.indexOf(`
|
|
34
|
+
---`,3);e>0&&(t=t.slice(e+4).trimStart())}return/^#[ \t]+\S/.test(t)}function Ke(e){e&&(e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`)}function qe(e,t){let n=Q(e);if(!n.trim())return``;let r=(t||[]).filter(e=>e?.type===`image`),i=(t||[]).filter(e=>e?.kind===`ref`);return We(n,[...r,...i]).replace(/<p class="mdw-empty">[\s\S]*?<\/p>/g,``)}function Je(e){let t=String(e||``);return/^---\s*$/.test(t.split(`
|
|
35
|
+
`,1)[0]||``)&&t.includes(`
|
|
36
|
+
`)?`fm`:/^#\s/m.test(t)&&!/^##/m.test(t)?`h1`:/^##\s/m.test(t)&&!/^###/m.test(t)?`h2`:/^###\s/m.test(t)?`h3`:/^[-*]\s/m.test(t)?`li`:/^>\s/m.test(t)?`quote`:`p`}function Ye(e){return Re(e)}function Xe({baseClass:e,skipPrevented:t=!1,onDropFiles:n}){let[r,i]=(0,J.useState)(!1);return{dragging:r,rootProps:{className:`${e}${r?` is-drop`:``}`,onDragEnter:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),i(!0))},onDragOver:e=>{[...e.dataTransfer.types].includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||i(!1)},onDrop:e=>{if(i(!1),t&&e.defaultPrevented)return;let r=W(e.dataTransfer);r.length&&(e.preventDefault(),n(r,e))}}}}function Ze({index:e,text:t,focused:n,hit:r,onFocus:i,onViewClick:a,onChange:o,onBlur:s,onKeyDown:c,onPasteFiles:l,onTaReady:u,onTextSel:d,attachments:f,pendingSelRef:p,pendingFormatRef:m}){let h=(0,J.useRef)(null),g=Q(t),_=ze(g),v=_?``:qe(g,f),y=Je(g);return(0,J.useLayoutEffect)(()=>{if(!n||!h.current)return;let t=h.current;u?.(t),Ke(t);let r=p?.current;if(r&&r.index===e){p.current=null,t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}let e=m?.current;if(e){m.current=null;let n=k(t,e);n&&o(n.value)}return}if(document.activeElement!==t){if(document.activeElement?.closest?.(`.mdw-atpick`))return;t.focus();let e=t.value.length;try{t.setSelectionRange(e,e)}catch{}}},[n,t,e,p,m,u,o]),_?null:n?(0,Y.jsx)(`div`,{className:`mdw-lp-block is-edit kind-${y}`,"data-i":e,children:(0,Y.jsx)(`textarea`,{ref:h,className:`mdw-lp-src`,value:g,rows:1,spellCheck:!1,"aria-label":`正文`,placeholder:`输入… Enter 新块 · 行首 / 命令`,onChange:e=>{o(e.target.value),Ke(e.target)},onBlur:s,onKeyDown:c,onPaste:e=>{let t=W(e.clipboardData);t.length&&(e.preventDefault(),l?.(t,h.current))},onMouseUp:e=>{let t=h.current;if(!t||t.selectionStart===t.selectionEnd)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&d?.({text:n,x:e.clientX-80,y:e.clientY-44})}})}):(0,Y.jsx)(`div`,{className:`mdw-lp-block is-view kind-${y}${Fe(t)?` is-empty`:``}${r?` is-hit`:``}`,"data-i":e,role:`button`,tabIndex:0,onClick:t=>a(t,e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e))},children:v?(0,Y.jsx)(`div`,{className:`mdw-lp-view`,dangerouslySetInnerHTML:{__html:v}}):(0,Y.jsx)(`div`,{className:`mdw-lp-gap`})})}function Qe({query:e,setQuery:t,index:n,total:r,onNext:i,onPrev:a,onClose:o,inputRef:s}){return(0,Y.jsxs)(`div`,{className:`mdw-find`,role:`search`,children:[(0,Y.jsx)(`input`,{ref:s,className:`mdw-find-input`,value:e,placeholder:`查找…`,"aria-label":`查找`,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),o();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?a():i()),e.key===`F3`&&(e.preventDefault(),e.shiftKey?a():i())}}),(0,Y.jsx)(`span`,{className:`mdw-find-count`,children:r?`${n+1}/${r}`:`无结果`}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`上一个`,"aria-label":`上一个匹配`,onClick:a,children:`↑`}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`下一个`,"aria-label":`下一个匹配`,onClick:i,children:`↓`}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-find-nav`,title:`关闭`,"aria-label":`关闭查找`,onClick:o,children:`×`})]})}function $e(e){return e.key===`ArrowDown`||e.key===`ArrowUp`||e.code===`ArrowDown`||e.code===`ArrowUp`}function et(e){if(!e?.items?.length)return 0;let t=e.active;return typeof t!=`number`||Number.isNaN(t)?0:Math.min(Math.max(0,t),e.items.length-1)}function tt(e,t,{move:n,pick:r,close:i}){let a=t.current;return a?.items?.length?$e(e)?(e.preventDefault(),e.stopPropagation(),n(e.key===`ArrowUp`||e.code===`ArrowUp`?-1:1),!0):e.key===`Enter`||e.key===`Tab`?(e.preventDefault(),e.stopPropagation(),r(a.items[et(a)]),!0):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),i(),!0):!1}function nt({items:e,active:t,onPick:n,onHover:r,style:i}){let a=(0,J.useRef)(null),o=et({items:e,active:t});return(0,J.useEffect)(()=>{let e=a.current;e&&e.querySelector(`.mdw-slash-item.on`)?.scrollIntoView?.({block:`nearest`})},[o,e]),e.length?(0,Y.jsxs)(`div`,{ref:a,className:`mdw-slash`,role:`listbox`,"aria-activedescendant":`mdw-slash-opt-${o}`,style:i,onMouseDown:e=>e.preventDefault(),children:[(0,Y.jsx)(`div`,{className:`mdw-slash-cap`,children:`插入 · ↑↓ 选择 · Enter 确认`}),e.map((e,t)=>(0,Y.jsxs)(`button`,{id:`mdw-slash-opt-${t}`,type:`button`,role:`option`,tabIndex:-1,"aria-selected":t===o,className:`mdw-slash-item${t===o?` on`:``}`,onMouseEnter:()=>r(t),onMouseDown:t=>{t.preventDefault(),n(e)},children:[(0,Y.jsx)(`span`,{className:`lab`,children:e.label}),(0,Y.jsx)(`span`,{className:`hint`,children:e.hint})]},e.id))]}):null}function rt({caret:e,stats:t,showLines:n,showRuler:r,findOpen:i,wrap:a,onToggleLines:o,onToggleRuler:s,onToggleFind:c,onToggleWrap:l}){return(0,Y.jsxs)(`div`,{className:`mdw-editor-status`,role:`status`,children:[(0,Y.jsxs)(`span`,{children:[`Ln `,e.line,`, Col `,e.col]}),(0,Y.jsxs)(`span`,{children:[t.lines,` 行`]}),(0,Y.jsxs)(`span`,{children:[t.words,` 词`]}),(0,Y.jsxs)(`span`,{children:[t.chars,` 字`]}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${n?` on`:``}`,title:`显示/隐藏行号`,onClick:o,children:`行号`}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${r?` on`:``}`,title:`80 字符参考线`,onClick:s,children:`参考线`}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${i?` on`:``}`,title:`查找 Ctrl/⌘F`,onClick:c,children:`查找`}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-wrap-toggle${a?` on`:``}`,title:a?`自动换行开(点击关闭)`:`自动换行关(点击开启)`,onClick:l,children:a?`换行`:`不换行`})]})}function it({getTa:e,positionOf:t,onApply:n}){let[r,i]=(0,J.useState)(null),a=(0,J.useRef)(null),o=(0,J.useRef)(0),s=e=>{let t=typeof e==`function`?e(a.current):e;a.current=t,i(t)};(0,J.useEffect)(()=>{a.current=r},[r]);let c=(e,n=null)=>{let r=V(e);if(!r){s(null);return}let i=H(r.query);if(!i.length){s(null);return}let{x:a,y:o}=t(e);s(e=>{let t=Object.keys(n||{}).every(t=>e?.[t]===n?.[t]),s=e&&e.query===r.query&&t?et({...e,items:i}):0;return{...n||{},query:r.query,items:i,active:s,x:a,y:o}})},l=e=>{s(t=>{if(!t?.items?.length)return t;let n=t.items.length,r=et(t);return{...t,active:(r+e+n)%n}})},u=t=>{let r=e(),i=a.current;if(!r||!t)return;let o=U(r,t);s(null),o&&n(o,i)};return(0,J.useEffect)(()=>{if(!r)return;let e=e=>{tt(e,a,{move:l,pick:u,close:()=>s(null)})};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[r]),{slash:r,slashRef:a,slashRafRef:o,setSlashBoth:s,refreshSlash:c,moveSlash:l,pickSlash:u,hoverSlash:e=>s(t=>t&&{...t,active:e})}}function at({body:e,onBody:t,articleRef:n,attachments:r,docKey:i,onFiles:a,onCloseSelMenu:o,attachHost:s}){let[c,l]=(0,J.useState)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(null),p=Ye(e),m=p.length===0||p.every(e=>!String(e).trim()),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(0),x=(0,J.useRef)(null),S=(0,J.useMemo)(()=>{let e=_.trim().toLowerCase();if(!e)return[];let t=[];return p.forEach((n,r)=>{let i=String(n??``).toLowerCase(),a=i.indexOf(e);for(;a!==-1;)t.push({block:r,start:a}),a=i.indexOf(e,a+e.length)}),t},[p,_]),C=e=>{let t=S.length;if(!t)return;let r=(e%t+t)%t;b(r);let i=S[r];i&&(n.current?.querySelector(`.mdw-lp-block[data-i="${i.block}"]`))?.scrollIntoView?.({block:`center`})},w=S[y]?.block??-1,T=e=>{v(e),b(0)},E=(0,J.useCallback)((e,n=`op`)=>t?.($(e),n),[t]),D=(e,t,n=`op`)=>{let r=p.slice();r[e]=t,E(r,n)},O=(e,t)=>{t&&(u.current={index:e,start:t.start,end:t.end},D(e,t.value))},{slash:A,slashRef:j,slashRafRef:M,setSlashBoth:N,refreshSlash:P,moveSlash:F,pickSlash:I,hoverSlash:L}=it({getTa:()=>f.current,positionOf:e=>{let t=e.getBoundingClientRect();return{x:Math.min(window.innerWidth-220,t.left),y:Math.min(window.innerHeight-220,t.bottom+4)}},onApply:(e,t)=>{let n=t?.index??c;n!=null&&O(n,e)}});(0,J.useEffect)(()=>{l(null),N(null)},[i]);let R=(0,J.useMemo)(()=>s?null:(r||[]).filter(e=>e.type===`image`).map(e=>({kind:`image`,id:e.name,name:e.name,sizeText:e.size})),[s,r]),z=we({host:s,itemsOverride:s?null:R,onInsert:({index:e,embed:t,at:n,caret:r})=>{let i=Q(p[e]??``),a=oe(t,n>0?i[n-1]:``,i[r]||``),o=i.slice(0,n)+a.text+i.slice(r),s=n+a.caretAt;D(e,o),u.current={index:e,start:s,end:s},l(e)}}),ee=e=>{let t=z.menu,n=t?{index:t.index,at:t.at,caret:t.caret}:{index:c??0,at:null,caret:null};if(t){let e=Q(p[t.index]??``);D(t.index,e.slice(0,t.at)+e.slice(t.caret))}requestAnimationFrame(()=>{a?.(e,{mode:`live`,focusIndex:n.index,...n.at==null?{}:{caretInBlock:n.at}})})},V=(e,t)=>{let n=f.current,r=B(n&&c===e?n:{value:Q(p[e]??``),selectionStart:0,selectionEnd:0},t);r&&(O(e,r),l(e))},H=(e,t)=>{e?.length&&a&&a(e,{mode:`live`,focusIndex:c,caretInBlock:t?t.selectionStart:null})},{rootProps:U}=Xe({baseClass:`mdw-lp`,onDropFiles:e=>H(e,null)});return{blocks:p,focus:c,setFocus:l,pendingSelRef:u,pendingFormatRef:d,liveTaRef:f,commit:E,updateAt:D,applyBlockOp:O,slash:A,slashRef:j,setSlashBoth:N,moveSlash:F,pickSlash:I,hoverSlash:L,findOpen:h,setFindOpen:g,findQuery:_,setLiveQuery:T,findIdx:y,liveMatches:S,jumpLive:C,hitBlock:w,findInputRef:x,picker:z,onDraftAddFiles:ee,apiBase:(0,J.useMemo)(()=>({format(e){let t=f.current;t&&c!=null&&(t.focus(),O(c,k(t,e)))},turn(e){V(c??0,e)},focus(){f.current?.focus()},openFind(){g(!0),requestAnimationFrame(()=>x.current?.focus())},formatSelection(e){let t=window.getSelection();if(!t||t.isCollapsed)return!1;let r=String(t.toString()||``);if(!r.trim())return!1;let i=t.anchorNode,a=(i?.nodeType===3?i.parentElement:i)?.closest?.(`.mdw-lp-block`);if(!a||!n.current?.contains(a))return!1;let s=Number(a.getAttribute(`data-i`));if(!Number.isInteger(s)||s<0||s>=p.length)return!1;let c=Q(p[s]??``).indexOf(r);return c!==-1&&(u.current={index:s,start:c,end:c+r.length},d.current=e,o?.(),l(s),!0)},caretFromDiff(e,t){let n=re($(Ye(e)),$(Ye(t))),r=0;for(let e=0;e<p.length;e+=1){let t=$(p.slice(0,e+1)).length;if(n<=t){let t=Math.max(0,Math.min(n-r,Q(p[e]??``).length));if(c===e){let e=f.current;e&&(e.focus(),e.setSelectionRange(t,t))}else u.current={index:e,start:t,end:t},l(e);return}r=t+2}}}),[c,p,t,o]),rootProps:U,emptyDoc:m,ingestFiles:H,onBlockFocus:e=>{l(e),N(null)},onTaReady:e=>{f.current=e},onBlockChange:(e,t)=>{D(e,t,`typing`),cancelAnimationFrame(M.current),M.current=requestAnimationFrame(()=>{let t=f.current;if(!t)return;P(t,{index:e});let n=ie(t);n?z.open({index:e,ta:t,at:n.at,caret:n.caret}):z.close()})},onBlockBlur:()=>{requestAnimationFrame(()=>{document.activeElement?.closest?.(`.mdw-lp-block.is-edit`)||document.activeElement?.closest?.(`.mdw-slash`)||document.activeElement?.closest?.(`.mdw-atpick`)||(l(null),N(null))})}}}function ot({body:e,onBody:t,editorApiRef:n,onFiles:r,onTextSel:i}){let a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(null),c=(0,J.useRef)(null),[l,u]=(0,J.useState)(!0),[d,f]=(0,J.useState)(!0),[p,m]=(0,J.useState)(!0),[h,g]=(0,J.useState)({line:1,col:1}),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(``),[x,S]=(0,J.useState)(0),C=M(e),w=te(e,y),T=e=>{e&&(c.current={start:e.start,end:e.end},t?.(e.value))},{slash:O,slashRef:A,slashRafRef:j,setSlashBoth:F,refreshSlash:I,moveSlash:L,pickSlash:R,hoverSlash:z}=it({getTa:()=>a.current,positionOf:e=>{let t=e.getBoundingClientRect(),n=N(e.value,e.selectionStart).line;return{x:Math.min(window.innerWidth-220,t.left+12),y:Math.min(window.innerHeight-220,t.top+n*20-e.scrollTop+8)}},onApply:e=>{T(e)}}),B=()=>{let e=a.current;e&&g(N(e.value,e.selectionStart))};(0,J.useLayoutEffect)(()=>{let e=c.current,t=a.current;if(e&&t){c.current=null;try{t.setSelectionRange(e.start,e.end)}catch{}}},[e]),(0,J.useEffect)(()=>{_&&(s.current?.focus(),s.current?.select())},[_]),(0,J.useEffect)(()=>{S(0)},[y,e]);let H=e=>{let t=a.current;if(!t||!w.length)return;let n=(e%w.length+w.length)%w.length;S(n);let r=w[n];if(r){t.focus();try{t.setSelectionRange(r.start,r.end)}catch{}ne(t,r.start),requestAnimationFrame(()=>s.current?.focus())}},U=()=>{v(!0);let e=a.current;if(e&&e.selectionStart!==e.selectionEnd){let t=e.value.slice(e.selectionStart,e.selectionEnd);t&&!t.includes(`
|
|
37
|
+
`)&&t.length<80&&b(t)}};(0,J.useImperativeHandle)(n,()=>({format(e){let t=a.current;t&&(t.focus(),T(k(t,e)))},turn(e){let t=a.current;t&&(t.focus(),T(ee(t,e)))},insertAtCursor(e){let t=a.current;t&&T(P(t,e))},getCursor(){let e=a.current;return e?e.selectionStart:null},caretFromDiff(e,t){let n=a.current;if(!n)return;let r=Math.min(re(e,t),n.value.length);n.focus(),n.setSelectionRange(r,r)},toggleWrap(){u(e=>!e)},getWrap:()=>l,openFind:U,focus(){a.current?.focus()}}),[t,l]);let G=e=>{if(!e?.length||!r)return;let t=a.current;r(e,{insertAt:t?t.selectionStart:null,mode:`edit`})},{rootProps:K}=Xe({baseClass:`mdw-pane mdw-pane-edit`,skipPrevented:!0,onDropFiles:e=>G(e)});return{taRef:a,gutterRef:o,wrap:l,showLines:d,showRuler:p,lineNums:d?Array.from({length:Math.max(1,C.lines)},(e,t)=>t+1):null,findOpen:_,findBarProps:{query:y,setQuery:b,index:x,total:w.length,inputRef:s,onNext:()=>H(x+1),onPrev:()=>H(x-1),onClose:()=>{v(!1),a.current?.focus()}},statusProps:{caret:h,stats:C,showLines:d,showRuler:p,findOpen:_,wrap:l,onToggleLines:()=>f(e=>!e),onToggleRuler:()=>m(e=>!e),onToggleFind:()=>_?v(!1):U(),onToggleWrap:()=>u(e=>!e)},slash:O,slashMenuProps:O?{items:O.items,active:O.active,onHover:z,onPick:R,style:{left:O.x,top:O.y}}:null,rootProps:K,ingestImages:G,focusBodyStart:()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(0,0))},onChange:e=>{t?.(e.target.value,`typing`),B(),cancelAnimationFrame(j.current),j.current=requestAnimationFrame(()=>{a.current&&I(a.current)})},onKeyDown:e=>{let t=a.current;if(!t||tt(e,A,{move:L,pick:R,close:()=>F(null)}))return;let n=e.metaKey||e.ctrlKey;if(n&&!e.altKey&&e.key.toLowerCase()===`f`){e.preventDefault(),U();return}if(e.key===`F3`){e.preventDefault(),_?e.shiftKey?H(x-1):H(x+1):U();return}if(n&&!e.altKey){let n=Ue[e.key.toLowerCase()];if(n){e.preventDefault(),T(k(t,n));return}}if(e.key===`Tab`){e.preventDefault(),T(E(t,e.shiftKey));return}if(e.key===`Enter`&&!e.shiftKey&&!n){let n=D(t);n&&(e.preventDefault(),T(n)),F(null)}},onClick:()=>{B(),V(a.current)||F(null)},onPaste:e=>{let t=W(e.clipboardData);t.length&&(e.preventDefault(),G(t))},onMouseUp:e=>{B();let t=a.current;if(!t||t.selectionStart===t.selectionEnd){i?.(null);return}let n=t.value.slice(t.selectionStart,t.selectionEnd);n&&i?.({text:n,x:e.clientX-80,y:e.clientY-44})},syncCaret:B,syncGutter:()=>{o.current&&a.current&&(o.current.scrollTop=a.current.scrollTop)}}}function st(e){let{e:t,i:n,val:r,ta:i,blocks:a,commit:o,setFocus:s,pendingSelRef:c,setSlashBoth:l,applyBlockOp:u}=e,d=D(i);if(d)return t.preventDefault(),u(n,d),!0;t.preventDefault(),l(null);let f=i.selectionStart,p=i.selectionEnd,m=r.slice(0,f).replace(/\n+$/,``),h=r.slice(p),g=a.slice();return g[n]=m,g.splice(n+1,0,h),c.current={index:n+1,start:0,end:0},o(g),s(n+1),!0}function ct(e){let{e:t,i:n,val:r,ta:i,blocks:a,commit:o,setFocus:s,pendingSelRef:c,slashRef:l,setSlashBoth:u}=e;if(Fe(r)&&n===0&&a.length>1){t.preventDefault(),u(null);let e=a.slice();return e.splice(n,1),o(e),s(0),!0}if(i.selectionStart===0&&i.selectionEnd===0&&n>0&&!l.current&&!ze(Q(a[n-1]??``))){t.preventDefault(),u(null);let e=Q(a[n-1]??``),i=a.slice();return i[n-1]=e+r,i.splice(n,1),c.current={index:n-1,start:e.length,end:e.length},o(i),s(n-1),!0}return!1}function lt(e){let{e:t,i:n,val:r,ta:i,blocks:a,commit:o,setFocus:s,pendingSelRef:c,slashRef:l,setSlashBoth:u}=e;if(i.selectionStart!==i.selectionEnd||l.current)return!1;let d=i.selectionStart,f=r.lastIndexOf(`
|
|
38
|
+
`,d-1)+1,p=r.indexOf(`
|
|
39
|
+
`,d),m=p===-1?r.length:p;if(!A(r.slice(f,m)))return!1;t.preventDefault(),u(null);let h=r.slice(0,f).replace(/\n$/,``),g=p===-1?``:r.slice(m+1),_=a.slice();return!h&&!g?(_[n]=``,c.current={index:n,start:0,end:0},o(_),s(n)):g?(_[n]=h,_.splice(n+1,0,``,g),c.current={index:n+1,start:0,end:0},o(_),s(n+1)):(_[n]=h,_.splice(n+1,0,``),c.current={index:n+1,start:0,end:0},o(_),s(n+1)),!0}function ut(e){let{e:t,i:n,val:r,ta:i,blocks:a,commit:o,setFocus:s,pendingSelRef:c,setSlashBoth:l}=e,u=i.selectionStart,d=i.selectionEnd,f=null;if(u===0&&d===0?f=n:u===r.length&&d===r.length&&(f=n+1),f==null)return!1;t.preventDefault(),l(null);let p=a.slice();return p.splice(f,0,``),c.current={index:f,start:0,end:0},o(p),s(f),!0}function dt(e){let{e:t,i:n,val:r,ta:i,blocks:a,setFocus:o,pendingSelRef:s,liveTaRef:c}=e;if(!(i.selectionStart!==i.selectionEnd||t.shiftKey||t.altKey)){if(t.key===`ArrowUp`&&i.selectionStart===0&&n>0){t.preventDefault();let e=Q(a[n-1]??``).length;s.current={index:n-1,start:e,end:e},o(n-1);return}if(t.key===`ArrowDown`&&i.selectionEnd===r.length&&n<a.length-1){t.preventDefault(),s.current={index:n+1,start:0,end:0},o(n+1);return}if(t.key===`ArrowUp`||t.key===`ArrowDown`){let e={start:i.selectionStart,end:i.selectionEnd},r=t.key;requestAnimationFrame(()=>{let t=c.current;if(!t||t!==document.activeElement||t.selectionStart!==e.start||t.selectionEnd!==e.end)return;let i=Q(a[n]??``).length;if(r===`ArrowUp`&&e.start>0&&n>0){let e=Q(a[n-1]??``).length;s.current={index:n-1,start:e,end:e},o(n-1)}else r===`ArrowDown`&&e.end<i&&n<a.length-1&&(s.current={index:n+1,start:0,end:0},o(n+1))})}}}function ft(e){if(e.altKey||!(e.metaKey||e.ctrlKey)||e.repeat||e.isComposing||e.keyCode===229)return null;let t=String(e.key||``).toLowerCase();return t.length===1?t:null}function pt(e=400){let t=new Map;return(n,r=Date.now())=>{let i=t.get(n);return i!=null&&r-i<e?!1:(t.set(n,r),!0)}}function mt(e){return!e||typeof e==`function`?null:e}var ht=(0,J.forwardRef)(function({mode:e,title:t=``,body:n=``,previewHtml:r=``,onTitle:i,onBody:a,attachments:o=[],docKey:s=`draft`,editorApiRef:c=null,onFiles:l=null,onTextSel:u=null,onSave:d=null,onUndo:f=null,onRedo:p=null,onCloseSelMenu:m=null,hideTitle:h=!1,attachHost:g=null},_){let v=(0,J.useRef)(null),y=c??v,b=(0,J.useRef)(null),x=mt(_)??b,S=(0,J.useRef)(pt());return(0,J.useEffect)(()=>{let t=t=>{let n=ft(t);if(!n)return;let r=t.target;if(!r||typeof r.closest!=`function`)return;let i=r.closest(`.mdw-editor,.mdw-lp-src,.mdw-lp-title,.mdw-title-input`);if(n===`f`&&e!==`edit`){if(!r.closest(`.mdw`))return;t.preventDefault(),y.current?.openFind?.();return}if(!i){let r=Ue[n];e===`split`&&r&&y.current?.formatSelection?.(r)&&t.preventDefault();return}if(n===`s`){if(t.preventDefault(),!S.current(`save`,Date.now()))return;d?.();return}if(n===`z`){let e=t.shiftKey?p:f;if(!e)return;t.preventDefault(),e();return}if(n===`y`){if(!p)return;t.preventDefault(),p()}};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[d,f,p,e,c]),e===`edit`?(0,Y.jsx)(`div`,{className:`mdw-split mode-edit`,children:(0,Y.jsx)(yt,{title:t,body:n,onTitle:i,onBody:a,editorApiRef:y,onFiles:l,onTextSel:u})}):!a&&!i?(0,Y.jsx)(`div`,{className:`mdw-split mode-read`,children:(0,Y.jsx)(`div`,{className:`mdw-pane mdw-preview`,children:(0,Y.jsxs)(`div`,{className:`mdw-reader`,children:[t&&!Ge(n)?(0,Y.jsx)(`h1`,{className:`mdw-reader-title`,children:t}):null,(0,Y.jsx)(`article`,{ref:_,dangerouslySetInnerHTML:{__html:r}})]})})}):(0,Y.jsx)(`div`,{className:`mdw-split mode-split live`,children:(0,Y.jsx)(vt,{title:t,body:n,onTitle:i,onBody:a,articleRef:x,attachments:o,docKey:s,onFiles:l,editorApiRef:y,onTextSel:u,onCloseSelMenu:m,hideTitle:h,attachHost:g})})}),gt=c();function _t({value:e,onTitle:t,placeholder:n,className:r,onFocus:i,onEnter:a}){let o=(0,J.useRef)(null);return(0,J.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`};t();let n=null;return typeof ResizeObserver<`u`?(n=new ResizeObserver(()=>t()),n.observe(e)):window.addEventListener(`resize`,t),()=>{n?n.disconnect():window.removeEventListener(`resize`,t)}},[e]),(0,Y.jsx)(`textarea`,{ref:o,className:r,value:e,placeholder:n,rows:1,spellCheck:!1,"aria-label":`标题`,onChange:e=>t?.(e.target.value,`typing`),onFocus:i,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),a?.())}})}function vt({title:e,body:t,onTitle:n,onBody:r,articleRef:i,attachments:a,docKey:o,onFiles:s,editorApiRef:c,onTextSel:l,onCloseSelMenu:u,hideTitle:d=!1,attachHost:f=null}){let{blocks:p,focus:m,setFocus:h,pendingSelRef:g,pendingFormatRef:_,liveTaRef:v,commit:y,updateAt:b,applyBlockOp:x,slash:S,slashRef:C,setSlashBoth:w,moveSlash:T,pickSlash:D,hoverSlash:O,findOpen:A,setFindOpen:M,findQuery:N,setLiveQuery:P,findIdx:F,liveMatches:I,jumpLive:L,hitBlock:R,findInputRef:z,picker:B,onDraftAddFiles:ee,apiBase:V,rootProps:H,emptyDoc:U,ingestFiles:te,onBlockFocus:ne,onTaReady:W,onBlockChange:re,onBlockBlur:G}=at({body:t,onBody:r,articleRef:i,attachments:a,docKey:o,onFiles:s,onCloseSelMenu:u,attachHost:f}),K=(0,J.useCallback)((e,t)=>{if(!Number.isInteger(e)||!Number.isInteger(t)||e<0||t<e||t>=p.length)return!1;let n=p.slice();n.splice(e,t-e+1),y(n);let r=Math.min(e,Math.max(0,n.length-1));return g.current={index:r,start:0,end:0},h(r),!0},[p,y]);(0,J.useImperativeHandle)(c,()=>({...V,deleteBlockRange(e,t){return K(e,t)}}),[V,K]),(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Backspace`&&e.key!==`Delete`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(t&&(t.tagName===`TEXTAREA`||t.tagName===`INPUT`||t.isContentEditable))return;let n=window.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return;let r=String(n.toString()||``);if(!r.trim())return;let a=e=>e?.nodeType===3?e.parentElement:e,o=a(n.anchorNode)?.closest?.(`.mdw-lp-block`);if(!o||!i.current?.contains(o))return;let s=Number(o.getAttribute(`data-i`));if(!Number.isInteger(s)||s<0||s>=p.length)return;let c=a(n.focusNode)?.closest?.(`.mdw-lp-block`);if(c&&c!==o&&i.current?.contains(c)){let t=Number(c.getAttribute(`data-i`));Number.isInteger(t)&&t>=0&&t<p.length&&t!==s&&(e.preventDefault(),K(Math.min(s,t),Math.max(s,t)),u?.());return}let l=Q(p[s]??``),d=l.indexOf(r);d!==-1&&(e.preventDefault(),b(s,l.slice(0,d)+l.slice(d+r.length)),g.current={index:s,start:d,end:d},u?.(),h(s))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[p,r,i,u,K]);let q=(e,t)=>{let n=j(Q(p[e]??``),t);n&&b(e,n)},ie=(e,t)=>{let n=e.target.closest?.(`.mdw-cb`);if(n){e.stopPropagation();let r=[...e.currentTarget.querySelectorAll(`.mdw-cb`)];q?.(t,r.indexOf(n));return}let r=window.getSelection();r&&!r.isCollapsed&&String(r).trim()||ne(t)},ae=(e,t)=>{let n=Q(p[e]??``),r=t.target;if(v.current=r,t.nativeEvent?.isComposing||t.keyCode===229||tt(t,C,{move:T,pick:D,close:()=>w(null)}))return;if(t.key===`Escape`){t.preventDefault(),w(null),r.blur(),h(null);return}let i=t.metaKey||t.ctrlKey;if(i&&!t.altKey){let n=Ue[t.key.toLowerCase()];if(n){t.preventDefault(),x(e,k(r,n));return}}if(t.key===`Tab`){t.preventDefault(),x(e,E(r,t.shiftKey));return}let a={e:t,i:e,val:n,ta:r,blocks:p,commit:y,setFocus:h,pendingSelRef:g,slashRef:C,liveTaRef:v,setSlashBoth:w,applyBlockOp:x};if((t.key!==`Enter`||t.shiftKey||i||!st(a))&&!(t.key===`Backspace`&&ct(a))&&!(t.key===`Backspace`&<(a))){if(t.key===`Delete`&&r.selectionStart===n.length&&r.selectionEnd===n.length&&e<p.length-1&&!C.current&&!ze(Q(p[e+1]??``))){t.preventDefault(),w(null);let r=Q(p[e+1]??``),i=p.slice();i[e]=n+r,i.splice(e+1,1),g.current={index:e,start:n.length,end:n.length},y(i),h(e);return}(t.key!==`Enter`||!t.shiftKey||i||C.current||!ut(a))&&(C.current||dt(a))}};return(0,Y.jsxs)(`div`,{...H,children:[(0,Y.jsxs)(`div`,{className:`mdw-lp-sheet`,ref:i,children:[A&&(0,Y.jsx)(Qe,{query:N,setQuery:P,index:F,total:I.length,onNext:()=>L(F+1),onPrev:()=>L(F-1),onClose:()=>M(!1),inputRef:z}),!d&&(0,Y.jsx)(_t,{className:`mdw-lp-title`,value:e,placeholder:`无标题`,onTitle:n,onFocus:()=>{h(null),w(null)},onEnter:()=>{p.length&&h(0)}}),(0,Y.jsx)(`div`,{className:`mdw-lp-blocks${U?` is-empty-doc`:``}`,children:p.map((e,t)=>(0,Y.jsx)(Ze,{index:t,text:e,focused:m===t,hit:R===t,attachments:a,pendingSelRef:g,pendingFormatRef:_,onFocus:ne,onViewClick:ie,onTaReady:W,onChange:e=>re(t,e),onBlur:G,onKeyDown:e=>ae(t,e),onPasteFiles:(e,t)=>te(e,t),onTextSel:l},`${o}-${t}`))}),U&&m===null?(0,Y.jsx)(`button`,{type:`button`,className:`mdw-lp-add is-empty-hint`,"aria-label":`开始输入`,onClick:()=>h(0),children:(0,Y.jsx)(`span`,{className:`mdw-lp-add-hint`,children:`输入正文,或键入 / 唤起命令…`})}):(0,Y.jsx)(`button`,{type:`button`,className:`mdw-lp-add`,"aria-label":`继续输入`,onClick:()=>{y([...p,``]),h(p.length)}})]}),S&&(0,gt.createPortal)((0,Y.jsx)(nt,{items:S.items,active:S.active,onHover:O,onPick:D,style:{left:S.x,top:S.y}}),document.body),B.menu&&(0,gt.createPortal)((0,Y.jsx)(Te,{items:B.items,query:B.menu.query,onQuery:B.setQuery,active:B.active,onHover:B.move,onPick:B.pick,loading:B.menu.loading,error:B.menu.error,position:{left:B.menu.x,top:B.menu.y},host:f,onReload:B.reload,onAddFiles:f?null:ee}),document.body)]})}function yt({title:e,body:t,onTitle:n,onBody:r,editorApiRef:i,onFiles:a,onTextSel:o}){let s=ot({body:t,onBody:r,editorApiRef:i,onFiles:a,onTextSel:o}),{ingestImages:c}=s,l=e=>{e.nativeEvent?.isComposing||e.keyCode===229||s.onKeyDown(e)};return(0,Y.jsxs)(`div`,{...s.rootProps,children:[(0,Y.jsx)(_t,{className:`mdw-title-input`,value:e,placeholder:`任务标题`,onTitle:n,onEnter:s.focusBodyStart}),s.findOpen&&(0,Y.jsx)(Qe,{...s.findBarProps}),(0,Y.jsxs)(`div`,{className:`mdw-editor-row${s.showLines?` has-gutter`:``}${s.showRuler?` has-ruler`:``}`,children:[s.showLines&&(0,Y.jsx)(`div`,{className:`mdw-gutter`,ref:s.gutterRef,"aria-hidden":!0,children:(s.lineNums||[]).map(e=>(0,Y.jsx)(`div`,{className:`mdw-gutter-ln`,children:e},e))}),(0,Y.jsxs)(`div`,{className:`mdw-editor-stage`,children:[s.showRuler&&(0,Y.jsx)(`div`,{className:`mdw-ruler`,"aria-hidden":!0,title:`约 80 字符参考`}),(0,Y.jsx)(`textarea`,{ref:s.taRef,className:`mdw-editor${s.wrap?` is-wrap`:` is-nowrap`}`,value:t,spellCheck:!1,wrap:s.wrap?`soft`:`off`,"aria-label":`正文源码`,placeholder:`用 Markdown 写任务——行首 / 出命令 · Ctrl/⌘F 查找 · Ctrl/⌘B 粗体`,onChange:s.onChange,onKeyDown:l,onKeyUp:s.syncCaret,onClick:s.onClick,onSelect:s.syncCaret,onScroll:s.syncGutter,onPaste:s.onPaste,onDrop:e=>{let t=W(e.dataTransfer);t.length&&(e.preventDefault(),c(t))},onMouseUp:s.onMouseUp})]})]}),(0,Y.jsx)(rt,{...s.statusProps}),s.slash&&s.slashMenuProps&&(0,gt.createPortal)((0,Y.jsx)(nt,{...s.slashMenuProps}),document.body)]})}var bt=700;function xt(e,t,n,r=`op`){if(!t)return;let i=e.get(t)??{past:[],future:[],lastAt:0},a=Date.now(),o=r===`typing`;o&&a-i.lastAt<bt&&i.past.length>0||(i.past.push(n),i.past.length>200&&i.past.shift()),i.future=[],i.lastAt=o?a:0,e.set(t,i)}function St(e,t,n){if(!t)return null;let r=e.get(t);if(!r||!r.past.length)return null;let i=r.past.pop();return r.future.unshift(n),r.future.length>200&&r.future.pop(),r.lastAt=0,i??null}function Ct(e,t,n){if(!t)return null;let r=e.get(t);if(!r||!r.future.length)return null;let i=r.future.shift();return r.past.push(n),r.lastAt=0,i??null}function wt(e,t){t&&e.delete(t)}export{_ as C,b as S,me as _,ht as a,h as b,Pe as c,Ne as d,De as f,he as g,ge as h,St as i,Ie as l,de as m,xt as n,He as o,Ce as p,Ct as r,Re as s,wt as t,ke as u,d as v,g as x,y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,m as r,p as i,y as a}from"./frontmatter-DEIM0yF2.js";import{a as o}from"./workspace-C0PPPfA1.js";import{n as s}from"./app-context-CR7f0AtI.js";import{c,l,n as u,o as ee,s as d}from"./doc-
|
|
1
|
+
import{C as e,_ as t,b as n,m as r,p as i,y as a}from"./frontmatter-DEIM0yF2.js";import{a as o}from"./workspace-C0PPPfA1.js";import{n as s}from"./app-context-CR7f0AtI.js";import{c,l,n as u,o as ee,s as d}from"./doc-CKkCGsZ4.js";function f(e){return e.title||e.summary||e.desc||`未命名文档`}function p(e){let t=String(e.desc||``).trim();return t&&t!==f(e)?t:``}function m(e){let t={all:0,repo:0,group:0,group_repo:0};for(let n of e||[])t.all+=1,(n.type===`repo`||n.type===`group`||n.type===`group_repo`)&&(t[n.type]+=1);return t}function te(e,t){let n=e||[];return t===`all`?n:n.filter(e=>e.type===t)}function h(e){return e===`repo`||e===`group`||e===`group_repo`?e:`all`}function g(e){return String(e||``).replace(/\\/g,`/`).replace(/\/+$/,``).toLowerCase()}function _(e,t){return(e||[]).find(e=>String(e.id||``)===t||String(e.key||``)===t||String(e.name||``).toLowerCase()===t.toLowerCase())}function v(e,t,n,r){if(!e)return{kind:`idle`};let i=n||[];if(e.view===`dir`&&e.key){let n=(t||[]).find(t=>t.key===e.key),r=String(n?.repo?.key||``).trim(),a=r?i.find(e=>String(e.key||``)===r):void 0,o=g(n?.cwd),s=o?i.find(e=>g(e.path)===o):void 0,c=a||s;return c?{kind:`host`,repoKey:String(c.key||``),name:String(c.name||``)}:{kind:`none`}}if(e.view===`group`&&e.key){let t=String(e.key),n=_(r,t);return n?{kind:`host`,groupKey:String(n.key||t),name:String(n.name||t)}:{kind:`host`,groupKey:t,name:t}}if(e.view===`doc`){let t=String(e.repoKey||``).trim(),n=String(e.boardKey||``).trim();if(t){let e=i.find(e=>String(e.key||``)===t);return{kind:`host`,repoKey:t,name:String(e?.name||t)}}return n?{kind:`host`,groupKey:n,name:String(e.boardName||n)}:{kind:`idle`}}return{kind:`idle`}}var y=e(n(),1),b=a();function x(e,t,n){return e.type===`repo`?e.hostKind===`ref`?[{cls:`ref`,text:`参考 · ${t(e.repoKey)}`}]:[{cls:`repo`,text:`仓库 · ${t(e.repoKey)}`}]:e.type===`group`?[{cls:`group`,text:`组 · ${n(e.repoKey)}`}]:[{cls:`group`,text:`组 · ${n(e.groupKey||``)}`},{cls:`repo`,text:`仓库 · ${t(e.repoKey)}`}]}function S({repoKey:e,repoName:n,boardKey:a,boardName:g,scope:_,model:S}){let C=s(),w=t(),{dialog:T,node:E}=i(),{openByDocId:D}=u(S),O=(0,y.useMemo)(()=>v(C.route,C.rows,C.repoData?.repos||[],C.repoData?.boards||[]),[C.route,C.rows,C.repoData]),[k,A]=(0,y.useState)(()=>e?{repoKey:e}:a?{groupKey:a,name:g}:null);(0,y.useEffect)(()=>{O.kind===`host`?A({repoKey:O.repoKey,groupKey:O.groupKey,name:O.name}):O.kind===`none`&&A(null)},[O]),(0,y.useEffect)(()=>{O.kind===`idle`&&(e?A({repoKey:e}):a&&A({groupKey:a,name:g}))},[e,a,g,O.kind]);let j=O.kind===`host`?O:O.kind===`none`?null:k,M=j?.repoKey,N=j?.groupKey,P=(0,y.useMemo)(()=>{let e=String(N||``);return(C.repoData?.boards||[]).find(t=>t.id===e||t.key===e||String(t.name||``).toLowerCase()===e.toLowerCase())?.key||e},[C.repoData,N]),F=(0,y.useMemo)(()=>M?(C.repoData?.repos||[]).find(e=>e.key===M)?.name||n||String(M).split(`/`).pop()||M:j?.groupKey&&j.name?j.name:g||P.replace(/^group\//,``)||`项目组`,[C.repoData,M,n,g,P,j]),ne=(0,y.useCallback)(e=>(C.repoData?.repos||[]).find(t=>t.key===e)?.name||String(e||``).split(`/`).pop()||e||`未知仓库`,[C.repoData]),re=(0,y.useCallback)(e=>{let t=String(e||``),n=t.replace(/^(board|group)\//,``);return(C.repoData?.boards||[]).find(e=>{let r=String(e.key||``);return r===t||r.replace(/^(board|group)\//,``)===n||String(e.name||``)===n})?.name||n||`未知组`},[C.repoData]),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(0),[H,U]=(0,y.useState)(()=>h(_));(0,y.useEffect)(()=>{U(h(_))},[_]);let W=(0,y.useCallback)(()=>V(e=>e+1),[]);(0,y.useEffect)(()=>{let e=!0;return z(``),(async()=>{try{let t=M?await l({host:M}):await l({group:P});e&&L(t.bindings||[])}catch(t){e&&(L([]),z(String(t.message||t)))}})(),()=>{e=!1}},[M,P,B]),(0,y.useEffect)(()=>c(W),[W]);let G=M?{repoKey:M}:{boardKey:P,boardName:F},K=e=>D(`ref:`+e,null,G),q=e=>e().catch(e=>w(String(e.message||e))),J=()=>q(async()=>{if(!M&&!P)return;let e=M&&P?`group_repo`:M?`repo`:`group`,t=await ee({owner:e,repo:M,group:e===`repo`?void 0:P,desc:``});w(`已新建文档`),W(),K(t)}),Y=e=>q(async()=>{let t=f(e);await T({message:`从「${t}」摘除?只解除归属,文档不删。`,danger:!0})&&(await d(e),w(`已摘除归属`),W())}),X=!!(M||P),Z=(0,y.useMemo)(()=>m(I),[I]),Q=(0,y.useMemo)(()=>te(I,H),[I,H]),$=Q.length;return(0,b.jsxs)(`div`,{className:`nx-refs`,children:[(0,b.jsxs)(`div`,{className:`nx-refs-h`,children:[(0,b.jsxs)(`span`,{className:`t`,title:F,children:[F,` · 文档列表`]}),(0,b.jsx)(`span`,{className:`nx-refs-count`,children:$?`${$} 篇`:``}),X&&(0,b.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`新建文档(直接编辑)`,"aria-label":`新建文档`,onClick:J,children:`+`}),(0,b.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`刷新`,"aria-label":`刷新文档列表`,onClick:W,children:(0,b.jsx)(r,{name:`refresh`,size:13,title:void 0})}),S&&(0,b.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭文档列表面板`,"aria-label":`关闭文档列表面板`,onClick:()=>o(S,`refs`),children:(0,b.jsx)(r,{name:`x`,size:14,title:void 0})})]}),I&&(Z.repo+Z.group+Z.group_repo>1||H!==`all`)?(0,b.jsx)(`div`,{className:`nx-refs-scopes`,role:`tablist`,"aria-label":`按归属筛选文档`,children:[[`all`,`全部`,Z.all],[`repo`,`仓库`,Z.repo],[`group`,`组`,Z.group],[`group_repo`,`组内`,Z.group_repo]].map(([e,t,n])=>n>0||e===`all`?(0,b.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":H===e,className:`nx-refs-scope-filter`+(H===e?` on`:``),onClick:()=>U(e),children:[t,` `,(0,b.jsx)(`b`,{children:n})]},e):null)}):null,(0,b.jsxs)(`div`,{className:`nx-refs-list`,children:[R?(0,b.jsx)(`div`,{className:`nx-refs-empty`,children:R}):null,!R&&!I?(0,b.jsx)(`div`,{className:`nx-refs-empty`,children:`读取中…`}):null,!R&&I&&!Q.length?(0,b.jsxs)(`div`,{className:`nx-refs-empty`,children:[`还没有文档`,(0,b.jsx)(`br`,{}),X?`点右上角「+」新建,建完直接编辑`:O.kind===`none`?`当前打开的目录还没登记为本机仓库:nx-kv repo add "<目录>" --key <key> 之后才有文档列表`:`这个宿主还没有可挂的文档`]}):null,Q.map(e=>{let t=f(e),n=p(e),r=x(e,ne,re);return(0,b.jsxs)(`div`,{className:`nx-refs-row-wrap`+(e.main?` main`:``),children:[(0,b.jsxs)(`button`,{type:`button`,className:`nx-refs-row`,title:`${[t,n,e.note].filter(Boolean).join(`
|
|
2
2
|
`)}\n点击打开(可编辑)`,onClick:()=>K(e.refId),children:[(0,b.jsxs)(`span`,{className:`nx-refs-row-label`,children:[(0,b.jsx)(`span`,{className:`nx-refs-row-badges`,children:r.map((e,t)=>(0,b.jsx)(`span`,{className:`nx-refs-scope ${e.cls}`,children:e.text},`${e.cls}:${t}`))}),(0,b.jsx)(`span`,{className:`nx-refs-row-text`,children:t})]}),n&&(0,b.jsx)(`span`,{className:`nx-refs-row-desc`,children:n}),e.note&&(0,b.jsxs)(`span`,{className:`nx-refs-row-sub`,children:[`备注:`,e.note]})]}),(0,b.jsx)(`span`,{className:`nx-refs-row-acts`,children:(0,b.jsx)(`button`,{type:`button`,className:`nx-refs-mini danger`,title:`解绑归属(文档不删)`,onClick:()=>Y(e),children:`×`})})]},`${e.type}:${e.repoKey}:${e.groupKey||``}:${e.refId}`)})]}),(0,b.jsx)(`div`,{className:`nx-refs-note`,children:`点一行打开文档(编辑 / 保存在那一页);× 摘除归属,不删文档。`}),E]})}export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,g as r,p as i,u as a,v as o,y as s}from"./frontmatter-DEIM0yF2.js";import{n as c}from"./doc-
|
|
1
|
+
import{C as e,_ as t,b as n,g as r,p as i,u as a,v as o,y as s}from"./frontmatter-DEIM0yF2.js";import{n as c}from"./doc-CKkCGsZ4.js";var l=e(n(),1),u=s();function d({text:e,className:n=``,title:r,children:i}){let a=t();return(0,u.jsx)(`span`,{className:`copyable`+(n?` `+n:``),title:r||`点击复制`,onClick:async()=>{let t=String(e??``);try{await navigator.clipboard.writeText(t),a(`已复制: `+(t.length>60?t.slice(0,57)+`...`:t))}catch{try{let e=document.createElement(`textarea`);e.value=t,e.style.cssText=`position:fixed;opacity:0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),e.remove(),a(`已复制: `+(t.length>60?t.slice(0,57)+`...`:t))}catch{a(`复制失败(剪贴板不可用)`)}}},children:i===void 0?e:i})}var f=class extends l.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[nx-kv] 视图渲染失败:`,e,t)}render(){return this.state.error?(0,u.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,u.jsx)(`div`,{className:`colhead`,children:(0,u.jsx)(`h3`,{children:`这个面板出错了`})}),(0,u.jsx)(`div`,{style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`,marginBottom:10},children:String(this.state.error?.message||this.state.error)}),(0,u.jsx)(`div`,{className:`muted`,style:{marginBottom:10},children:`其他面板不受影响,可以切到别的 tab 继续操作;控制台有完整堆栈。`}),(0,u.jsx)(`button`,{className:`btn`,onClick:()=>this.setState({error:null}),children:`重试`})]}):this.props.children}};function p(){return o(`/api/repos`)}function m(){return o(`/api/boards`)}function h(){return o(`/api/repos/ref/check`)}function g(){return o(`/api/setting`)}function _(e){return o(`/api/setting`,{method:`POST`,body:e})}function v(e){return o(`/api/repos/remote/list?id=`+encodeURIComponent(e))}function y(e,t){return o(`/api/repos/remote/check?id=`+encodeURIComponent(e)+(t?`&url=`+encodeURIComponent(t):``))}function b(e){return o(`/api/repos/bind`,{method:`POST`,body:e})}function x(e){return o(`/api/repos/ref/note`,{method:`POST`,body:e})}function S(e){return o(`/api/repos/ref/sync`,{method:`POST`,body:e})}function C(e){return o(`/api/repos/ref/clone`,{method:`POST`,body:e})}function w(e,t){return o(`/api/boards/${encodeURIComponent(e)}`,{method:`PATCH`,body:t})}function T(e){return o(`/api/boards`,{method:`POST`,body:e})}function E(e){return o(`/api/boards/${encodeURIComponent(e)}`,{method:`DELETE`,body:{}})}function D(e){return o(`/api/boards/import`,{method:`POST`,body:e})}function O(){return o(`/api/boards/export`)}function k(e){return o(`/api/boards/rekey`,{method:`POST`,body:e})}function A(e){return o(`/api/boards/assign`,{method:`POST`,body:e})}function j(e){return o(`/api/boards/prune`,{method:`POST`,body:e})}function M(e){return o(`/api/repos`,{method:`POST`,body:e})}function N(e,t){return o(`/api/repos/${encodeURIComponent(e)}`,{method:`PATCH`,body:t})}function P(e){return o(`/api/repos/${encodeURIComponent(e)}`,{method:`DELETE`})}function F(e){return o(`/api/repos/detect`,{method:`POST`,body:e})}function I(e){return o(`/api/repos/open`,{method:`POST`,body:e})}function L(e){return o(`/api/repos/clone`,{method:`POST`,body:e})}function R(e){return o(`/api/repos/remote/pick`,{method:`POST`,body:e})}function z(){return o(`/api/docs`)}function B(){return o(`/api/docs/bindings`)}function V(e){return o(`/api/docs/item`,{method:`DELETE`,body:e})}var H={primary:``,secondary:`ghost`};function U({variant:e=`secondary`,danger:t=!1,small:n=!1,className:r=``,type:i=`button`,children:a,...o}){let s=[`btn`],c=H[e]??`ghost`;return c&&s.push(c),t&&s.push(`danger`),n&&s.push(`small`),r&&s.push(r),(0,u.jsx)(`button`,{type:i,className:s.join(` `),...o,children:a})}function W(e){return String(e||``).trim().replace(/\s+/g,`-`).replace(/[<>:"\\|?*\x00-\x1f]/g,`-`).replace(/\.git$/i,``).replace(/\/{2,}/g,`/`).replace(/^\/+|\/+$/g,``).slice(0,160).toLowerCase()}function G(e){let t=String(e||``).trim();if(!t)return``;t=t.replace(/\/+$/,``);let n=/^git@([^:/]+):(.+)$/i.exec(t);n?t=`${n[1]??``}/${n[2]??``}`:/^[a-z][a-z0-9+.-]*:\/\//i.test(t)&&(t=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``),t=t.replace(/^[^/]*@/,``),t=t.replace(/^([^/]+?):\d+(\/|$)/,`$1$2`),t=t.replace(/^([a-z]):/i,`$1`)),t=t.replace(/\.git$/i,``),t=t.replace(/\/{2,}/g,`/`);let r={"ssh.github.com":`github.com`,"www.github.com":`github.com`},i=t.indexOf(`/`);if(i>0){let e=t.slice(0,i).toLowerCase();t=(r[e]||e)+t.slice(i)}return t=t.replace(/^\/+|\/+$/g,``),t.toLowerCase()}var K={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``,key:``,icon:``};function q({editing:e,repos:n,onClose:o,onSaved:s}){let d=r(),f=t(),{dialog:p,node:m}=i(),{openByDocId:h}=c(),g=(0,l.useMemo)(()=>e&&n.find(t=>t.id===e)||null,[e,n]),[_,v]=(0,l.useState)(()=>g?{path:g.path||``,name:g.name||``,desc:g.desc||``,type:g.type||`dev`,remote:g.remote||``,notes:g.notes||``,key:g.key||``,icon:g.icon||``}:K),[y,b]=(0,l.useState)(()=>g?g.keyCustom===!0:!1),[x,S]=(0,l.useState)(null),[C,w]=(0,l.useState)(()=>!!g);(0,l.useEffect)(()=>{let e=_.path.trim();if(!e){S(null);return}let t=!0,n=setTimeout(async()=>{S({loading:!0});try{let n=await F({path:e});if(!t)return;S({loading:!1,...n}),n.recommended&&!C&&v(e=>({...e,remote:n.recommended,key:y?e.key:n.key||e.key}))}catch(e){t&&S({loading:!1,error:e.message})}},400);return()=>{t=!1,clearTimeout(n)}},[_.path,C,y]);let T=e=>t=>v(n=>({...n,[e]:t.target.value})),E=e=>{let t=e.target.value;w(!0),S(null),v(e=>({...e,remote:t,key:y?e.key:G(t)}))},D=e=>{b(!0),v(t=>({...t,key:e.target.value}))},O=g&&g.descDocs||null;return(0,u.jsxs)(a,{title:e?`编辑仓库 · ${e}`:`添加仓库`,onClose:o,children:[(0,u.jsxs)(`div`,{className:`form-grid`,children:[(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-path`,children:`仓库绝对路径 *`}),(0,u.jsx)(`input`,{id:`repo-path`,placeholder:`D:/code/my-project`,spellCheck:`false`,value:_.path,onChange:T(`path`)})]}),(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-name`,children:`名称`}),(0,u.jsx)(`input`,{id:`repo-name`,placeholder:`留空则用目录末段`,value:_.name,onChange:T(`name`)})]}),(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-icon`,children:`图标`}),(0,u.jsx)(`input`,{id:`repo-icon`,maxLength:8,placeholder:`emoji 或单字符(留空 = 默认文件夹图标)`,value:_.icon,onChange:T(`icon`)})]}),O?(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{children:`项目描述(文档)`}),(0,u.jsxs)(`div`,{className:`rp-docpick`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`rp-doc`,onClick:()=>{o(),h(O.main?.docId)},children:[O.main?.title,O.main?.exists?null:(0,u.jsx)(`span`,{className:`rp-doc-todo`,children:`未写`})]}),(O.links||[]).length?(0,u.jsxs)(`span`,{className:`muted`,children:[`另有 `,(O.links||[]).length,` 篇补充文档`]}):null]})]}):null,(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-type`,children:`类型`}),(0,u.jsxs)(`select`,{id:`repo-type`,value:_.type,onChange:T(`type`),children:[(0,u.jsx)(`option`,{value:`dev`,children:`开发仓库(本机开发的)`}),(0,u.jsx)(`option`,{value:`ref`,children:`参考仓库(远程 clone 下来的)`})]})]}),(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-remote`,children:`远程 git 地址`}),(0,u.jsx)(`input`,{id:`repo-remote`,spellCheck:`false`,placeholder:`https://github.com/me/x.git(导出时导它,不含本地路径)`,value:_.remote,onChange:E}),x?(0,u.jsx)(`div`,{className:`form-hint`,children:x.loading?`正在从目录读取 git remote…`:x.error?`读取 git remote 失败:${x.error}`:x.recommended?`已按目录 git remote 自动填入${(x.remotes||[]).length>1?`(另有 ${(x.remotes||[]).length-1} 条候选)`:``}`:x.exists===!1?`该路径不存在 —— 请检查后重填`:x.isGit?`目录是 git 仓库,但没有配置 remote —— 请手工填写`:`目录不是 git 仓库 —— 请手工填写`}):null,(0,u.jsx)(`div`,{className:`form-hint`,children:`有远程地址时,下面的 key 会按它自动归一化:ssh / https / 带 .git / 带 user 的写法 都归一成 host/owner/repo(如 github.com/on-devplan/nx-kv)。`})]}),(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-key`,children:`仓库 key *(全局唯一身份)`}),(0,u.jsx)(`input`,{id:`repo-key`,spellCheck:`false`,placeholder:`github.com/on-devplan/nx-kv`,value:_.key,onChange:D}),(0,u.jsx)(`div`,{className:`form-hint`,children:`没有远程地址时必须手工填写;已有仓库可查看,改 key 会波及引用它的队列 / 看板 / 关系。`})]}),(0,u.jsxs)(`div`,{className:`form-field`,children:[(0,u.jsx)(`label`,{htmlFor:`repo-notes`,children:`备注`}),(0,u.jsx)(`textarea`,{id:`repo-notes`,placeholder:`补充信息(可选)`,value:_.notes,onChange:T(`notes`)})]}),(0,u.jsxs)(`div`,{className:`form-acts`,children:[(0,u.jsx)(U,{onClick:o,children:`取消`}),(0,u.jsx)(U,{disabled:!_.path.trim()||!_.key.trim()&&!_.remote.trim(),onClick:()=>d(async()=>{if(!_.path.trim())return;let t=_.remote.trim(),n=_.key.trim(),r=n?W(n):G(t);if(!r){f(`仓库 key 必填:没有远程 git 地址时必须手工填写 key(不会再自动生成 local/<目录名>)`);return}let i={path:_.path.trim(),name:_.name.trim()||void 0,notes:_.notes,type:_.type===`ref`?`ref`:`dev`,remote:t||void 0,icon:_.icon.trim()};if(e){let e=g&&g.key||``;if(y&&n===``){if(!t){f(`清空自定义 key 需要仓库有远程地址(否则 key 必填)`);return}i.key=``,i.keyCustom=!1}else if(y&&r!==e){if(!await p({title:`修改仓库 key`,message:`key 是仓库身份,改掉会连锁影响:\n\n「${e||`(空)`}」→「${r}」\n\n队列/看板/参考关系会跟随新 key 级联更新;旧 key 上的文档归属不会自动迁移,需要在文档列表里重新绑定。确认修改?`,danger:!0}))return;i.key=r,i.keyCustom=!0}}else i.key=r,y&&(i.keyCustom=!0);e?await N(encodeURIComponent(e),i):await M(i),o(),await s()}),children:e?`保存修改`:`添加仓库`})]})]}),m]})}export{d as A,S as C,_ as D,P as E,w as O,x as S,V as T,p as _,y as a,j as b,E as c,g as d,D as f,v as g,z as h,b as i,f as j,N as k,O as l,B as m,U as n,L as o,m as p,A as r,T as s,q as t,h as u,I as v,k as w,C as x,R as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,g as r,p as i,u as a,v as o,y as s}from"./frontmatter-DEIM0yF2.js";import{r as c}from"./workspace-C0PPPfA1.js";import{A as l,C as u,D as d,E as f,O as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as b,f as x,g as S,h as C,i as w,k as T,l as E,m as D,n as O,o as k,p as A,r as j,s as M,t as N,u as P,v as F,w as I,x as L,y as R}from"./repo-form-modal-CDZb_LS0.js";import{n as z}from"./app-context-CR7f0AtI.js";import{a as B,i as V,n as H}from"./doc-RM4avSIW.js";import{t as ee}from"./route-crumb-CkhC1zw2.js";import{t as te}from"./bar-BYNKx6rI.js";import{t as ne}from"./member-picker-B_LsCqNq.js";var U=e(n(),1),W=s(),G={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function re({onClose:e,onChanged:n,repos:i,boards:a}){let s=r(),c=t(),[l,u]=(0,U.useState)(`import`),[d,f]=(0,U.useState)({}),[p,m]=(0,U.useState)({}),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(``),[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)({}),[T,E]=(0,U.useState)({}),[D,O]=(0,U.useState)(`ours`),[k,A]=(0,U.useState)(`none`),[j,M]=(0,U.useState)(``),[N,P]=(0,U.useState)(null),[F,I]=(0,U.useState)(!1),L=(0,U.useMemo)(()=>i||[],[i]),R=(0,U.useMemo)(()=>L.map(e=>e.key),[L]),z=(0,U.useMemo)(()=>(a||[]).map(e=>e.name),[a]),B=e=>{let t={};for(let n of R)t[n]=e;f(t)},V=e=>{let t={};for(let n of z)t[n]=e;m(t)},H=()=>{let e={};for(let t of R)e[t]=!d[t];f(e)},ee=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==R.length?e:void 0,boards:t.length&&t.length!==z.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let i=await o(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(i,null,2)),c(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),te=()=>{if(!_)return;let e=new Blob([_],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},ne=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),P(null))},re=()=>s(async()=>{if(y.trim()){I(!0);try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),P(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{I(!1)}}}),K=()=>s(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);I(!0);try{let r=await o(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:k,selection:e.length?e:void 0,boards:t.length?t:void 0}});P(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await q(),n&&await n()}finally{I(!1)}}),q=(0,U.useCallback)(async()=>{try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),J=(0,U.useMemo)(()=>x?j?x.repos.filter(e=>e.status===j):x.repos:[],[x,j]),Y=(e,t)=>s(async()=>{if(t){I(!0);try{await o(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await q(),n&&await n()}finally{I(!1)}}}),ie=e=>{let t={...C};for(let n of J)t[n.key]=e;w(t)};(0,U.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let X=(0,U.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,W.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,W.jsxs)(`div`,{className:`rp-full-box`,children:[(0,W.jsxs)(`div`,{className:`rp-full-head`,children:[(0,W.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,W.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,W.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,W.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,W.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),l===`export`?(0,W.jsxs)(`div`,{className:`rp-full-body`,children:[(0,W.jsxs)(`div`,{className:`rp-full-col`,children:[(0,W.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,W.jsx)(`span`,{children:`导出范围`}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选仓库`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:H,children:`反选`})]})]}),(0,W.jsxs)(`div`,{className:`rp-full-sel`,children:[L.map(e=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,W.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,W.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),L.length?null:(0,W.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,W.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,W.jsx)(`span`,{children:`看板`}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!0),children:`全选`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!1),children:`全不选`})]})]}),(0,W.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,W.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,W.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,W.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,W.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,W.jsxs)(`div`,{className:`form-acts`,children:[(0,W.jsx)(`button`,{className:`btn`,onClick:ee,children:`生成布局`}),(0,W.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:te,children:`下载 JSON`})]})]}),(0,W.jsxs)(`div`,{className:`rp-full-col`,children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,children:(0,W.jsx)(`span`,{children:`导出结果`})}),(0,W.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,W.jsxs)(`div`,{className:`rp-full-body`,children:[(0,W.jsxs)(`div`,{className:`rp-full-col`,children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,children:(0,W.jsx)(`span`,{children:`导入来源`})}),(0,W.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:ne}),(0,W.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,W.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,W.jsx)(`div`,{className:`form-acts`,children:(0,W.jsx)(`button`,{className:`btn`,disabled:!y.trim()||F,onClick:re,children:`差异检查`})}),x?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,W.jsx)(`span`,{children:`冲突方案`})}),(0,W.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,W.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,W.jsx)(`span`,{children:t})]},e))}),(0,W.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,W.jsx)(`span`,{children:`克隆`})}),(0,W.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,W.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,W.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,W.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,W.jsx)(`div`,{className:`form-acts`,children:(0,W.jsxs)(`button`,{className:`btn`,disabled:F,onClick:K,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,N?(0,W.jsxs)(`div`,{className:`rp-import-result`,children:[(0,W.jsxs)(`div`,{children:[`新建 `,N.created.length,` · 覆盖 `,N.updated.length,` · 另存 `,N.duplicated.length,` · 跳过 `,N.skipped.length]}),(0,W.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,N.boardsCreated,` / 合并 `,N.boardsMerged,` · 参考关系 `,N.links]}),N.cloned.length?(0,W.jsxs)(`div`,{children:[`克隆 `,N.cloned.length,` 个`]}):null,N.unmatched.length?(0,W.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,N.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,W.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,W.jsxs)(`span`,{children:[`差异(新增 `,X.new,` · 有差异 `,X.changed,` · 一致 `,X.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(`button`,{className:`rp-chip`+(j===``?` on`:``),onClick:()=>M(``),children:`全部`}),(0,W.jsx)(`button`,{className:`rp-chip`+(j===`new`?` on`:``),onClick:()=>M(`new`),children:`新增`}),(0,W.jsx)(`button`,{className:`rp-chip`+(j===`changed`?` on`:``),onClick:()=>M(`changed`),children:`有差异`}),(0,W.jsx)(`button`,{className:`rp-chip`+(j===`same`?` on`:``),onClick:()=>M(`same`),children:`一致`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ie(!0),children:`全选`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ie(!1),children:`全不选`})]})]}),(0,W.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,W.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{style:{width:`32px`}}),(0,W.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,W.jsx)(`th`,{children:`仓库 key`}),(0,W.jsx)(`th`,{children:`差异字段`})]})}),(0,W.jsxs)(`tbody`,{children:[J.map(e=>(0,W.jsxs)(`tr`,{className:`rp-diff-row `+(G[e.status]?.cls??``),children:[(0,W.jsx)(`td`,{children:(0,W.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`span`,{className:`rp-status `+(G[e.status]?.cls??``),children:G[e.status]?.label})}),(0,W.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,W.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,W.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:F,onClick:()=>Y(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,W.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`b`,{children:e.field}),`: `,(0,W.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,W.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,W.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,W.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,W.jsx)(`td`,{}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,W.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,W.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,W.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,children:(0,W.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,W.jsx)(`span`,{className:`rp-status `+(G[e.status]?.cls??``),children:G[e.status]?.label}),(0,W.jsx)(`span`,{children:e.key}),(0,W.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,W.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,W.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,W.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,W.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,W.jsx)(`button`,{className:`btn small`,disabled:F,onClick:()=>Y(e.key,e.remote),children:`克隆到本地`}):(0,W.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,W.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var K=10;function q({repo:e,onClose:n,onSaved:r}){let i=z(),o=t(),s=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[c,l]=(0,U.useState)(!!(s&&s.enabled)),[u,d]=(0,U.useState)(s&&s.waitMinutes!==void 0&&s.waitMinutes!==null?String(s.waitMinutes):String(K)),[f,p]=(0,U.useState)(!1),m=e=>{let t=String(e??``).trim();if(t===``)return K;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):K},h=async t=>{p(!0);try{let n=t&&t.enabled!==void 0?t.enabled:c;await T(e.id,{"get-loop":n?`on`:`off`,...n?{"get-loop-minutes":m(u)}:{}});let a=m(u);o(n?`已保存「${e.name}」的持续 get 设置(${a>0?`${a} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),i.refreshRepos&&i.refreshRepos(),r&&r()}catch(e){o(String(e.message||e))}finally{p(!1)}},g=async e=>{l(e),await h({enabled:e})};return(0,W.jsx)(a,{title:`持续 get · ${e.name}`,onClose:n,size:`md`,children:(0,W.jsxs)(`div`,{className:`rp-gl`,children:[(0,W.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,W.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,W.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,W.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,W.jsxs)(`button`,{className:`toggle`+(c?` on`:``),onClick:()=>g(!c),disabled:f,children:[(0,W.jsx)(`span`,{className:`dot`}),c?`开`:`关`]})]}),c&&(0,W.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,W.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,W.jsx)(`span`,{children:`阻塞窗口`}),(0,W.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,W.jsx)(`input`,{className:`rp-gl-min`,value:u,onChange:e=>d(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,W.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,W.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,W.jsx)(`span`,{className:`spacer`}),(0,W.jsx)(O,{variant:`primary`,disabled:f,onClick:()=>h(),children:`保存持续 get 设置`})]})]})]})})}function J({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,W.jsx)(l,{text:t,title:void 0,children:t}):(0,W.jsxs)(l,{text:t,title:`点击复制完整路径`,children:[(0,W.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Y({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
|
|
1
|
+
import{C as e,_ as t,b as n,g as r,p as i,u as a,v as o,y as s}from"./frontmatter-DEIM0yF2.js";import{r as c}from"./workspace-C0PPPfA1.js";import{A as l,C as u,D as d,E as f,O as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as b,f as x,g as S,h as C,i as w,k as T,l as E,m as D,n as O,o as k,p as A,r as j,s as M,t as N,u as P,v as F,w as I,x as L,y as R}from"./repo-form-modal-DxEqerLy.js";import{n as z}from"./app-context-CR7f0AtI.js";import{a as B,i as V,n as H}from"./doc-CKkCGsZ4.js";import{t as ee}from"./route-crumb-CkhC1zw2.js";import{t as te}from"./bar-CmzzOYQi.js";import{t as ne}from"./member-picker-B_LsCqNq.js";var U=e(n(),1),W=s(),G={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function re({onClose:e,onChanged:n,repos:i,boards:a}){let s=r(),c=t(),[l,u]=(0,U.useState)(`import`),[d,f]=(0,U.useState)({}),[p,m]=(0,U.useState)({}),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(``),[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)({}),[T,E]=(0,U.useState)({}),[D,O]=(0,U.useState)(`ours`),[k,A]=(0,U.useState)(`none`),[j,M]=(0,U.useState)(``),[N,P]=(0,U.useState)(null),[F,I]=(0,U.useState)(!1),L=(0,U.useMemo)(()=>i||[],[i]),R=(0,U.useMemo)(()=>L.map(e=>e.key),[L]),z=(0,U.useMemo)(()=>(a||[]).map(e=>e.name),[a]),B=e=>{let t={};for(let n of R)t[n]=e;f(t)},V=e=>{let t={};for(let n of z)t[n]=e;m(t)},H=()=>{let e={};for(let t of R)e[t]=!d[t];f(e)},ee=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==R.length?e:void 0,boards:t.length&&t.length!==z.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let i=await o(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(i,null,2)),c(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),te=()=>{if(!_)return;let e=new Blob([_],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},ne=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),P(null))},re=()=>s(async()=>{if(y.trim()){I(!0);try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),P(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{I(!1)}}}),K=()=>s(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);I(!0);try{let r=await o(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:k,selection:e.length?e:void 0,boards:t.length?t:void 0}});P(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await q(),n&&await n()}finally{I(!1)}}),q=(0,U.useCallback)(async()=>{try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),J=(0,U.useMemo)(()=>x?j?x.repos.filter(e=>e.status===j):x.repos:[],[x,j]),Y=(e,t)=>s(async()=>{if(t){I(!0);try{await o(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await q(),n&&await n()}finally{I(!1)}}}),ie=e=>{let t={...C};for(let n of J)t[n.key]=e;w(t)};(0,U.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let X=(0,U.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,W.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,W.jsxs)(`div`,{className:`rp-full-box`,children:[(0,W.jsxs)(`div`,{className:`rp-full-head`,children:[(0,W.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,W.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,W.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,W.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,W.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),l===`export`?(0,W.jsxs)(`div`,{className:`rp-full-body`,children:[(0,W.jsxs)(`div`,{className:`rp-full-col`,children:[(0,W.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,W.jsx)(`span`,{children:`导出范围`}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选仓库`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:H,children:`反选`})]})]}),(0,W.jsxs)(`div`,{className:`rp-full-sel`,children:[L.map(e=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,W.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,W.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),L.length?null:(0,W.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,W.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,W.jsx)(`span`,{children:`看板`}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!0),children:`全选`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!1),children:`全不选`})]})]}),(0,W.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,W.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,W.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,W.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,W.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,W.jsxs)(`div`,{className:`form-acts`,children:[(0,W.jsx)(`button`,{className:`btn`,onClick:ee,children:`生成布局`}),(0,W.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:te,children:`下载 JSON`})]})]}),(0,W.jsxs)(`div`,{className:`rp-full-col`,children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,children:(0,W.jsx)(`span`,{children:`导出结果`})}),(0,W.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,W.jsxs)(`div`,{className:`rp-full-body`,children:[(0,W.jsxs)(`div`,{className:`rp-full-col`,children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,children:(0,W.jsx)(`span`,{children:`导入来源`})}),(0,W.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:ne}),(0,W.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,W.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,W.jsx)(`div`,{className:`form-acts`,children:(0,W.jsx)(`button`,{className:`btn`,disabled:!y.trim()||F,onClick:re,children:`差异检查`})}),x?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,W.jsx)(`span`,{children:`冲突方案`})}),(0,W.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,W.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,W.jsx)(`span`,{children:t})]},e))}),(0,W.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,W.jsx)(`span`,{children:`克隆`})}),(0,W.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),children:[(0,W.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,W.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,W.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,W.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,W.jsx)(`div`,{className:`form-acts`,children:(0,W.jsxs)(`button`,{className:`btn`,disabled:F,onClick:K,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,N?(0,W.jsxs)(`div`,{className:`rp-import-result`,children:[(0,W.jsxs)(`div`,{children:[`新建 `,N.created.length,` · 覆盖 `,N.updated.length,` · 另存 `,N.duplicated.length,` · 跳过 `,N.skipped.length]}),(0,W.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,N.boardsCreated,` / 合并 `,N.boardsMerged,` · 参考关系 `,N.links]}),N.cloned.length?(0,W.jsxs)(`div`,{children:[`克隆 `,N.cloned.length,` 个`]}):null,N.unmatched.length?(0,W.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,N.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,W.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,W.jsxs)(`span`,{children:[`差异(新增 `,X.new,` · 有差异 `,X.changed,` · 一致 `,X.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(`button`,{className:`rp-chip`+(j===``?` on`:``),onClick:()=>M(``),children:`全部`}),(0,W.jsx)(`button`,{className:`rp-chip`+(j===`new`?` on`:``),onClick:()=>M(`new`),children:`新增`}),(0,W.jsx)(`button`,{className:`rp-chip`+(j===`changed`?` on`:``),onClick:()=>M(`changed`),children:`有差异`}),(0,W.jsx)(`button`,{className:`rp-chip`+(j===`same`?` on`:``),onClick:()=>M(`same`),children:`一致`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ie(!0),children:`全选`}),(0,W.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ie(!1),children:`全不选`})]})]}),(0,W.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,W.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{style:{width:`32px`}}),(0,W.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,W.jsx)(`th`,{children:`仓库 key`}),(0,W.jsx)(`th`,{children:`差异字段`})]})}),(0,W.jsxs)(`tbody`,{children:[J.map(e=>(0,W.jsxs)(`tr`,{className:`rp-diff-row `+(G[e.status]?.cls??``),children:[(0,W.jsx)(`td`,{children:(0,W.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`span`,{className:`rp-status `+(G[e.status]?.cls??``),children:G[e.status]?.label})}),(0,W.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,W.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,W.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:F,onClick:()=>Y(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,W.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`b`,{children:e.field}),`: `,(0,W.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,W.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,W.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,W.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,W.jsx)(`td`,{}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,W.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,W.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,W.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,W.jsx)(`div`,{className:`rp-full-colhead`,children:(0,W.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,W.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,W.jsx)(`span`,{className:`rp-status `+(G[e.status]?.cls??``),children:G[e.status]?.label}),(0,W.jsx)(`span`,{children:e.key}),(0,W.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,W.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,W.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,W.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,W.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,W.jsx)(`button`,{className:`btn small`,disabled:F,onClick:()=>Y(e.key,e.remote),children:`克隆到本地`}):(0,W.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,W.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var K=10;function q({repo:e,onClose:n,onSaved:r}){let i=z(),o=t(),s=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[c,l]=(0,U.useState)(!!(s&&s.enabled)),[u,d]=(0,U.useState)(s&&s.waitMinutes!==void 0&&s.waitMinutes!==null?String(s.waitMinutes):String(K)),[f,p]=(0,U.useState)(!1),m=e=>{let t=String(e??``).trim();if(t===``)return K;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):K},h=async t=>{p(!0);try{let n=t&&t.enabled!==void 0?t.enabled:c;await T(e.id,{"get-loop":n?`on`:`off`,...n?{"get-loop-minutes":m(u)}:{}});let a=m(u);o(n?`已保存「${e.name}」的持续 get 设置(${a>0?`${a} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),i.refreshRepos&&i.refreshRepos(),r&&r()}catch(e){o(String(e.message||e))}finally{p(!1)}},g=async e=>{l(e),await h({enabled:e})};return(0,W.jsx)(a,{title:`持续 get · ${e.name}`,onClose:n,size:`md`,children:(0,W.jsxs)(`div`,{className:`rp-gl`,children:[(0,W.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,W.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,W.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,W.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,W.jsxs)(`button`,{className:`toggle`+(c?` on`:``),onClick:()=>g(!c),disabled:f,children:[(0,W.jsx)(`span`,{className:`dot`}),c?`开`:`关`]})]}),c&&(0,W.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,W.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,W.jsx)(`span`,{children:`阻塞窗口`}),(0,W.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,W.jsx)(`input`,{className:`rp-gl-min`,value:u,onChange:e=>d(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,W.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,W.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,W.jsx)(`span`,{className:`spacer`}),(0,W.jsx)(O,{variant:`primary`,disabled:f,onClick:()=>h(),children:`保存持续 get 设置`})]})]})]})})}function J({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,W.jsx)(l,{text:t,title:void 0,children:t}):(0,W.jsxs)(l,{text:t,title:`点击复制完整路径`,children:[(0,W.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Y({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
|
|
2
2
|
`):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`,o=(e,t)=>e.title||e.desc||`第 ${t+1} 篇`,s=[];return n&&n.exists&&s.push({id:`main`,label:o(n,0),kind:`repo`,main:!0,title:n.title||n.summary||``}),r.forEach((e,t)=>{s.push({id:(e.docId||e.refId||`link`)+`:`+t,label:o(e,t),kind:`repo`,note:e.note||``,title:[e.title||e.desc,e.note&&`备注:${e.note}`].filter(Boolean).join(`
|
|
3
3
|
`)})}),(0,W.jsxs)(`div`,{className:`rp-docs-entry`,role:`button`,tabIndex:0,title:a,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&t()},children:[s.length?(0,W.jsx)(V,{items:s,onMore:t}):(0,W.jsx)(`span`,{className:`rp-docs-entry-main ghost`,children:`+ 写项目介绍`}),(0,W.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function ie({chips:e,acts:t}){let[n,r]=(0,U.useState)(!1),i=n?e:e.slice(0,4);return(0,W.jsxs)(W.Fragment,{children:[i.map(e=>(0,W.jsx)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:(0,W.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`本仓库直接绑定的参考仓库`,e.note,`点击跳到这个参考仓库`].filter(Boolean).join(`
|
|
4
4
|
`),onClick:()=>t.gotoRefRepo(e.key),children:[(0,W.jsx)(`b`,{children:`自`}),(0,W.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.key)),e.length>4?(0,W.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>r(e=>!e),children:n?`收起`:`+${e.length-4}`}):null]})}function X({r:e,showRef:t,showGroups:n,filterBoard:r,refRepoChipsByRepo:i,acts:a}){let o=i.get(e.key)||[];return(0,W.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,W.jsxs)(`td`,{className:`rp-name`,children:[(0,W.jsxs)(`strong`,{children:[e.icon?(0,W.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name,e.getLoop&&e.getLoop.enabled?(0,W.jsx)(`span`,{className:`rp-gl-dot`,title:`持续 get 已开启(${Number(e.getLoop.waitMinutes)>0?`${Number(e.getLoop.waitMinutes)} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`,"aria-label":`持续 get 已开启`}):null]}),(0,W.jsx)(`span`,{className:`mono rp-name-path`,children:(0,W.jsx)(J,{path:e.path})})]}),(0,W.jsx)(`td`,{className:`rp-cell-docs`,children:(0,W.jsx)(Y,{docs:e.descDocs,onOpen:()=>a.docs(e)})}),t?(0,W.jsxs)(`td`,{className:`rp-refs`,children:[o.length?(0,W.jsx)(ie,{chips:o,acts:a}):(0,W.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,W.jsx)(O,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库所属组的参考仓库`,onClick:()=>a.bind(e),children:`绑定`})]}):null,n?(0,W.jsx)(`td`,{className:`rp-cell-groups`,children:(e.boards||[]).length?(0,W.jsx)(B,{moreTitle:`展开本行全部所属分组`,children:(e.boards||[]).map(e=>(0,W.jsx)(`button`,{className:`rp-group-chip`+(r?.id===e.id?` on`:``),title:`只看「${e.name}」${e.note?`\n组内描述:${e.note}`:``}`,onClick:()=>a.filter(e.id),children:e.name},e.id))}):(0,W.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}):null,(0,W.jsx)(`td`,{className:`rp-acts`,children:(0,W.jsx)(te,{kind:`repos-row`,renderers:{edit:()=>(0,W.jsx)(O,{small:!0,onClick:()=>a.edit(e),children:`编辑`}),open:()=>(0,W.jsx)(O,{small:!0,title:`在文件管理器中打开`,onClick:()=>a.open(e),children:`打开`}),del:()=>(0,W.jsx)(O,{small:!0,danger:!0,onClick:()=>a.del(e),children:`删除`}),getloop:()=>(0,W.jsx)(O,{small:!0,title:`持续 get(waitgoal)配置`,onClick:()=>a.getloop(e),children:(0,W.jsxs)(`span`,{className:`rp-gl-menu-it`,children:[e.getLoop&&e.getLoop.enabled?(0,W.jsx)(`span`,{className:`rp-gl-dot`,"aria-hidden":!0}):null,`持续 get…`]})}),remote:()=>(0,W.jsx)(O,{small:!0,onClick:()=>a.remote(e),children:`对齐 remote`})},actions:{edit:()=>a.edit(e),open:()=>a.open(e),del:()=>a.del(e),getloop:()=>a.getloop(e),remote:()=>a.remote(e)},titles:{getloop:`持续 get(waitgoal)配置`,remote:`key 与远程 git 地址对齐`,del:`删除仓库登记(磁盘文件不受影响)`}})})]})}function ae({shown:e,devRepos:t,filterBoard:n,refRepoChipsByRepo:r,acts:i,onAddMember:a}){let o=!n,s=!n;return(0,W.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,W.jsxs)(`table`,{className:`rp-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,style:{width:`16%`},children:`仓库`}),(0,W.jsxs)(`th`,{scope:`col`,style:{width:`36%`},children:[`文档`,(0,W.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),o?(0,W.jsx)(`th`,{scope:`col`,style:{width:`18%`},children:`参考仓库`}):null,s?(0,W.jsx)(`th`,{scope:`col`,style:{width:`14%`},children:`分组`}):null,(0,W.jsx)(`th`,{scope:`col`,style:{width:`250px`},children:`操作`})]})}),(0,W.jsxs)(`tbody`,{children:[e.map(e=>(0,W.jsx)(X,{r:e,showRef:o,showGroups:s,filterBoard:n,refRepoChipsByRepo:r,acts:i},e.id)),e.length?null:(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:3+ +!!o+ +!!s,className:`muted rp-empty`,children:t.length?(0,W.jsxs)(W.Fragment,{children:[`这个分组还没有成员`,` `,n?(0,W.jsx)(O,{small:!0,onClick:()=>a(n.id),children:`添加成员`}):null]}):`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}function oe({boards:e,filter:t,onFilter:n,devCount:r,shownCount:i,q:a,onQ:o,onOpenDocs:s}){return(0,W.jsxs)(`div`,{className:`rp-filters`,"data-testid":`rp-filters`,children:[(0,W.jsxs)(`div`,{className:`rp-filters-main`,children:[(0,W.jsxs)(`button`,{className:`rp-chip`+(t?``:` on`),onClick:()=>n(``),title:`显示全部开发仓库`,children:[`全部 `,(0,W.jsx)(`b`,{children:r})]}),e.map(e=>(0,W.jsxs)(`button`,{className:`rp-chip`+(t===e.id?` on`:``),onClick:()=>n(t===e.id?``:e.id),title:`只看「${e.name}」里的仓库(${(e.repos||[]).length} 个)`,children:[e.name,` `,(0,W.jsx)(`b`,{children:(e.repos||[]).length})]},e.id))]}),(0,W.jsxs)(`div`,{className:`rp-filters-side`,children:[(0,W.jsx)(`input`,{className:`rp-search`,type:`search`,value:a,onChange:e=>o(e.target.value),placeholder:`搜仓库 / 路径 / 分组 / 文档…`,"aria-label":`检索仓库与文档`}),a?(0,W.jsx)(O,{small:!0,onClick:()=>o(``),children:`清空`}):null,(0,W.jsxs)(`span`,{className:`muted rp-search-count`,children:[i,` / `,r]}),(0,W.jsx)(O,{small:!0,title:`按仓库 / 组内 / 分组三档检索文档`,onClick:s,children:`文档检索`})]})]})}function se({filterBoard:e,refRepos:t,checkOf:n,onOpenDoc:r,onOpenRefDocs:i,onAddMember:a,onSync:o,onOpen:s,onLinkNote:c,onUnbind:u}){let d=(0,U.useMemo)(()=>{if(!e)return[];let n=new Map(t.map(e=>[e.key,e]));return(e.refs||[]).map(e=>{let t=n.get(e.id);return t?{...t,boardNote:e.note||``}:null}).filter(e=>e!==null)},[t,e]),[f,p]=(0,U.useState)(null);(0,U.useEffect)(()=>{p(null)},[e?e.id:null]);let m=f===null?d.length<=8:f;return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`rp-context`,"data-testid":`rp-context`,children:[(0,W.jsx)(`span`,{className:`rp-context-name`,children:e.name}),e.desc?(0,W.jsx)(`span`,{className:`rp-context-desc`,title:e.desc,children:e.desc}):(0,W.jsx)(`span`,{className:`muted rp-context-desc`,children:`还没有领域描述 —— 点「文档列表」新建一篇组介绍:侧重什么、谁配合谁、关键路径与搜索关键词在哪。`}),(0,W.jsxs)(`span`,{className:`acts`,children:[(0,W.jsx)(O,{small:!0,title:`在右侧栏列出这个组的文档(组 → 组内仓库 → 仓库自己)`,onClick:()=>r(e),children:`文档列表`}),(0,W.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(e.id),title:`组页里看这个组的成员与任务`,children:`组页 ↗`}),(0,W.jsx)(O,{small:!0,onClick:()=>a(e.id),children:`添加成员`})]})]}),(0,W.jsxs)(`div`,{className:`rp-ref-mounted`,"data-testid":`rp-board-refs`,children:[(0,W.jsxs)(`div`,{className:`rp-ref-mounted-head`,children:[(0,W.jsxs)(`span`,{className:`rp-ref-mounted-label`,children:[`「`,e.name,`」的参考仓库 `,(0,W.jsx)(`b`,{children:d.length})]}),(0,W.jsx)(`span`,{className:`muted`,children:`绑定在组上:组内所有仓库共享,不区分来源仓库`}),d.length?(0,W.jsx)(O,{small:!0,className:`rp-ref-mounted-toggle`,title:m?`收起这个组的参考仓库清单`:`展开这个组的参考仓库清单`,onClick:()=>p(!m),children:m?`收起`:`展开 ${d.length}`}):null]}),d.length?m?d.map(t=>{let r=n.get(t.id);return(0,W.jsxs)(`div`,{className:`rp-ref-mounted-item`,children:[(0,W.jsx)(`span`,{className:`rp-ref-dot`+(r?r.ok?` ok`:` bad`:``),title:r?r.ok?`检查通过`:(r.issues||[]).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,_ as t,b as n,m as r,p as i,v as a,y as o}from"./frontmatter-DEIM0yF2.js";import{n as s}from"./repo-form-modal-
|
|
1
|
+
import{C as e,_ as t,b as n,m as r,p as i,v as a,y as o}from"./frontmatter-DEIM0yF2.js";import{n as s}from"./repo-form-modal-DxEqerLy.js";import{n as c}from"./app-context-CR7f0AtI.js";import{a as l,t as u}from"./index-Bij7tTb6.js";var d=e(n(),1);function f(){return a(`/api/setting`)}function p(e){return a(`/api/setting`,{method:`POST`,body:e})}function m(){return a(`/api/localtasks`)}function h(e){return a(`/api/localtasks/setting`,{method:`PATCH`,body:e})}function g(){return Promise.all([a(`/api/repos`),a(`/api/boards`)])}var _=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),v=8e3,y=`builtin`,b=`系统内置`,x=`{{#if repo}},{{#if repo.intro}},〔项目介绍 · {{repo.name}}〕,{{repo.intro}},{{/if}},{{#if repo.docs}},〔项目文档〕按需取用:nx-kv docs get --ref <refId>,{{#each repo.docs}}, - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}, 取用:nx-kv docs get --ref {{refId}},{{/each}},{{/if}},{{#if repo.intro}}{{else}}{{#if repo.docs}}{{else}},〔项目上下文 · {{repo.name}}〕已登记为本机仓库({{repo.key}}),但没有项目介绍文档:nx-kv repo doc add {{repo.key}} --ref <refId>,{{/if}}{{/if}},{{/if}},{{#if repo}}{{else}}{{#if cwd}},〔项目上下文〕工作目录 {{cwd}} 未登记为本机仓库,本次交付没有项目介绍 / 组上下文。登记(不需要 .git,给 key 即可):nx-kv repo add "{{cwd}}" --key <key>,{{/if}}{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.introRefId}},组介绍:{{#if group.introDesc}}{{group.introDesc}}{{else}}(无描述){{/if}}, 取用:nx-kv docs get --ref {{group.introRefId}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}},{{/each}},{{/if}},{{#if group.docs}},组文档(按需取用):,{{#each group.docs}}, - {{#if desc}}{{desc}}{{else}}{{#if title}}{{title}}{{else}}未命名文档{{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}, 取用:nx-kv docs get --ref {{refId}},{{/each}},{{/if}},{{/if}},{{#if refRepos.count}},参考仓库(可直接读取,共 {{refRepos.count}} 个):,{{#each refRepos.list}}, - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}}`.split(`,`).join(`
|
|
2
2
|
`),S=[`{{#if attach}}`,`〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容、文件夹先列目录)再开始处理,不要跳过附件。`,``,`附件清单:`,`{{#each attach.list}}`,` - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{/if}}{{#if mdfile}}{{mdfile.absPath}}{{#if mdfile.missing}}(源文件已不在){{/if}}{{/if}}{{#if folder}}{{folder.absPath}}{{#if folder.missing}}(目录已不在){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}`,`{{/each}}`,``,`取用方式:`,`{{#each attach.list}}`,` - {{kindLabel}} 《{{name}}》:{{usage}}`,`{{/each}}`,`{{#each attach.list}}{{#if mdfile}}{{#if mdfile.content}}〔外部 md · {{name}}〕({{mdfile.absPath}}{{#if mdfile.truncated}},已截断{{/if}}{{#if mdfile.stale}},内容有变化{{/if}}):`,``,`{{mdfile.content}}`,``,`{{/if}}{{/if}}{{/each}}`,`{{#each attach.list}}{{#if ref}}{{#if ref.content}}〔文档原文 · {{ref.title}}〕:`,``,`{{ref.content}}`,``,`{{/if}}{{/if}}{{/each}}`,`{{/if}}`].join(`
|
|
3
3
|
`),C=[`{{#if goal.check}}`,`{{goal.check}}`,`{{/if}}`,`{{#if goal.statusLine}}`,`{{goal.statusLine}}`,`{{/if}}`].join(`
|
|
4
4
|
`),w=[`{{#if goal.check}}`,`〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),{{#if goal.reached}}已到点(超时 {{formatDuration goal.overtimeSec}}){{else}}剩余 {{goal.remainingHuman}}{{/if}}。`,`{{#if goal.reached}}——时间已到:可以收口,把改动收敛成可交付状态,补验证与说明后按 ack 段 done。`,`{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}——已过 2/3:进入收尾整理(收敛改动 / 补验证 / 写清遗留),别开新战线。`,`{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 50)}}——已过半:先确认主线走到哪,剩余时间只做收尾必需项。`,`{{else}}——时间尚足:先做主线,再补细节。{{/if}}{{/if}}{{/if}}`,`{{/if}}`].join(`
|