@fgbg/mdocs 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-skills/changelog/SKILL.md +18 -0
- package/dist/server/routes/assets.routes.js +9 -4
- package/dist/server/routes/assets.routes.js.map +1 -1
- package/dist/server/routes/assets.routes.upload.test.js +1 -0
- package/dist/server/routes/assets.routes.upload.test.js.map +1 -1
- package/dist/web/assets/{AgentChatPanel-C8TMWDuE.js → AgentChatPanel-Bt38gm3b.js} +2 -2
- package/dist/web/assets/{AgentSkillFormCard-yk7PWF0W.js → AgentSkillFormCard-CtfWIf7Y.js} +1 -1
- package/dist/web/assets/AiWriteWorkbench-Boie5E_-.js +7 -0
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-Bw4wHaBD.js → DiagramEditor-NtNY3sZL-CZy-tmEe.js} +1 -1
- package/dist/web/assets/DocumentEditor-1A6lpvV-.js +26 -0
- package/dist/web/assets/{MergeView-royv5YkB.js → MergeView-Dip0aW7s.js} +1 -1
- package/dist/web/assets/PlaygroundPage-C4X6Lj-Q.js +8 -0
- package/dist/web/assets/{SettingsPage-D8HfepZ8.js → SettingsPage-nlnmzNZK.js} +1 -1
- package/dist/web/assets/{Toolbar-BDJ6WABq.js → Toolbar-BHLX-ug4.js} +2 -2
- package/dist/web/assets/{VisitorPickerModal-DPKIoySi.js → VisitorPickerModal-BPyEWlQo.js} +1 -1
- package/dist/web/assets/{copy-UwfRYkpI.js → copy-BE64wQqi.js} +1 -1
- package/dist/web/assets/diagram-CT58wBdU.js +5772 -0
- package/dist/web/assets/{editor-ONzd_YnO.js → editor-CL03se2B.js} +1 -1
- package/dist/web/assets/{index-4TuRcE3b.js → index-BkKvQv2F.js} +24 -24
- package/dist/web/assets/index-DKshvHIN.css +1 -0
- package/dist/web/assets/{meta2d-D3b5RRN8.js → meta2d-1-g23JOU.js} +1 -1
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-D1J2-XNv.js → meta2dEngine-BD2XbzaV-z-eR7E_V.js} +1 -1
- package/dist/web/assets/{motion-DddvD-ez.js → motion-DX3HNq_4.js} +2 -2
- package/dist/web/assets/{plus-CiGwts52.js → plus-ECzYbQfA.js} +1 -1
- package/dist/web/assets/react-GP8hKHRA.js +2122 -0
- package/dist/web/assets/react-vendor-BuABiQkA.js +242 -0
- package/dist/web/assets/ui-BQStT3dY.js +3116 -0
- package/dist/web/index.html +6 -6
- package/package.json +2 -2
- package/dist/web/assets/AiWriteWorkbench-ChCJt24m.js +0 -7
- package/dist/web/assets/DocumentEditor-B3Dsq02C.js +0 -26
- package/dist/web/assets/PlaygroundPage-B-_1l4Ix.js +0 -8
- package/dist/web/assets/diagram--gCCJK__.js +0 -6257
- package/dist/web/assets/index-C4ESYs7f.css +0 -1
- package/dist/web/assets/react-B99eF5mm.js +0 -2377
- package/dist/web/assets/react-vendor-BJFXgntS.js +0 -242
- package/dist/web/assets/ui-BHvBMRFE.js +0 -3126
|
@@ -8,6 +8,24 @@ source: changelog.md
|
|
|
8
8
|
|
|
9
9
|
# 更新日志
|
|
10
10
|
|
|
11
|
+
## v1.1.2
|
|
12
|
+
|
|
13
|
+
### 修复与体验
|
|
14
|
+
- **拉取更新 + 本地草稿**:落后且有未发布草稿时,「拉取更新」会打开合并视图,而不再静默无反应
|
|
15
|
+
- **AI 帮写 diff**:接受/拒绝后布局不再因失焦整段 LCS 重算而「旧上新下」错位
|
|
16
|
+
- **路径式文档链接**:兼容 `/doc/<id>`,自动转到 HashRouter 的 `#/doc/<id>`
|
|
17
|
+
- **手机图谱详情**:窄屏下节点详情全屏铺满图谱区,便于阅读关闭
|
|
18
|
+
- **附件上传**:放宽 PDF MIME 校验;PDF 强制下载;插入附件文件选择器补上 pdf/zip 等扩展名
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## v1.1.1
|
|
23
|
+
|
|
24
|
+
- **Markdown 粘贴转换**:多段落正文不再只剩一级标题;嵌套列表父项与子项可完整保留(依赖 `@fgbg/lobe-editor@1.0.0-fork.21`)
|
|
25
|
+
- **编辑器依赖**:升级 `@fgbg/lobe-editor@1.0.0-fork.21`
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
11
29
|
## v1.1.0
|
|
12
30
|
|
|
13
31
|
### 知识图谱
|
|
@@ -79,8 +79,13 @@ export function isAllowedAssetUpload(originalname, mimetype) {
|
|
|
79
79
|
return ZIP_MIME.has(mime);
|
|
80
80
|
if (AUDIO_EXT.has(ext))
|
|
81
81
|
return mime.startsWith("audio/");
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// 浏览器/系统可能给出 application/pdf、application/x-pdf 等
|
|
83
|
+
if (ext === ".pdf") {
|
|
84
|
+
return (mime === "application/pdf" ||
|
|
85
|
+
mime === "application/x-pdf" ||
|
|
86
|
+
mime === "applications/vnd.pdf" ||
|
|
87
|
+
mime.endsWith("/pdf"));
|
|
88
|
+
}
|
|
84
89
|
if (HTML_EXT.has(ext)) {
|
|
85
90
|
return mime === "text/html" || mime === "application/xhtml+xml" || mime.startsWith("text/");
|
|
86
91
|
}
|
|
@@ -253,8 +258,8 @@ export function serveAssetFile(req, res) {
|
|
|
253
258
|
const ct = HTML_EXT.has(ext)
|
|
254
259
|
? "application/octet-stream"
|
|
255
260
|
: (CONTENT_TYPE_BY_EXT[ext] ?? "application/octet-stream");
|
|
256
|
-
// zip / 音频 / html 强制下载(html 不以 text/html 内联,避免 XSS)
|
|
257
|
-
if (AUDIO_EXT.has(ext) || HTML_EXT.has(ext) || ext === ".zip") {
|
|
261
|
+
// zip / 音频 / html / pdf 强制下载(html 不以 text/html 内联,避免 XSS)
|
|
262
|
+
if (AUDIO_EXT.has(ext) || HTML_EXT.has(ext) || ext === ".zip" || ext === ".pdf") {
|
|
258
263
|
res.setHeader("Content-Disposition", `attachment; filename="${path.basename(abs)}"`);
|
|
259
264
|
}
|
|
260
265
|
res.setHeader("Content-Type", ct);
|
|
@@ -1 +1 @@
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,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { isAllowedAssetUpload } from "./assets.routes.js";
|
|
|
3
3
|
describe("isAllowedAssetUpload", () => {
|
|
4
4
|
it("allows pdf / txt / md / csv / html", () => {
|
|
5
5
|
expect(isAllowedAssetUpload("a.pdf", "application/pdf")).toBe(true);
|
|
6
|
+
expect(isAllowedAssetUpload("a.pdf", "application/x-pdf")).toBe(true);
|
|
6
7
|
expect(isAllowedAssetUpload("note.txt", "text/plain")).toBe(true);
|
|
7
8
|
expect(isAllowedAssetUpload("readme.md", "text/markdown")).toBe(true);
|
|
8
9
|
expect(isAllowedAssetUpload("data.csv", "text/csv")).toBe(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.routes.upload.test.js","sourceRoot":"","sources":["../../../src/server/routes/assets.routes.upload.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,MAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClE,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtE,MAAM,CAAC,oBAAoB,CAAC,UA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AC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9E,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/D,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as o,j as e}from"./react-vendor-
|
|
1
|
+
import{r as o,j as e}from"./react-vendor-BuABiQkA.js";import{c as Le,ag as be,ah as Ke,i as ve,ai as Se,aj as Oe,ak as Ue,al as We,am as Ge,an as Xe,ao as Re,ap as Ye,aq as Ve,ar as Je}from"./index-BkKvQv2F.js";import{H as Qe,A as we,S as Ze,a as es}from"./AgentSkillFormCard-CtfWIf7Y.js";import{P as ss}from"./plus-ECzYbQfA.js";import{ae as ts,af as ns}from"./ui-BQStT3dY.js";import{C as as,a as is}from"./copy-BE64wQqi.js";import"./diagram-CT58wBdU.js";import"./motion-DX3HNq_4.js";/**
|
|
2
2
|
* @license lucide-react v0.562.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const rs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ls=Le("file-text",rs);function le(r){var n;return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(le).join(""):typeof r=="object"&&"props"in r?le((n=r.props)==null?void 0:n.children):""}function cs(r){const[n,c]=o.useState(!1),d=o.useRef(null),v=le(r.children).replace(/\n$/,"");o.useEffect(()=>()=>{d.current!=null&&window.clearTimeout(d.current)},[]);async function x(){if(v)try{await navigator.clipboard.writeText(v),c(!0),d.current!=null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void x(),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(as,{size:14,"aria-hidden":!0}):e.jsx(is,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:r.children})]})}function Ae(r){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(ts,{remarkPlugins:[ns],components:{pre:({children:n})=>e.jsx(cs,{children:n})},children:r.children})})}const os=["如何发布文档?","草稿是什么?","如何创建域?"];function Ce(r,n){return n.map((c,d)=>{const v=c.skillNames&&c.skillNames.length>0?c.skillNames:c.skillIds&&c.skillIds.length>0?c.skillIds:void 0;return{id:`h-${r}-${d}-${c.role}`,role:c.role,content:c.content,skillNames:v}})}function ds(r,n){const c=r.slice(),d=c[c.length-1];return(d==null?void 0:d.type)==="text"?c[c.length-1]={type:"text",text:d.text+n}:c.push({type:"text",text:n}),c}function us(r,n){const c=r.slice(),d=c[c.length-1];return(d==null?void 0:d.type)==="thinking"?c[c.length-1]={type:"thinking",text:d.text+n}:c.push({type:"thinking",text:n}),c}function Ie(r){return r!=null&&r.length?r.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function ms(r){return!!(r!=null&&r.some(n=>n.type==="thinking"&&n.text.length>0))}function ps(r){const n=new Date(r);if(Number.isNaN(n.getTime()))return"";const c=new Date;return n.getFullYear()===c.getFullYear()&&n.getMonth()===c.getMonth()&&n.getDate()===c.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function _e(r){if(r>=1e3){const n=r/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(r)}function hs(r){const{block:n,onResolved:c}=r,[d,v]=o.useState(""),[x,$]=o.useState(!1),[_,R]=o.useState(1),A=o.useRef(!1),F=o.useRef(c);F.current=c;const S=n.status==="open",B=o.useRef(0);o.useEffect(()=>{if(!S)return;A.current=!1;const k=new Date(n.expiresAt).getTime(),N=Date.now(),w=Math.max(k-N,1);B.current=w,R(1);const u=()=>{const U=k-Date.now(),P=Math.max(0,Math.min(1,U/w));R(P),U<=0&&!A.current&&(A.current=!0,Ve(n.requestId).catch(()=>{}).finally(()=>{F.current(n.requestId,"","expired")}))};u();const T=window.setInterval(u,100);return()=>window.clearInterval(T)},[S,n.expiresAt,n.requestId]);async function M(k){const N=k.trim();if(!(!N||x||!S)){$(!0);try{await Je(n.requestId,N),c(n.requestId,N,"selected")}catch{c(n.requestId,N,"failed")}finally{$(!1)}}}async function H(){if(!(x||!S)){$(!0),A.current=!0;try{await Re(n.requestId),c(n.requestId,"","cancelled")}catch{c(n.requestId,"","failed")}finally{$(!1)}}}const L=Math.max(0,Math.ceil(_*B.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(S?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),S?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[L,"s"]}):null]}),S?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(_*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${_})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,S?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(k=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:x,onClick:()=>void M(k),children:k},k))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:d,disabled:x,placeholder:"或输入自己的内容…",onChange:k=>v(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),M(d))}}),e.jsx("button",{type:"button",disabled:x||!d.trim(),onClick:()=>void M(d),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:x,onClick:()=>void H(),children:"取消"})})]}):null]})}function fs(r){const v=2*Math.PI*8.75,x=Math.min(100,Math.max(0,r.percent)),$=v*(1-x/100),_=x>=90?"danger":x>=70?"warn":"ok",R=`上下文 ${x}% · 已用 ${_e(r.used)} / ${_e(r.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+_,"data-tooltip":R,"aria-label":R,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:v,strokeDashoffset:$,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function gs(r){var n;for(const c of r)if(!(c.role!=="assistant"||!((n=c.blocks)!=null&&n.length))){for(const d of c.blocks)if((d.type==="choice_card"||d.type==="skill_form_card")&&d.status==="open")return!0}return!1}const ws=o.forwardRef(function(n,c){const{open:d,onClose:v,visitorName:x,anchorStyle:$,fullscreen:_,domainId:R,documentId:A,documentTitle:F,documentPath:S,onOpenDocument:B,onTreeChanged:M,onDocumentOverwritten:H,onOpenCoding:L}=n,k=((x==null?void 0:x.trim().charAt(0))||"我").toUpperCase(),[N,w]=o.useState(!1),[u,T]=o.useState(null),[U,P]=o.useState(null),[q,y]=o.useState([]),[J,W]=o.useState(null),[ce,qe]=o.useState([]),[$e,oe]=o.useState(!1),[G,X]=o.useState(""),[K,de]=o.useState([]),[Ee,ue]=o.useState(!1),[g,Y]=o.useState(!1),[me,E]=o.useState(null),[V,pe]=o.useState(null),[Q,z]=o.useState(!1),[D,he]=o.useState(!1),De=o.useRef(null),Z=o.useRef(null),C=o.useRef(null),fe=o.useRef(0),O=o.useRef(!0),ee=o.useRef(q);ee.current=q;const ge=!!(A!=null&&A.trim())&&!Ee,Me=(F==null?void 0:F.trim())||"当前文档",xe=(S==null?void 0:S.trim())||"";o.useEffect(()=>{ue(!1)},[A]);function ye(s){return fe.current+=1,`${s}-${fe.current}`}function ze(s,m=48){return s.scrollHeight-s.scrollTop-s.clientHeight<=m}function I(){const s=Z.current;!s||!O.current||(s.scrollTop=s.scrollHeight)}function Fe(){const s=Z.current;s&&(O.current=ze(s))}async function Te(){oe(!0);try{const s=await Ue();qe(s.sessions),J||W(s.lastOpenedSessionId)}catch{}finally{oe(!1)}}async function se(){try{const s=await Oe();pe(s)}catch{}}async function je(){try{const s=await be();T(s),P(null)}catch(s){T(null),P(s instanceof Error?s.message:String(s))}}o.useEffect(()=>{var m;if(!d){w(!1),(m=C.current)==null||m.abort(),C.current=null,Y(!1);return}let s=!1;return(async()=>{try{const a=await be();s||(T(a),P(null))}catch(a){s||(T(null),P(a instanceof Error?a.message:String(a)))}})(),se(),()=>{s=!0}},[d]),o.useEffect(()=>{if(!d)return;let s=!1;return(async()=>{try{const m=await Ke();if(s)return;W(m.sessionId),y(a=>a.length>0?a:Ce(m.sessionId,m.messages))}catch{}})(),()=>{s=!0}},[d]),o.useEffect(()=>{!d||!N||Te()},[d,N]);function te(){if(!D){if(gs(ee.current)){z(!0);return}z(!1),v()}}async function Pe(){var a;if(D)return;he(!0);const s=ee.current,m=[];for(const j of s)if(!(j.role!=="assistant"||!j.blocks))for(const p of j.blocks)p.type==="choice_card"&&p.status==="open"&&m.push(Re(p.requestId).catch(()=>{})),p.type==="skill_form_card"&&p.status==="open"&&m.push(Ye(p.requestId).catch(()=>{}));await Promise.all(m),(a=C.current)==null||a.abort(),y(j=>j.map(p=>p.role!=="assistant"||!p.blocks?p:{...p,blocks:p.blocks.map(h=>h.type==="choice_card"&&h.status==="open"?{...h,status:"cancelled"}:h.type==="skill_form_card"&&h.status==="open"?{...h,status:"cancelled"}:h)})),z(!1),he(!1),v()}const ne=o.useRef(te);ne.current=te,o.useImperativeHandle(c,()=>({requestClose:()=>ne.current()}),[]),o.useEffect(()=>{if(!d){z(!1);return}const s=m=>{if(m.key==="Escape"){if(Q){D||z(!1);return}if(N){w(!1);return}ne.current()}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[d,N,Q,D]);async function ae(s){var h;const m=s.trim();if(!m||g)return;if(!(u!=null&&u.enabled)){E((u==null?void 0:u.reason)==="missing_api_key"?"请先配置 API Key":(u==null?void 0:u.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(h=C.current)==null||h.abort();const a=new AbortController;C.current=a;const j={id:ye("u"),role:"user",content:m,skillNames:K.length>0?[...K]:void 0},p=ye("a");O.current=!0,y(b=>[...b,j,{id:p,role:"assistant",content:""}]),X(""),Y(!0),E(null),w(!1),requestAnimationFrame(()=>I());try{let b=!1;await Xe(m,{skillNames:K.length>0?K:void 0,references:{domainId:(R==null?void 0:R.trim())||void 0,documentId:ge?A.trim():void 0},signal:a.signal,onEvent:i=>{i.type==="text_delta"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=ds(t.blocks??[],i.text);return{...t,blocks:l,content:Ie(l)}})),requestAnimationFrame(()=>I())):i.type==="thinking_delta"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=us(t.blocks??[],i.text);return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="sources"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=(t.blocks??[]).slice(),re=l[l.length-1];return(re==null?void 0:re.type)==="sources"?l[l.length-1]={type:"sources",items:i.items}:l.push({type:"sources",items:i.items}),{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="document_table"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_table",title:i.title,rows:i.rows}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="document_card"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_card",documentId:i.documentId,title:i.title,path:i.path,preview:i.preview}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="tool_notice"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"tool_notice",toolName:i.toolName,text:i.text}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="choice_card"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"choice_card",requestId:i.requestId,title:i.title,options:i.options,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="choice_expired"?y(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="skill_form_card"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"skill_form_card",requestId:i.requestId,mode:i.mode,title:i.title,currentName:i.currentName,initialName:i.initialName,initialDescription:i.initialDescription,initialBody:i.initialBody,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="skill_form_expired"?y(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="tree_changed"?M==null||M():i.type==="document_overwritten"?H==null||H({documentId:i.documentId,headCommitId:i.headCommitId}):i.type==="open_coding"?L==null||L({documentId:i.documentId,displayName:i.displayName}):i.type==="context_usage"?pe({percent:i.percent,used:i.used,limit:i.limit}):i.type==="error"&&(b=!0,E(i.message))}}),!a.signal.aborted&&!b&&de([])}catch(b){if(a.signal.aborted)return;E(b instanceof Error?b.message:String(b))}finally{C.current===a&&(C.current=null),Y(!1)}}async function Be(){var s;if(!g){(s=C.current)==null||s.abort(),E(null),w(!1),Y(!1);try{const m=await We();W(m.sessionId),y([]),X(""),O.current=!0,se()}catch(m){E(m instanceof Error?m.message:String(m))}}}async function He(s){var m;if(!g){if(s===J){w(!1);return}(m=C.current)==null||m.abort(),E(null);try{const a=await Ge(s);W(a.sessionId),y(Ce(a.sessionId,a.messages)),X(""),w(!1),O.current=!0,requestAnimationFrame(()=>I()),se()}catch(a){E(a instanceof Error?a.message:String(a))}}}function ke(s){!s||!B||B(s)}if(!d)return null;const ie=(u==null?void 0:u.reason)==="missing_api_key",Ne=U??(u&&!u.enabled&&!ie?u.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:De,className:"mdocs-agent-panel"+(_?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":_?!0:void 0,style:_?void 0:$,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:ve,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:g,onClick:()=>void Be(),children:e.jsx(ss,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(N?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>w(s=>!s),children:e.jsx(Qe,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:te,children:e.jsx(Se,{size:16,strokeWidth:1.8})})]})]}),N?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>w(!1),children:"返回对话"})]}),$e?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):ce.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:ce.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(s.id===J?" active":""),disabled:g,onClick:()=>void He(s.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:s.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:ps(s.updatedAt)})]})},s.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:Z,onScroll:Fe,children:q.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),ie?e.jsx(we,{onConfigured:je}):Ne?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Ne}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:os.map(s=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void ae(s),disabled:g||!(u!=null&&u.enabled),children:s},s))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:q.map(s=>{var m;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(s.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[s.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:ve,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[s.role==="user"&&s.skillNames&&s.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",s.skillNames.length]}):null,s.role==="assistant"?s.blocks&&s.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[s.blocks.map((a,j)=>{var p;return a.type==="thinking"?a.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:g&&s.id===((p=q[q.length-1])==null?void 0:p.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:a.text})]},`${s.id}-th-${j}`):null:a.type==="text"?a.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ae,{children:a.text})},`${s.id}-t-${j}`):null:a.type==="sources"?a.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",a.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:a.items.map(h=>e.jsx("li",{children:e.jsx("a",{href:h.url,target:"_blank",rel:"noreferrer",children:h.name})},h.id))})]})},`${s.id}-s-${j}`):a.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:a.text})},`${s.id}-n-${j}`):a.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(hs,{block:a,onResolved:(h,b,i)=>{y(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===h?{...l,status:i,selected:i==="selected"?b:l.selected}:l)}))}})},`${s.id}-ch-${j}`):a.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ze,{block:a,onResolved:(h,b,i)=>{y(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===h?{...l,status:b,submittedName:b==="submitted"?i:l.submittedName}:l)}))}})},`${s.id}-sf-${j}`):a.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:h=>{h.preventDefault(),h.stopPropagation(),ke(a.documentId)},children:["《",a.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[a.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:a.path}):null,a.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:a.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${s.id}-c-${j}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[a.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:a.rows.length===0?"无结果":`${a.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:a.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:a.rows.map(h=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>ke(h.documentId),children:h.title})}),e.jsx("td",{children:h.summary||"-"})]},h.documentId))})]})})]})},`${s.id}-d-${j}`)}),g&&s.id===((m=q[q.length-1])==null?void 0:m.id)&&!Ie(s.blocks)&&!ms(s.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):s.content?e.jsx(Ae,{children:s.content}):g?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:s.content]}),s.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:k}):null]},s.id)})})}),me?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:me}):null,ie&&q.length>0?e.jsx(we,{onConfigured:je}):null,e.jsx(es,{selectedNames:K,onChange:de,disabled:g||!(u!=null&&u.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[ge?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(ls,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:Me}),xe?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:xe}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:g,onClick:()=>ue(!0),children:e.jsx(Se,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:u!=null&&u.enabled?"把你的问题告诉我…":"请先配置 API Key",value:G,disabled:g||!(u!=null&&u.enabled),onChange:s=>X(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),ae(G))}}),V?e.jsx(fs,{percent:V.percent,used:V.used,limit:V.limit}):null,e.jsx("button",{type:"button",className:g?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:g?!1:!(u!=null&&u.enabled)||!G.trim(),onClick:()=>{var s;if(g){(s=C.current)==null||s.abort();return}ae(G)},title:g?"停止":"发送","aria-label":g?"停止":"发送",children:g?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),Q?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{D||z(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:D,onClick:()=>z(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:D,onClick:()=>void Pe(),children:D?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ws as AgentChatPanel};
|
|
6
|
+
*/const rs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ls=Le("file-text",rs);function le(r){var n;return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(le).join(""):typeof r=="object"&&"props"in r?le((n=r.props)==null?void 0:n.children):""}function cs(r){const[n,c]=o.useState(!1),d=o.useRef(null),v=le(r.children).replace(/\n$/,"");o.useEffect(()=>()=>{d.current!=null&&window.clearTimeout(d.current)},[]);async function x(){if(v)try{await navigator.clipboard.writeText(v),c(!0),d.current!=null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void x(),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(as,{size:14,"aria-hidden":!0}):e.jsx(is,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:r.children})]})}function Ae(r){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(ts,{remarkPlugins:[ns],components:{pre:({children:n})=>e.jsx(cs,{children:n})},children:r.children})})}const os=["如何发布文档?","草稿是什么?","如何创建域?"];function Ce(r,n){return n.map((c,d)=>{const v=c.skillNames&&c.skillNames.length>0?c.skillNames:c.skillIds&&c.skillIds.length>0?c.skillIds:void 0;return{id:`h-${r}-${d}-${c.role}`,role:c.role,content:c.content,skillNames:v}})}function ds(r,n){const c=r.slice(),d=c[c.length-1];return(d==null?void 0:d.type)==="text"?c[c.length-1]={type:"text",text:d.text+n}:c.push({type:"text",text:n}),c}function us(r,n){const c=r.slice(),d=c[c.length-1];return(d==null?void 0:d.type)==="thinking"?c[c.length-1]={type:"thinking",text:d.text+n}:c.push({type:"thinking",text:n}),c}function Ie(r){return r!=null&&r.length?r.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function ms(r){return!!(r!=null&&r.some(n=>n.type==="thinking"&&n.text.length>0))}function ps(r){const n=new Date(r);if(Number.isNaN(n.getTime()))return"";const c=new Date;return n.getFullYear()===c.getFullYear()&&n.getMonth()===c.getMonth()&&n.getDate()===c.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function _e(r){if(r>=1e3){const n=r/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(r)}function hs(r){const{block:n,onResolved:c}=r,[d,v]=o.useState(""),[x,$]=o.useState(!1),[_,R]=o.useState(1),A=o.useRef(!1),F=o.useRef(c);F.current=c;const S=n.status==="open",B=o.useRef(0);o.useEffect(()=>{if(!S)return;A.current=!1;const k=new Date(n.expiresAt).getTime(),N=Date.now(),w=Math.max(k-N,1);B.current=w,R(1);const u=()=>{const U=k-Date.now(),P=Math.max(0,Math.min(1,U/w));R(P),U<=0&&!A.current&&(A.current=!0,Ve(n.requestId).catch(()=>{}).finally(()=>{F.current(n.requestId,"","expired")}))};u();const T=window.setInterval(u,100);return()=>window.clearInterval(T)},[S,n.expiresAt,n.requestId]);async function D(k){const N=k.trim();if(!(!N||x||!S)){$(!0);try{await Je(n.requestId,N),c(n.requestId,N,"selected")}catch{c(n.requestId,N,"failed")}finally{$(!1)}}}async function H(){if(!(x||!S)){$(!0),A.current=!0;try{await Re(n.requestId),c(n.requestId,"","cancelled")}catch{c(n.requestId,"","failed")}finally{$(!1)}}}const L=Math.max(0,Math.ceil(_*B.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(S?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),S?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[L,"s"]}):null]}),S?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(_*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${_})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,S?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(k=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:x,onClick:()=>void D(k),children:k},k))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:d,disabled:x,placeholder:"或输入自己的内容…",onChange:k=>v(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),D(d))}}),e.jsx("button",{type:"button",disabled:x||!d.trim(),onClick:()=>void D(d),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:x,onClick:()=>void H(),children:"取消"})})]}):null]})}function fs(r){const v=2*Math.PI*8.75,x=Math.min(100,Math.max(0,r.percent)),$=v*(1-x/100),_=x>=90?"danger":x>=70?"warn":"ok",R=`上下文 ${x}% · 已用 ${_e(r.used)} / ${_e(r.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+_,"data-tooltip":R,"aria-label":R,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:v,strokeDashoffset:$,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function gs(r){var n;for(const c of r)if(!(c.role!=="assistant"||!((n=c.blocks)!=null&&n.length))){for(const d of c.blocks)if((d.type==="choice_card"||d.type==="skill_form_card")&&d.status==="open")return!0}return!1}const ws=o.forwardRef(function(n,c){const{open:d,onClose:v,visitorName:x,anchorStyle:$,fullscreen:_,domainId:R,documentId:A,documentTitle:F,documentPath:S,onOpenDocument:B,onTreeChanged:D,onDocumentOverwritten:H,onOpenCoding:L}=n,k=((x==null?void 0:x.trim().charAt(0))||"我").toUpperCase(),[N,w]=o.useState(!1),[u,T]=o.useState(null),[U,P]=o.useState(null),[q,y]=o.useState([]),[J,W]=o.useState(null),[ce,qe]=o.useState([]),[$e,oe]=o.useState(!1),[G,X]=o.useState(""),[K,de]=o.useState([]),[Ee,ue]=o.useState(!1),[g,Y]=o.useState(!1),[me,E]=o.useState(null),[V,pe]=o.useState(null),[Q,z]=o.useState(!1),[M,he]=o.useState(!1),Me=o.useRef(null),Z=o.useRef(null),C=o.useRef(null),fe=o.useRef(0),O=o.useRef(!0),ee=o.useRef(q);ee.current=q;const ge=!!(A!=null&&A.trim())&&!Ee,De=(F==null?void 0:F.trim())||"当前文档",xe=(S==null?void 0:S.trim())||"";o.useEffect(()=>{ue(!1)},[A]);function ye(s){return fe.current+=1,`${s}-${fe.current}`}function ze(s,m=48){return s.scrollHeight-s.scrollTop-s.clientHeight<=m}function I(){const s=Z.current;!s||!O.current||(s.scrollTop=s.scrollHeight)}function Fe(){const s=Z.current;s&&(O.current=ze(s))}async function Te(){oe(!0);try{const s=await Ue();qe(s.sessions),J||W(s.lastOpenedSessionId)}catch{}finally{oe(!1)}}async function se(){try{const s=await Oe();pe(s)}catch{}}async function je(){try{const s=await be();T(s),P(null)}catch(s){T(null),P(s instanceof Error?s.message:String(s))}}o.useEffect(()=>{var m;if(!d){w(!1),(m=C.current)==null||m.abort(),C.current=null,Y(!1);return}let s=!1;return(async()=>{try{const a=await be();s||(T(a),P(null))}catch(a){s||(T(null),P(a instanceof Error?a.message:String(a)))}})(),se(),()=>{s=!0}},[d]),o.useEffect(()=>{if(!d)return;let s=!1;return(async()=>{try{const m=await Ke();if(s)return;W(m.sessionId),y(a=>a.length>0?a:Ce(m.sessionId,m.messages))}catch{}})(),()=>{s=!0}},[d]),o.useEffect(()=>{!d||!N||Te()},[d,N]);function te(){if(!M){if(gs(ee.current)){z(!0);return}z(!1),v()}}async function Pe(){var a;if(M)return;he(!0);const s=ee.current,m=[];for(const j of s)if(!(j.role!=="assistant"||!j.blocks))for(const p of j.blocks)p.type==="choice_card"&&p.status==="open"&&m.push(Re(p.requestId).catch(()=>{})),p.type==="skill_form_card"&&p.status==="open"&&m.push(Ye(p.requestId).catch(()=>{}));await Promise.all(m),(a=C.current)==null||a.abort(),y(j=>j.map(p=>p.role!=="assistant"||!p.blocks?p:{...p,blocks:p.blocks.map(h=>h.type==="choice_card"&&h.status==="open"?{...h,status:"cancelled"}:h.type==="skill_form_card"&&h.status==="open"?{...h,status:"cancelled"}:h)})),z(!1),he(!1),v()}const ne=o.useRef(te);ne.current=te,o.useImperativeHandle(c,()=>({requestClose:()=>ne.current()}),[]),o.useEffect(()=>{if(!d){z(!1);return}const s=m=>{if(m.key==="Escape"){if(Q){M||z(!1);return}if(N){w(!1);return}ne.current()}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[d,N,Q,M]);async function ae(s){var h;const m=s.trim();if(!m||g)return;if(!(u!=null&&u.enabled)){E((u==null?void 0:u.reason)==="missing_api_key"?"请先配置 API Key":(u==null?void 0:u.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(h=C.current)==null||h.abort();const a=new AbortController;C.current=a;const j={id:ye("u"),role:"user",content:m,skillNames:K.length>0?[...K]:void 0},p=ye("a");O.current=!0,y(b=>[...b,j,{id:p,role:"assistant",content:""}]),X(""),Y(!0),E(null),w(!1),requestAnimationFrame(()=>I());try{let b=!1;await Xe(m,{skillNames:K.length>0?K:void 0,references:{domainId:(R==null?void 0:R.trim())||void 0,documentId:ge?A.trim():void 0},signal:a.signal,onEvent:i=>{i.type==="text_delta"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=ds(t.blocks??[],i.text);return{...t,blocks:l,content:Ie(l)}})),requestAnimationFrame(()=>I())):i.type==="thinking_delta"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=us(t.blocks??[],i.text);return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="sources"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=(t.blocks??[]).slice(),re=l[l.length-1];return(re==null?void 0:re.type)==="sources"?l[l.length-1]={type:"sources",items:i.items}:l.push({type:"sources",items:i.items}),{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="document_table"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_table",title:i.title,rows:i.rows}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="document_card"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"document_card",documentId:i.documentId,title:i.title,path:i.path,preview:i.preview}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="tool_notice"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"tool_notice",toolName:i.toolName,text:i.text}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="choice_card"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"choice_card",requestId:i.requestId,title:i.title,options:i.options,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="choice_expired"?y(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="skill_form_card"?(y(f=>f.map(t=>{if(t.id!==p)return t;const l=[...t.blocks??[],{type:"skill_form_card",requestId:i.requestId,mode:i.mode,title:i.title,currentName:i.currentName,initialName:i.initialName,initialDescription:i.initialDescription,initialBody:i.initialBody,expiresAt:i.expiresAt,status:"open"}];return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="skill_form_expired"?y(f=>f.map(t=>t.id!==p||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===i.requestId&&l.status==="open"?{...l,status:"expired"}:l)})):i.type==="tree_changed"?D==null||D():i.type==="document_overwritten"?H==null||H({documentId:i.documentId,headCommitId:i.headCommitId}):i.type==="open_coding"?L==null||L({documentId:i.documentId,displayName:i.displayName}):i.type==="context_usage"?pe({percent:i.percent,used:i.used,limit:i.limit}):i.type==="error"&&(b=!0,E(i.message))}}),!a.signal.aborted&&!b&&de([])}catch(b){if(a.signal.aborted)return;E(b instanceof Error?b.message:String(b))}finally{C.current===a&&(C.current=null),Y(!1)}}async function Be(){var s;if(!g){(s=C.current)==null||s.abort(),E(null),w(!1),Y(!1);try{const m=await We();W(m.sessionId),y([]),X(""),O.current=!0,se()}catch(m){E(m instanceof Error?m.message:String(m))}}}async function He(s){var m;if(!g){if(s===J){w(!1);return}(m=C.current)==null||m.abort(),E(null);try{const a=await Ge(s);W(a.sessionId),y(Ce(a.sessionId,a.messages)),X(""),w(!1),O.current=!0,requestAnimationFrame(()=>I()),se()}catch(a){E(a instanceof Error?a.message:String(a))}}}function ke(s){!s||!B||B(s)}if(!d)return null;const ie=(u==null?void 0:u.reason)==="missing_api_key",Ne=U??(u&&!u.enabled&&!ie?u.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:Me,className:"mdocs-agent-panel"+(_?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":_?!0:void 0,style:_?void 0:$,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:ve,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:g,onClick:()=>void Be(),children:e.jsx(ss,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(N?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>w(s=>!s),children:e.jsx(Qe,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:te,children:e.jsx(Se,{size:16,strokeWidth:1.8})})]})]}),N?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>w(!1),children:"返回对话"})]}),$e?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):ce.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:ce.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(s.id===J?" active":""),disabled:g,onClick:()=>void He(s.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:s.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:ps(s.updatedAt)})]})},s.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:Z,onScroll:Fe,children:q.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),ie?e.jsx(we,{onConfigured:je}):Ne?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Ne}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:os.map(s=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void ae(s),disabled:g||!(u!=null&&u.enabled),children:s},s))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:q.map(s=>{var m;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(s.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[s.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:ve,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[s.role==="user"&&s.skillNames&&s.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",s.skillNames.length]}):null,s.role==="assistant"?s.blocks&&s.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[s.blocks.map((a,j)=>{var p;return a.type==="thinking"?a.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:g&&s.id===((p=q[q.length-1])==null?void 0:p.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:a.text})]},`${s.id}-th-${j}`):null:a.type==="text"?a.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ae,{children:a.text})},`${s.id}-t-${j}`):null:a.type==="sources"?a.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",a.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:a.items.map(h=>e.jsx("li",{children:e.jsx("a",{href:h.url,target:"_blank",rel:"noreferrer",children:h.name})},h.id))})]})},`${s.id}-s-${j}`):a.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:a.text})},`${s.id}-n-${j}`):a.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(hs,{block:a,onResolved:(h,b,i)=>{y(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="choice_card"&&l.requestId===h?{...l,status:i,selected:i==="selected"?b:l.selected}:l)}))}})},`${s.id}-ch-${j}`):a.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ze,{block:a,onResolved:(h,b,i)=>{y(f=>f.map(t=>t.id!==s.id||!t.blocks?t:{...t,blocks:t.blocks.map(l=>l.type==="skill_form_card"&&l.requestId===h?{...l,status:b,submittedName:b==="submitted"?i:l.submittedName}:l)}))}})},`${s.id}-sf-${j}`):a.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:h=>{h.preventDefault(),h.stopPropagation(),ke(a.documentId)},children:["《",a.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[a.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:a.path}):null,a.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:a.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${s.id}-c-${j}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[a.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:a.rows.length===0?"无结果":`${a.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:a.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:a.rows.map(h=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>ke(h.documentId),children:h.title})}),e.jsx("td",{children:h.summary||"-"})]},h.documentId))})]})})]})},`${s.id}-d-${j}`)}),g&&s.id===((m=q[q.length-1])==null?void 0:m.id)&&!Ie(s.blocks)&&!ms(s.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):s.content?e.jsx(Ae,{children:s.content}):g?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:s.content]}),s.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:k}):null]},s.id)})})}),me?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:me}):null,ie&&q.length>0?e.jsx(we,{onConfigured:je}):null,e.jsx(es,{selectedNames:K,onChange:de,disabled:g||!(u!=null&&u.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[ge?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(ls,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:De}),xe?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:xe}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:g,onClick:()=>ue(!0),children:e.jsx(Se,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:u!=null&&u.enabled?"把你的问题告诉我…":"请先配置 API Key",value:G,disabled:g||!(u!=null&&u.enabled),onChange:s=>X(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),ae(G))}}),V?e.jsx(fs,{percent:V.percent,used:V.used,limit:V.limit}):null,e.jsx("button",{type:"button",className:g?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:g?!1:!(u!=null&&u.enabled)||!G.trim(),onClick:()=>{var s;if(g){(s=C.current)==null||s.abort();return}ae(G)},title:g?"停止":"发送","aria-label":g?"停止":"发送",children:g?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),Q?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{M||z(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:M,onClick:()=>z(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:M,onClick:()=>void Pe(),children:M?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ws as AgentChatPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as K,a2 as q,b as L,a0 as R,at as T,ap as B,au as P}from"./index-
|
|
1
|
+
import{c as K,a2 as q,b as L,a0 as R,at as T,ap as B,au as P}from"./index-BkKvQv2F.js";import{r as n,j as e}from"./react-vendor-BuABiQkA.js";/**
|
|
2
2
|
* @license lucide-react v0.562.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{r as d,j as n}from"./react-vendor-BuABiQkA.js";import{ag as ne,ah as de,i as ue,ak as me,as as he,al as fe,am as ge,an as xe}from"./index-BkKvQv2F.js";import{H as ke,A as te,S as ye,a as we}from"./AgentSkillFormCard-CtfWIf7Y.js";import{P as pe}from"./plus-ECzYbQfA.js";import{ae as je,af as Ne}from"./ui-BQStT3dY.js";import"./diagram-CT58wBdU.js";import"./motion-DX3HNq_4.js";function X(e){return e===""?[]:e.split(`
|
|
2
|
+
`)}function be(e){return e.join(`
|
|
3
|
+
`)}function Z(e,i){const s=X(e),l=X(i),m=s.length,k=l.length,y=Array.from({length:m+1},()=>Array.from({length:k+1},()=>0));for(let N=m-1;N>=0;N--)for(let v=k-1;v>=0;v--)s[N]===l[v]?y[N][v]=y[N+1][v+1]+1:y[N][v]=Math.max(y[N+1][v],y[N][v+1]);const C=[];let g=0,x=0;for(;g<m||x<k;)if(g<m&&x<k&&s[g]===l[x])C.push({kind:"eq",oi:g,ni:x}),g++,x++;else if(x<k&&(g===m||y[g][x+1]>=y[g+1][x]))C.push({kind:"ins",oi:g,ni:x}),x++;else if(g<m)C.push({kind:"del",oi:g,ni:x}),g++;else break;const j=[];let f=0,P=0;for(;f<C.length;){if(C[f].kind==="eq"){f++;continue}const N=C[f].oi,v=C[f].ni,R=[],b=[];let A=N,D=v;for(;f<C.length&&C[f].kind!=="eq";){const $=C[f];$.kind==="del"?(R.push(s[$.oi]),A=$.oi+1):(b.push(l[$.ni]),D=$.ni+1),f++}j.push({id:`h${P++}`,oldStart:N,oldEnd:A,newStart:v,newEnd:D,oldLines:R,newLines:b})}return j}function Se(e,i){const s=X(e);return be([...s.slice(0,i.oldStart),...i.newLines,...s.slice(i.oldEnd)])}function Y(e){return e===""?[]:e.split(`
|
|
4
|
+
`)}function K(e){return e.join(`
|
|
5
|
+
`)}function Ce(e,i){const s=Y(e),l=[];let m=0;return i.forEach((k,y)=>{k.oldStart>m&&l.push({kind:"same",lines:s.slice(m,k.oldStart),key:`s-${m}-${k.oldStart}`}),l.push({kind:"hunk",hunk:k,hunkIndex:y,key:`h-${k.id}-${y}`}),m=k.oldEnd}),m<s.length?l.push({kind:"same",lines:s.slice(m),key:`s-${m}-end`}):i.length===0&&s.length===0&&l.push({kind:"same",lines:[],key:"s-empty"}),l}function Ie(e){const i=[],s=[];for(const l of e)l.kind==="same"?i.push(K(l.lines)):s.push(K(l.hunk.newLines));return{sameTexts:i,newTexts:s}}function se(e,i){const s=[];let l=0,m=0;for(const k of e)if(k.kind==="same"){const y=i.sameTexts[l++]??"";s.push(...Y(y))}else{const y=i.newTexts[m++]??"";s.push(...Y(y))}return K(s)}function Me(e){return e.oldLines.length===0?"add":e.newLines.length===0?"del":"mod"}function ie(e){const i=Math.max(1,Y(e.value).length);return n.jsxs("div",{className:`mdocs-ai-write-line ${e.className}`,children:[n.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),n.jsx("textarea",{className:"mdocs-ai-write-inline-edit",value:e.value,rows:i,spellCheck:!1,"aria-label":e["aria-label"],onChange:s=>e.onChange(s.target.value),onBlur:()=>e.onBlurFlush()})]})}function ve(e){const i=!!e.sending,[s,l]=d.useState(0),[m,k]=d.useState(null),[y,C]=d.useState({sameTexts:[],newTexts:[]}),[g,x]=d.useState([]),j=d.useRef(!1),f=d.useRef(!1),P=d.useRef([]),N=d.useRef(y);N.current=y,P.current=g;const v=d.useMemo(()=>e.proposedMd==null||e.proposedMd===e.currentMd?[]:Z(e.currentMd,e.proposedMd),[e.currentMd,e.proposedMd]),R=!i&&(g.length>0?g.some(a=>a.kind==="hunk"):v.length>0);d.useEffect(()=>{if(i){x([]),j.current=!1,f.current=!1;return}if(e.proposedMd==null||e.proposedMd===e.currentMd){x([]),j.current=!1,f.current=!1;return}if(f.current){f.current=!1;return}const a=Z(e.currentMd,e.proposedMd);if(a.length===0){x([]);return}const c=Ce(e.currentMd,a);x(c),j.current=!1,C(Ie(c))},[i,e.proposedMd,e.currentMd]);const b=d.useMemo(()=>g.filter(a=>a.kind==="hunk").map(a=>a.hunk),[g]);d.useEffect(()=>{if(b.length===0){l(0);return}l(a=>Math.min(a,b.length-1))},[b.length]);const A=m??s;function D(){return se(P.current,N.current)}function $(){if(!R||P.current.length===0)return e.proposedMd;const a=D();return j.current=!1,a===e.currentMd?(f.current=!1,e.onProposedChange(null),null):(a!==e.proposedMd&&(f.current=!0,e.onProposedChange(a)),a)}function F(a){const c=P.current.find(H=>H.kind==="hunk"&&H.hunk.id===a.id);if(!c)return;const w=N.current.newTexts[c.hunkIndex],S={...a,newLines:w!=null?Y(w):a.newLines},T=D();if(j.current=!1,f.current=!1,T===e.currentMd){e.onProposedChange(null);return}const M=Se(e.currentMd,S);e.onCurrentChange(M),T===M?e.onProposedChange(null):e.onProposedChange(T)}function W(a){const c=P.current.find(T=>T.kind==="hunk"&&T.hunk.id===a.id);if(!c)return;const w={sameTexts:N.current.sameTexts.slice(),newTexts:N.current.newTexts.slice()};w.newTexts[c.hunkIndex]=K(a.oldLines);const S=se(P.current,w);j.current=!1,f.current=!1,S===e.currentMd?e.onProposedChange(null):e.onProposedChange(S)}function I(){const a=D();j.current=!1,f.current=!1,e.onCurrentChange(a),e.onProposedChange(null)}function O(){j.current=!1,f.current=!1,e.onProposedChange(null)}function p(a){b.length!==0&&l(c=>{const w=(c+a+b.length)%b.length,S=document.getElementById(`mdocs-ai-hunk-${w}`);return S==null||S.scrollIntoView({block:"center",behavior:"smooth"}),w})}function q(a,c){j.current=!0,C(w=>{const S=w.sameTexts.slice();return S[a]=c,{...w,sameTexts:S}})}function G(a,c){j.current=!0,C(w=>{const S=w.newTexts.slice();return S[a]=c,{...w,newTexts:S}})}const E=b[A]??null;let z=0;return n.jsxs("div",{className:"mdocs-ai-write-md-pane",children:[n.jsxs("div",{className:"mdocs-ai-write-diff-toolbar",children:[n.jsx("span",{className:"mdocs-ai-write-diff-count",children:i?"接收中·编辑我的稿":b.length===0?e.proposedMd?"与提案一致(可编辑)":"Markdown 源码(可编辑)":`${b.length} 处变更(可改提案)`}),!i&&b.length>0?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:I,children:"全部接受"}),n.jsx("button",{type:"button",onClick:O,children:"全部拒绝"})]}):null]}),R&&g.length>0?n.jsxs("div",{className:"mdocs-ai-write-inline",role:"document",children:[g.map(a=>{if(a.kind==="same"){const M=z++,H=y.sameTexts[M]??K(a.lines);return n.jsx("div",{className:"mdocs-ai-write-inline-same",children:n.jsx(ie,{className:"ctx",value:H,"aria-label":"提案相同行",onChange:Q=>q(M,Q),onBlurFlush:()=>$()})},a.key)}const c=a.hunk,w=Me(c),S=a.hunkIndex===A,T=y.newTexts[a.hunkIndex]??K(c.newLines);return n.jsxs("div",{id:`mdocs-ai-hunk-${a.hunkIndex}`,className:`mdocs-ai-write-inline-hunk mdocs-ai-write-inline-hunk-${w}`+(S?" is-active":""),onMouseEnter:()=>k(a.hunkIndex),onMouseLeave:()=>k(null),onClick:()=>l(a.hunkIndex),children:[n.jsxs("div",{className:"mdocs-ai-write-hunk-hover",hidden:m!==a.hunkIndex,children:[n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:M=>{M.stopPropagation(),W(c)},children:"拒绝"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:M=>{M.stopPropagation(),F(c)},children:"接受"})]}),n.jsx("pre",{className:"mdocs-ai-write-hunk-pre",children:c.oldLines.map((M,H)=>n.jsxs("div",{className:"mdocs-ai-write-line del mdocs-ai-write-line-readonly",children:[n.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),n.jsx("span",{className:"mdocs-ai-write-code",children:M||" "})]},`o${H}`))}),c.newLines.length>0||T!==""||w!=="del"?n.jsx(ie,{className:"add",value:T,"aria-label":"提案新增行",onChange:M=>G(a.hunkIndex,M),onBlurFlush:()=>$()}):null]},a.key)}),E?n.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"变更导航",children:[n.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>p(-1),children:"↑"}),n.jsxs("span",{children:[A+1," / ",b.length]}),n.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>p(1),children:"↓"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>W(E),children:"拒绝"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>F(E),children:"接受"})]}):null]}):n.jsx("textarea",{className:"mdocs-ai-write-editor",value:e.currentMd,onChange:a=>e.onCurrentChange(a.target.value),spellCheck:!1,placeholder:`# 标题
|
|
6
|
+
|
|
7
|
+
在此编辑 Markdown 源码…`})]})}let ae=0;function le(e){return ae+=1,`${e}-${Date.now()}-${ae}`}function Ae(e,i){const s=e.slice(),l=s[s.length-1];return(l==null?void 0:l.type)==="text"?s[s.length-1]={type:"text",text:l.text+i}:s.push({type:"text",text:i}),s}function $e(e,i){const s=e.slice(),l=s[s.length-1];return(l==null?void 0:l.type)==="thinking"?s[s.length-1]={type:"thinking",text:l.text+i}:s.push({type:"thinking",text:i}),s}function J(e,i){const s=i.trim();return s?[...e,{type:"tool",text:s}]:e}function Ee(e){return e.some(i=>i.type==="text"||i.type==="thinking"?i.text.length>0:!0)}function Te(e){const i=new Date(e);if(Number.isNaN(i.getTime()))return"";const s=new Date;return i.getFullYear()===s.getFullYear()&&i.getMonth()===s.getMonth()&&i.getDate()===s.getDate()?i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):i.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function re(e,i){return i.map((s,l)=>{const m=`h-${e}-${l}-${s.role}`;if(s.role==="user"){const k=s.skillNames&&s.skillNames.length>0?s.skillNames:s.skillIds&&s.skillIds.length>0?s.skillIds:void 0;return{id:m,role:"user",content:s.content,skillNames:k}}return{id:m,role:"assistant",blocks:s.content?[{type:"text",text:s.content}]:[]}})}function Be(e){const[i,s]=d.useState(e.initialMarkdown),[l,m]=d.useState(null),[k]=d.useState(e.initialMarkdown),[y,C]=d.useState(e.displayName||"未命名"),[g,x]=d.useState([]),[j,f]=d.useState(null),[P,N]=d.useState([]),[v,R]=d.useState(!1),[b,A]=d.useState(!1),[D,$]=d.useState(""),[F,W]=d.useState([]),[I,O]=d.useState(!1),[p,q]=d.useState(null),[G,E]=d.useState(null),[z,a]=d.useState(!1),c=d.useRef(null);async function w(){R(!0);try{const t=await me("coding",e.documentId);N(t.sessions),j||f(t.lastOpenedSessionId)}catch{}finally{R(!1)}}async function S(){try{const t=await ne();q(t)}catch{q({enabled:!1,skillsReady:!1,model:null})}}if(d.useEffect(()=>{var u;if(!e.open){A(!1),(u=c.current)==null||u.abort();return}s(e.initialMarkdown),m(null),C(e.displayName||"未命名"),$(""),E(null),A(!1);let t=!1;return(async()=>{try{const o=await ne();t||q(o)}catch{t||q({enabled:!1,skillsReady:!1,model:null})}try{const o=await de("coding",e.documentId);if(t)return;f(o.sessionId),x(re(o.sessionId,o.messages))}catch{t||(f(null),x([]))}w()})(),()=>{t=!0}},[e.open,e.initialMarkdown,e.displayName,e.documentId]),d.useEffect(()=>()=>{var t;return(t=c.current)==null?void 0:t.abort()},[]),d.useEffect(()=>{e.open&&b&&w()},[b,e.open,e.documentId]),!e.open)return null;const T=(p==null?void 0:p.reason)==="missing_api_key",M=l!=null&&l!==i?Z(i,l):[];async function H(){var t;if(!I){(t=c.current)==null||t.abort(),E(null),A(!1),O(!1);try{const u=await fe("coding",e.documentId);f(u.sessionId),x([]),$(""),w()}catch(u){E(u instanceof Error?u.message:String(u))}}}async function Q(t){var u;if(!I){if(t===j){A(!1);return}(u=c.current)==null||u.abort(),E(null);try{const o=await ge(t,"coding",e.documentId);f(o.sessionId),x(re(o.sessionId,o.messages)),$(""),A(!1)}catch(o){E(o instanceof Error?o.message:String(o))}}}async function ee(){var U;const t=D.trim();if(!t||I)return;if(!(p!=null&&p.enabled)){E("请先配置 API Key");return}(U=c.current)==null||U.abort();const u=new AbortController;c.current=u;const o=le("u"),B=le("a");x(L=>[...L,{id:o,role:"user",content:t,skillNames:F.length>0?[...F]:void 0},{id:B,role:"assistant",blocks:[]}]),$(""),O(!0),E(null);const _=L=>{x(r=>r.map(h=>h.id===B&&h.role==="assistant"?{...h,blocks:L(h.blocks)}:h))};try{let L=!1;await xe(t,{mode:"coding",skillNames:F.length>0?F:void 0,documentId:e.documentId,workingMarkdown:i,baseMarkdown:k,signal:u.signal,onEvent:r=>{r.type==="text_delta"?_(h=>Ae(h,r.text)):r.type==="thinking_delta"?_(h=>$e(h,r.text)):r.type==="markdown_set"?m(r.markdown):r.type==="tool_notice"?_(h=>J(h,r.text)):r.type==="document_table"?_(h=>J(h,r.title)):r.type==="document_card"?_(h=>J(h,`读取文档「${r.title}」`)):r.type==="sources"?r.items.length>0&&_(h=>J(h,`已阅读 ${r.items.length} 个手册页面`)):r.type==="skill_form_card"?_(h=>[...h,{type:"skill_form_card",requestId:r.requestId,mode:r.mode,title:r.title,currentName:r.currentName,initialName:r.initialName,initialDescription:r.initialDescription,initialBody:r.initialBody,expiresAt:r.expiresAt,status:"open"}]):r.type==="skill_form_expired"?_(h=>h.map(V=>V.type==="skill_form_card"&&V.requestId===r.requestId&&V.status==="open"?{...V,status:"expired"}:V)):r.type==="error"&&(L=!0,E(r.message))}}),!u.signal.aborted&&!L&&W([]),w()}catch(L){u.signal.aborted||E(L instanceof Error?L.message:String(L))}finally{c.current===u&&(c.current=null),O(!1)}}async function oe(){let t=i;if(M.length>0){if(!window.confirm(`还有 ${M.length} 段未审阅,将全部接受后写回。继续?`))return;t=l??i,s(t),m(null)}a(!0);const u=!e.documentId;try{const o=await e.onComplete({markdown:t,documentId:e.documentId,displayName:y.trim()||"未命名"}),B=o&&typeof o=="object"&&typeof o.documentId=="string"?o.documentId.trim():"";if(u&&B&&j)try{await he(j,B)}catch{}e.onClose()}catch(o){if(o!=null&&o.silent||o instanceof Error&&o.message==="cancelled")return;E(o instanceof Error?o.message:String(o))}finally{a(!1)}}function ce(){var t;(i!==k||l!=null)&&!window.confirm("取消帮写?未写回的修改将丢失。")||((t=c.current)==null||t.abort(),e.onClose())}return n.jsxs("div",{className:"mdocs-ai-write-overlay",role:"dialog","aria-modal":"true","aria-label":"帮写",children:[n.jsxs("header",{className:"mdocs-ai-write-header",children:[n.jsxs("div",{className:"mdocs-ai-write-header-left",children:[n.jsx("img",{src:ue,alt:"",className:"mdocs-ai-write-title-logo"}),n.jsx("strong",{children:"帮写"}),n.jsx("input",{className:"mdocs-ai-write-title",value:y,onChange:t=>C(t.target.value),"aria-label":"文档标题"})]}),n.jsxs("div",{className:"mdocs-ai-write-header-actions",children:[n.jsx("button",{type:"button",onClick:ce,disabled:z,children:"取消"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-primary",onClick:()=>void oe(),disabled:z,children:z?"写回中…":"完成并写回"})]})]}),n.jsxs("div",{className:"mdocs-ai-write-body",children:[n.jsxs("section",{className:"mdocs-ai-write-chat",children:[n.jsxs("div",{className:"mdocs-ai-write-chat-toolbar",children:[n.jsx("span",{className:"mdocs-ai-write-chat-toolbar-label",children:"对话"}),n.jsxs("div",{className:"mdocs-ai-write-chat-toolbar-actions",children:[n.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:I,onClick:()=>void H(),children:n.jsx(pe,{size:16,strokeWidth:1.8})}),n.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(b?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>A(t=>!t),children:n.jsx(ke,{size:16,strokeWidth:1.8})})]})]}),b?n.jsxs("div",{className:"mdocs-ai-write-history mdocs-agent-panel-history",children:[n.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[n.jsx("span",{children:"历史会话"}),n.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>A(!1),children:"返回对话"})]}),v?n.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):P.length===0?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),n.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):n.jsx("ul",{className:"mdocs-agent-panel-history-list",children:P.map(t=>n.jsx("li",{children:n.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===j?" active":""),disabled:I,onClick:()=>void Q(t.id),children:[n.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),n.jsx("span",{className:"mdocs-agent-panel-history-time",children:Te(t.updatedAt)})]})},t.id))})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mdocs-ai-write-chat-messages",children:g.length===0?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"mdocs-ai-write-hint",children:"描述你想写或改的内容。助手可读取右侧当前稿与进场快照,再更新提案;请按段接受或拒绝后完成写回。"}),T?n.jsx(te,{onConfigured:S}):null]}):g.map(t=>n.jsx("div",{className:"mdocs-ai-write-msg"+(t.role==="user"?" mdocs-ai-write-msg-user":""),children:t.role==="user"?n.jsxs(n.Fragment,{children:[t.skillNames&&t.skillNames.length>0?n.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",t.skillNames.length]}):null,t.content]}):Ee(t.blocks)?n.jsx("div",{className:"mdocs-ai-write-timeline",children:t.blocks.map((u,o)=>u.type==="thinking"?u.text?n.jsxs("details",{className:"mdocs-ai-write-thinking",open:I,children:[n.jsx("summary",{children:"思考中"}),n.jsx("pre",{className:"mdocs-ai-write-thinking-body",children:u.text})]},`${t.id}-think-${o}`):null:u.type==="tool"?n.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:u.text},`${t.id}-tool-${o}`):u.type==="skill_form_card"?n.jsx(ye,{block:u,onResolved:(B,_,U)=>{x(L=>L.map(r=>r.id!==t.id||r.role!=="assistant"?r:{...r,blocks:r.blocks.map(h=>h.type==="skill_form_card"&&h.requestId===B?{...h,status:_,submittedName:_==="submitted"?U:h.submittedName}:h)}))}},`${t.id}-sf-${o}`):u.text?n.jsx("div",{className:"mdocs-agent-panel-md",children:n.jsx(je,{remarkPlugins:[Ne],children:u.text})},`${t.id}-text-${o}`):null)}):I?n.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[n.jsx("span",{}),n.jsx("span",{}),n.jsx("span",{})]}):null},t.id))}),G?n.jsx("p",{className:"mdocs-ai-write-error",children:G}):null,T&&g.length>0?n.jsx(te,{onConfigured:S}):null,n.jsxs("div",{className:"mdocs-ai-write-input-row",children:[n.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[n.jsx(we,{selectedNames:F,onChange:W,disabled:I||!(p!=null&&p.enabled)}),n.jsx("textarea",{rows:2,value:D,disabled:I||!(p!=null&&p.enabled),placeholder:p!=null&&p.enabled?"说说要写什么…":"请先配置 API Key",onChange:t=>$(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ee())}})]}),n.jsx("button",{type:"button",className:I?"mdocs-ai-write-stop":void 0,disabled:I?!1:!(p!=null&&p.enabled),onClick:()=>{var t;if(I){(t=c.current)==null||t.abort();return}ee()},children:I?"停止":"发送"})]})]})]}),n.jsx(ve,{currentMd:i,proposedMd:l,sending:I,onCurrentChange:s,onProposedChange:m})]})]})}export{Be as AiWriteWorkbench};
|
package/dist/web/assets/{DiagramEditor-NtNY3sZL-Bw4wHaBD.js → DiagramEditor-NtNY3sZL-CZy-tmEe.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Q as I,S as H,T as F,U as O,V as G}from"./react-
|
|
1
|
+
import{Q as I,S as H,T as F,U as O,V as G}from"./react-GP8hKHRA.js";import{r as c,j as e}from"./react-vendor-BuABiQkA.js";import{ensureMeta2dShapes as X,generateSvgFromMeta2d as Q,generateSvgFromDiagram as Y}from"./meta2dEngine-BD2XbzaV-z-eR7E_V.js";import{M as _}from"./meta2d-1-g23JOU.js";import"./editor-CL03se2B.js";import"./ui-BQStT3dY.js";import"./motion-DX3HNq_4.js";import"./diagram-CT58wBdU.js";import"./index-BkKvQv2F.js";import"./plus-ECzYbQfA.js";import"./copy-BE64wQqi.js";let q=0;const P=new Set;function $(n){return P.add(n),()=>{P.delete(n)}}function M(){return q}function J(){q++,P.forEach(n=>n())}function z(n){let t=null;try{const[r]=I();t=r}catch{}const i=t;if(!i)throw new Error("[useEditorLocale] No editor found. Pass an editor instance or use this hook inside an <Editor> tree.");return c.useSyncExternalStore($,M,M),{setLocale:c.useCallback(r=>{i.setLocale(r),J()},[i]),t:c.useCallback((r,u)=>i.t(r,u),[i])}}const K={Activity:"meta2d.palette.groups.activity",Basic:"meta2d.palette.groups.basic","Fault tree":"meta2d.palette.groups.faultTree",Flow:"meta2d.palette.groups.flow","Sequence & class":"meta2d.palette.groups.sequenceClass"};function W(n){return`meta2d.palette.${n}`}const s={background:"#fff",color:"#1f1f1f",height:60,lineWidth:1,textColor:"#1f1f1f",width:120};function U(){return[{group:"Basic",key:"square",label:"Square",pen:{...s,height:100,name:"square",text:"",width:100}},{group:"Basic",key:"rect",label:"Rectangle",pen:{...s,name:"rectangle",text:"Rectangle"}},{group:"Basic",key:"roundRect",label:"Rounded",pen:{...s,borderRadius:.2,name:"rectangle",text:"Rounded"}},{group:"Basic",key:"circle",label:"Circle",pen:{...s,height:80,name:"circle",text:"Circle",width:80}},{group:"Basic",key:"triangle",label:"Triangle",pen:{...s,height:90,name:"triangle",text:"Triangle",width:100}},{group:"Basic",key:"diamond",label:"Diamond",pen:{...s,height:100,name:"diamond",text:"Decision",width:100}},{group:"Basic",key:"pentagon",label:"Pentagon",pen:{...s,height:100,name:"pentagon",text:"Pentagon",width:100}},{group:"Basic",key:"hexagon",label:"Hexagon",pen:{...s,height:100,name:"hexagon",text:"Hexagon",width:100}},{group:"Basic",key:"pentagram",label:"Star",pen:{...s,height:100,name:"pentagram",text:"",width:100}},{group:"Basic",key:"leftArrow",label:"Left arrow",pen:{height:60,name:"leftArrow",width:120}},{group:"Basic",key:"rightArrow",label:"Right arrow",pen:{height:60,name:"rightArrow",width:120}},{group:"Basic",key:"twowayArrow",label:"Two-way",pen:{height:60,name:"twowayArrow",width:150}},{group:"Basic",key:"cloud",label:"Cloud",pen:{height:100,name:"cloud",width:100}},{group:"Basic",key:"message",label:"Message",pen:{height:100,name:"message",textTop:-.1,width:100}},{group:"Basic",key:"file",label:"File",pen:{height:100,name:"file",width:80}},{group:"Basic",key:"cube",label:"Cube",pen:{height:100,name:"cube",width:60,z:.25}},{group:"Basic",key:"people",label:"Actor",pen:{height:100,name:"people",width:70}},{group:"Basic",key:"text",label:"Text",pen:{...s,background:"transparent",color:"transparent",height:32,name:"text",text:"text",width:120}},{group:"Basic",key:"line",label:"Line",pen:{color:"#1f1f1f",height:1,lineWidth:1,name:"line",width:160}},{group:"Flow",key:"flowTerminal",label:"Terminal",pen:{...s,borderRadius:.5,height:40,name:"rectangle",text:"Start / End",width:120}},{group:"Flow",key:"flowProcess",label:"Process",pen:{...s,height:40,name:"rectangle",text:"Process",width:120}},{group:"Flow",key:"flowDecision",label:"Decision",pen:{...s,height:60,name:"diamond",text:"Decision",width:120}},{group:"Flow",key:"flowData",label:"Data",pen:{...s,name:"flowData",offsetX:.14,text:"Data"}},{group:"Flow",key:"flowPrepare",label:"Prepare",pen:{...s,height:50,name:"hexagon",text:"Prepare",width:120}},{group:"Flow",key:"flowSubprocess",label:"Subprocess",pen:{...s,height:50,name:"flowSubprocess",text:"Subprocess",width:120}},{group:"Flow",key:"flowDb",label:"Database",pen:{...s,height:100,name:"flowDb",text:"DB",width:80}},{group:"Flow",key:"flowDocument",label:"Document",pen:{...s,height:100,name:"flowDocument",text:"Document",width:120}},{group:"Flow",key:"flowInternalStorage",label:"Int. storage",pen:{...s,height:80,name:"flowInternalStorage",text:"Internal",width:120}},{group:"Flow",key:"flowExternStorage",label:"Ext. storage",pen:{...s,height:80,name:"flowExternStorage",text:"External",width:120}},{group:"Flow",key:"flowQueue",label:"Queue",pen:{...s,height:100,name:"flowQueue",text:"Queue",width:100}},{group:"Flow",key:"flowManually",label:"Manual input",pen:{...s,height:80,name:"flowManually",text:"Manual",width:120}},{group:"Flow",key:"flowDisplay",label:"Display",pen:{...s,height:80,name:"flowDisplay",text:"Display",width:120}},{group:"Flow",key:"flowParallel",label:"Parallel",pen:{...s,height:50,name:"flowParallel",text:"Parallel",width:120}},{group:"Flow",key:"flowComment",label:"Comment",pen:{...s,height:100,name:"flowComment",text:"Note",width:100}},{group:"Activity",key:"actStart",label:"Start",pen:{background:"#555",height:30,lineWidth:0,name:"circle",text:"",width:30}},{group:"Activity",key:"actFinal",label:"Final",pen:{height:30,name:"activityFinal",width:30}},{group:"Activity",key:"actStep",label:"Action",pen:{...s,borderRadius:.25,height:50,name:"rectangle",text:"Action",width:120}},{group:"Activity",key:"actMerge",label:"Merge",pen:{...s,height:50,name:"diamond",text:"Merge",width:120}},{group:"Activity",key:"swimlaneV",label:"Swimlane V",pen:{height:500,lineTop:.08,name:"swimlaneV",text:"Swimlane",textBaseline:"top",textTop:20,width:200}},{group:"Activity",key:"swimlaneH",label:"Swimlane H",pen:{height:200,lineLeft:.08,name:"swimlaneH",text:"Swimlane",textAlign:"left",textLeft:.04,textWidth:.01,width:500}},{group:"Activity",key:"forkV",label:"Fork V",pen:{fillStyle:"#555",height:150,name:"forkV",strokeStyle:"transparent",text:"",width:10}},{group:"Activity",key:"forkH",label:"Fork H",pen:{fillStyle:"#555",height:10,name:"forkH",strokeStyle:"transparent",text:"",width:150}},{group:"Sequence & class",key:"lifeline",label:"Lifeline",pen:{height:400,name:"lifeline",text:"Object",textHeight:50,width:150}},{group:"Sequence & class",key:"sequenceFocus",label:"Activation",pen:{height:200,name:"sequenceFocus",text:"",width:12}},{group:"Sequence & class",key:"simpleClass",label:"Simple class",pen:{height:200,list:[{text:`- name: string
|
|
2
2
|
+ setName(name: string): void`}],name:"simpleClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Sequence & class",key:"interfaceClass",label:"Class",pen:{height:200,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}],name:"interfaceClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Fault tree",key:"andGate",label:"AND gate",pen:{height:150,name:"andGate",width:100}},{group:"Fault tree",key:"orGate",label:"OR gate",pen:{height:150,name:"orGate",width:100}},{group:"Fault tree",key:"basicEvent",label:"Basic event",pen:{height:150,name:"basicEvent",width:100}},{group:"Fault tree",key:"xorGate",label:"XOR gate",pen:{height:150,name:"xorGate",width:100}},{group:"Fault tree",key:"votingGate",label:"Voting gate",pen:{height:150,name:"votingGate",width:100}}]}function V(n){return G(structuredClone(n))}function Z(n){const t=new Map;for(const i of n){const r=t.get(i.group)??[];r.push(i),t.set(i.group,r)}return Array.from(t.entries())}function ee({name:n}){const t={fill:"#fff",stroke:"#1f1f1f",strokeWidth:1.2};return n==="circle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("circle",{cx:"14",cy:"14",r:"10",...t})}):n==="diamond"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,14 14,25 3,14",...t})}):n==="triangle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,4 25,24 3,24",...t})}):n==="pentagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,12 21,25 7,25 3,12",...t})}):n==="hexagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"8,4 20,4 25,14 20,24 8,24 3,14",...t})}):n==="pentagram"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 17,11 26,11 18,16 21,25 14,20 7,25 10,16 2,11 11,11",...t})}):n==="line"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("line",{x1:"4",x2:"24",y1:"14",y2:"14",...t})}):n==="text"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("text",{dominantBaseline:"middle",fill:"#1f1f1f",fontSize:"14",textAnchor:"middle",x:"14",y:"15",children:"T"})}):e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("rect",{height:"14",rx:"2",width:"20",x:"4",y:"7",...t})})}function te({disabled:n,engineRef:t,item:i,t:r}){const u=()=>{const a=t.current;if(!(!a||n))try{a.canvas.addCaches=[V(i.pen)]}catch{}};return e.jsxs("div",{draggable:!n,onClick:a=>{a.stopPropagation(),u()},onDragStart:a=>{if(n){a.preventDefault();return}const f=JSON.stringify(V(i.pen));a.dataTransfer.setData("Meta2d",f),a.dataTransfer.setData("Text",f),a.dataTransfer.effectAllowed="copy"},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),u())},role:"button",style:{alignItems:"center",border:"1px solid #efefef",borderRadius:6,cursor:n?"not-allowed":"grab",display:"flex",flexDirection:"column",gap:4,justifyContent:"center",minHeight:56,opacity:n?.5:1,outline:"none",padding:6},tabIndex:n?-1:0,title:`${r(W(i.key))||i.label} — drag or click to add`,children:[e.jsx(ee,{name:String(i.pen.name??"rectangle")}),e.jsx("span",{style:{fontSize:11},children:r(W(i.key))||i.label})]})}function ne({disabled:n,engineRef:t}){const{t:i}=z(),r=c.useMemo(()=>Z(U()),[]);return e.jsxs("aside",{style:{borderRight:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",padding:12,touchAction:"pan-y",width:240},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:4},children:i("meta2d.palette.title")}),e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:12},children:i("meta2d.palette.hint")}),r.map(([u,a])=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:6},children:i(K[u]||u)}),e.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"repeat(2, minmax(0, 1fr))"},children:a.map(f=>e.jsx(te,{disabled:n,engineRef:t,item:f,t:i},f.key))})]},u))]})}const N={borderLeft:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",width:220},A={color:"#8c8c8c",fontSize:12,marginBottom:4},D={borderBottom:"1px solid #f0f0f0",padding:"10px 12px"},y={alignItems:"center",display:"flex",gap:6,marginBottom:6},w={background:"#fafafa",border:"1px solid #e5e5e5",borderRadius:4,fontSize:12,height:28,outline:"none",padding:"0 6px"},b={color:"#8c8c8c",fontSize:11,minWidth:22},T={background:"#fff",border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer",fontSize:11,minWidth:48,padding:"4px 8px"},le=120;function ie({engine:n}){const{t}=z(),[i,r]=c.useState(null),[u,a]=c.useState(null),[f,v]=c.useState(""),p=c.useRef(null),j=c.useRef(null),B=c.useCallback((l,d)=>{!n||l===null||l===void 0||n.setValue({id:l,text:d},{render:!0})},[n]),k=c.useCallback(l=>{if(!l||l.length!==1){p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null;return}const d=l[0];if((d.globalAlpha===null||d.globalAlpha===void 0)&&(d.globalAlpha=1),d.id!==j.current&&(p.current&&(clearTimeout(p.current),p.current=null),j.current=d.id,v(d.text??"")),r(d),n)try{a(n.getPenRect(d))}catch{a(null)}},[n]),C=c.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null},[]);if(c.useEffect(()=>{if(n)return n.on("active",k),n.on("inactive",C),()=>{n.off("active",k),n.off("inactive",C),p.current&&(clearTimeout(p.current),p.current=null)}},[n,k,C]),!i||!n)return e.jsx("aside",{style:N,children:e.jsx("div",{style:{color:"#bbb",fontSize:12,padding:16,textAlign:"center"},children:t("meta2d.props.empty")})});const h=(l,d)=>{const m={id:i.id};m[l]=d,l==="dash"&&(m.lineDash=[void 0,[5,5]][d]),l!=="text"&&r(S=>S&&{...S,...m}),n.setValue(m,{render:!0})},o=l=>{v(l);const d=i.id;p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null,B(d,l)},le)},x=()=>{p.current&&(clearTimeout(p.current),p.current=null),B(i.id,f)},g=(l,d)=>{if(!u)return;const m={id:i.id};m[l]=d,n.setValue(m,{render:!0}),a(S=>S?{...S,[l]:d}:null)},R=l=>{l(n),n.render(!0)};return e.jsxs("aside",{style:N,children:[e.jsxs("div",{style:D,children:[e.jsx("div",{style:A,children:t("meta2d.props.text")}),e.jsx("div",{style:y,children:e.jsx("input",{onBlur:x,onChange:l=>o(l.target.value),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),l.target.blur())},style:{...w,flex:1,width:"100%"},type:"text",value:f})})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.appearance")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.color")}),e.jsx("input",{onChange:l=>h("color",l.target.value),style:{...w,flex:1},type:"color",value:i.color||"#1f1f1f"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.bg")}),e.jsx("input",{onChange:l=>h("background",l.target.value),style:{...w,flex:1},type:"color",value:i.background||"#ffffff"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.dash")}),e.jsxs("select",{onChange:l=>h("dash",Number(l.target.value)),style:{...w,flex:1},value:String(i.dash??0),children:[e.jsx("option",{value:"0",children:t("meta2d.props.solid")}),e.jsx("option",{value:"1",children:t("meta2d.props.dashLine")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.radius")}),e.jsx("input",{max:1,min:0,onChange:l=>h("borderRadius",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.borderRadius??0)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:i.borderRadius??0})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.alpha")}),e.jsx("input",{max:1,min:0,onChange:l=>h("globalAlpha",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.globalAlpha??1)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:(i.globalAlpha??1).toFixed(2)})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.position")}),[["X","x"],["Y","y"],["W","width"],["H","height"]].map(([l,d])=>e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:l}),e.jsx("input",{onChange:m=>g(d,Number(m.target.value)),style:{...w,flex:1},type:"number",value:u?u[d]:0})]},d))]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.textAlign")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.h")}),e.jsxs("select",{onChange:l=>h("textAlign",l.target.value),style:{...w,flex:1},value:i.textAlign||"center",children:[e.jsx("option",{value:"left",children:t("meta2d.props.left")}),e.jsx("option",{value:"center",children:t("meta2d.props.center")}),e.jsx("option",{value:"right",children:t("meta2d.props.right")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.v")}),e.jsxs("select",{onChange:l=>h("textBaseline",l.target.value),style:{...w,flex:1},value:i.textBaseline||"middle",children:[e.jsx("option",{value:"top",children:t("meta2d.props.topAlign")}),e.jsx("option",{value:"middle",children:t("meta2d.props.middle")}),e.jsx("option",{value:"bottom",children:t("meta2d.props.bottomAlign")})]})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.layer")}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.jsx("button",{onClick:()=>R(l=>l.top()),style:T,type:"button",children:t("meta2d.props.top")}),e.jsx("button",{onClick:()=>R(l=>l.up()),style:T,type:"button",children:t("meta2d.props.up")}),e.jsx("button",{onClick:()=>R(l=>l.down()),style:T,type:"button",children:t("meta2d.props.down")}),e.jsx("button",{onClick:()=>R(l=>l.bottom()),style:T,type:"button",children:t("meta2d.props.bottom")})]})]})]})}const L={background:"#fff",border:"1px solid #d9d9d9",borderRadius:6,cursor:"pointer",minWidth:68,padding:"6px 12px"},E={...L,fontSize:12,minWidth:52,padding:"4px 10px"};function re(n){c.useEffect(()=>{const t=document.documentElement,i=document.body,r=t.style.overflow,u=i.style.overflow;return t.style.overflow="hidden",i.style.overflow="hidden",()=>{t.style.overflow=r,i.style.overflow=u}},[n])}function me({diagram:n,onClose:t,onSave:i}){const{t:r}=z(),u=c.useRef(null),a=c.useRef(null),f=c.useRef(n),v=c.useRef(t),[p,j]=c.useState(null),[B,k]=c.useState(!1);re(!0),c.useLayoutEffect(()=>{v.current=t}),c.useEffect(()=>{if(!u.current)return;X();const o=new _(u.current,{grid:!0,rule:!1});a.current=o,j(o);try{const g=f.current;g!=null&&g.trim()?o.open(JSON.parse(g)):o.open(H()),F(o.data()),o.render(!0)}catch{o.open(H()),F(o.data()),o.render(!0)}const x=g=>{g.key==="Escape"&&v.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x);try{o.destroy()}catch{}a.current=null}},[]);const C=async()=>{const o=a.current;if(o){k(!0);try{F(o.data()),o.render(!0);const x=O(o.data()),g=JSON.stringify(x);i(g,await Q(o)||await Y(g)||'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="100%" height="100%" fill="#fafafa" stroke="#eee"/></svg>')}finally{k(!1)}}},h=o=>{const x=a.current;x&&o(x)};return e.jsx("div",{onClick:t,style:{alignItems:"center",background:"rgb(0 0 0 / 35%)",display:"flex",inset:0,justifyContent:"center",overflow:"hidden",position:"fixed",zIndex:1e3},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),onWheel:o=>o.stopPropagation(),style:{background:"#fff",borderRadius:10,boxShadow:"0 12px 30px rgb(0 0 0 / 20%)",display:"flex",flexDirection:"column",height:"86vh",maxHeight:"100%",maxWidth:"1200px",overflow:"hidden",width:"92vw"},children:[e.jsxs("div",{style:{alignItems:"center",borderBottom:"1px solid #f0f0f0",display:"flex",flexWrap:"wrap",gap:8,justifyContent:"space-between",padding:"10px 14px"},children:[e.jsx("span",{style:{fontWeight:600},children:r("meta2d.editor.title")}),e.jsxs("div",{style:{alignItems:"center",display:"flex",flexWrap:"wrap",gap:8},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.jsx("button",{onClick:()=>h(o=>o.undo()),style:E,title:`${r("meta2d.editor.undo")} (Ctrl+Z)`,type:"button",children:r("meta2d.editor.undo")}),e.jsx("button",{onClick:()=>h(o=>o.redo()),style:E,title:`${r("meta2d.editor.redo")} (Ctrl+Y)`,type:"button",children:r("meta2d.editor.redo")}),e.jsx("button",{onClick:()=>h(o=>o.delete()),style:E,title:r("meta2d.editor.delete"),type:"button",children:r("meta2d.editor.delete")}),e.jsx("button",{onClick:()=>h(o=>o.fitView(!0)),style:E,title:r("meta2d.editor.fit"),type:"button",children:r("meta2d.editor.fit")}),e.jsx("button",{onClick:()=>h(o=>{o.scale(1),o.centerView()}),style:E,title:r("meta2d.editor.zoom100"),type:"button",children:r("meta2d.editor.zoom100")})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:t,style:L,type:"button",children:r("meta2d.editor.close")}),e.jsx("button",{disabled:B,onClick:()=>void C(),style:{...L,background:"#1677ff",border:"none",color:"#fff"},type:"button",children:r(B?"meta2d.editor.saving":"meta2d.editor.save")})]})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsx(ne,{engineRef:a}),e.jsx("div",{ref:u,style:{flex:1,minHeight:0,minWidth:0}}),e.jsx(ie,{engine:p})]})]})})}export{me as DiagramEditor};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{r as i,j as n}from"./react-vendor-BuABiQkA.js";import{ad as ke}from"./ui-BQStT3dY.js";import{c as Y,g as Re,u as Ae,a as Ie,d as $e,b as Ye,f as Je,e as Ge,h as Ke,N as Xe,P as Qe,D as je,F as Ce,l as le,S as Se,i as Ze,M as pe,r as et,j as tt,k as nt,m as X,n as at,o as it,p as we}from"./index-BkKvQv2F.js";import{z as ot,A as st,m as de,n as rt,o as ct,p as lt,r as dt,s as ut,t as mt,v as ft,x as ht,B as yt,R as gt,a as xt,b as Me,c as vt,d as bt,e as kt,f as It,g as jt,h as Ct,i as St,w as ue,j as wt,O as Mt,E as Et,q as Nt,l as Dt,C as Rt,D as At}from"./react-GP8hKHRA.js";import{H as Pt,a as Tt,b as Lt,M as Bt,T as _t,S as Ot,W as zt,o as Ht,c as Ee}from"./Toolbar-BHLX-ug4.js";import{V as Ft}from"./VisitorPickerModal-BPyEWlQo.js";import"./motion-DX3HNq_4.js";import"./diagram-CT58wBdU.js";import"./editor-CL03se2B.js";import"./plus-ECzYbQfA.js";import"./copy-BE64wQqi.js";/**
|
|
2
|
+
* @license lucide-react v0.562.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ut=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Wt=Y("ellipsis-vertical",Ut);/**
|
|
7
|
+
* @license lucide-react v0.562.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const qt=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Vt=Y("refresh-cw",qt);/**
|
|
12
|
+
* @license lucide-react v0.562.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const $t=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M6.376 18.91a6 6 0 0 1 11.249.003",key:"hnjrf2"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}]],Yt=Y("shield-user",$t);/**
|
|
17
|
+
* @license lucide-react v0.562.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Jt=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Gt=Y("text-align-justify",Jt);/**
|
|
22
|
+
* @license lucide-react v0.562.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Kt=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Xt=Y("users",Kt),Qt=48;function Q(e){try{const a=e.getDocument("markdown");return typeof a=="string"?a:""}catch{return null}}function Zt(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}function pt({editor:e,documentId:a,displayName:c,debounceMs:v=1e3,enabled:y=!0,localBaseCommitIdAtEditStart:S,snapshotMeta:w}){const[H,M]=i.useState(!1),[Z,P]=i.useState(!1),[p,b]=i.useState(null),u=i.useRef(null),f=i.useRef(null),k=i.useRef(!1),x=i.useRef(""),I=i.useRef(!1),E=i.useRef(a),ee=i.useRef(c),F=i.useRef(S),T=i.useRef(w);E.current=a,ee.current=c,F.current=S,T.current=w;const j=i.useCallback(async()=>{if(!e)return;if(!x.current){console.log("[useAutoSave] performSave blocked: lastContentRef is empty");return}const s=Zt(e);s!=null&&(console.log("[useAutoSave] performSave saving draft, documentId:",E.current,"content preview:",s.slice(0,80)),await Re(E.current).execute(()=>Ae({documentId:E.current,content:s,displayName:ee.current,localBaseCommitIdAtEditStart:F.current,snapshotMeta:T.current})),x.current=Q(e)??x.current,P(!0),M(!1),b(Date.now()),k.current=!0,I.current=!1)},[e]);i.useEffect(()=>{let s=!1;return Ie(a).then(m=>{s||(m?(P(!0),b(m.updatedAt),k.current=!0):(P(!1),b(null),k.current=!1,I.current=!1))}),()=>{s=!0}},[a]),i.useEffect(()=>{var O,L;if(!y){(O=f.current)==null||O.call(f),f.current=null;return}if(!e)return;const s=e.getLexicalEditor();if(!s)return;(L=f.current)==null||L.call(f);let m=!1,h=0,U=0;const g=()=>{if(m)return;const N=Q(e);if(N===null){if(U+=1,U>Qt)return;h=requestAnimationFrame(g);return}x.current=N;const ae=s.registerUpdateListener(()=>{const B=Q(e);B!==null&&B!==x.current&&(console.log("[useAutoSave] updateListener dirty, documentId:",a,"oldLen:",x.current.length,"newLen:",B.length),x.current=B,M(!0),I.current=!0,k.current=!1,u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null,j()},v))});f.current=()=>{ae(),u.current&&(clearTimeout(u.current),u.current=null)}};return queueMicrotask(()=>{m||(h=requestAnimationFrame(g))}),()=>{var N;m=!0,cancelAnimationFrame(h),(N=f.current)==null||N.call(f)}},[y,e,a,c,v,S,w,j]),i.useEffect(()=>{var h;if(!y||!e)return;const s=(h=e.getLexicalEditor())==null?void 0:h.getRootElement();if(!s)return;const m=()=>{u.current&&(clearTimeout(u.current),u.current=null),I.current&&j()};return s.addEventListener("blur",m),()=>s.removeEventListener("blur",m)},[y,e,j]),i.useEffect(()=>{if(!y)return;const s=()=>{document.visibilityState==="hidden"&&(u.current&&(clearTimeout(u.current),u.current=null),I.current&&j())},m=()=>{I.current&&(u.current&&(clearTimeout(u.current),u.current=null),j())};return document.addEventListener("visibilitychange",s),window.addEventListener("beforeunload",m),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("beforeunload",m)}},[y,j]);async function te(){await $e(a),P(!1),M(!1),I.current=!1,k.current=!1,x.current=""}async function J(){const s=await Ie(a);return s?s.content:null}function ne(){P(!0),M(!1),I.current=!1,b(Date.now()),k.current=!0,e&&(x.current=Q(e)??"")}return{isDirty:H,draftExists:Z,lastSavedAt:p,clearDraft:te,loadDraftContent:J,markDraftSaved:ne}}function en({isDirty:e,draftExists:a}){const c=e&&!a;i.useEffect(()=>{if(!c)return;const v=y=>{y.preventDefault()};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[c])}function me(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}const Ne='{"root":{"direction":"ltr","format":"","indent":0,"version":1,"type":"root","children":[{"direction":"ltr","format":"","indent":0,"version":1,"textFormat":0,"textStyle":"","children":[],"type":"paragraph"}]}}';function De(e){const c=(e instanceof Error?e.message:String(e)).trim();return/^File too large$/i.test(c)?"文件过大(单文件上限 55MB)":/^unsupported file type$/i.test(c)?"不支持的文件类型":/^not an image$/i.test(c)?"不是有效的图片文件":c||"上传失败"}function tn(e,a){if(!e)return a==="json"?Ne:e;if(a!=="json")return e;try{const c=JSON.parse(e);if(c!=null&&c.root&&Array.isArray(c.root.children)&&c.root.children.length===0)return Ne}catch{}return e}function nn({editor:e}){const{visible:a}=Rt();return n.jsx("div",{className:"mdocs-outline-siderail",style:{flexShrink:0,overflow:"hidden",transition:"width 0.2s ease",width:a?200:0},children:n.jsx("div",{style:{width:200},children:n.jsx(At,{editor:e})})})}function yn(e){const{t:a,lang:c}=Ye(),[v,y]=i.useState(!1),[S,w]=i.useState(!1),H=i.useRef(null),M=i.useRef(null),[Z,P]=i.useState([]),[p,b]=i.useState(!1),[u,f]=i.useState(e.meta.permission),[k,x]=i.useState(!1),[I,E]=i.useState(!1),[ee,F]=i.useState(!1),[T,j]=i.useState(new Map),[te,J]=i.useState(!1);i.useEffect(()=>{const t=o=>{H.current&&!H.current.contains(o.target)&&y(!1),M.current&&!M.current.contains(o.target)&&w(!1)};return(v||S)&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[v,S]),i.useEffect(()=>{let t=!0;return Je().then(o=>{t&&P(o)}).catch(()=>{}),()=>{t=!1}},[]);function ne(t){const o=Z.find(l=>l.visitorId===t);return(o==null?void 0:o.visitorName)??t.slice(0,8)}const[s,m]=i.useState(e.initialDisplayName),[h,U]=i.useState(!1),[g,O]=i.useState(!1),[L,N]=i.useState(!1),[ae,B]=i.useState(()=>localStorage.getItem("mdocs.autoEdit")!=="false"),D=e.canEdit&&ae,[d,fe]=i.useState(null),[Pe,he]=i.useState(!1),ie=i.useRef(null);i.useLayoutEffect(()=>{he(!1),fe(null),ie.current=null},[e.meta.documentId]),i.useEffect(()=>{const t=requestAnimationFrame(()=>he(!0));return()=>cancelAnimationFrame(t)},[e.meta.documentId]);const R=i.useMemo(()=>{var t;if(!e.initialContent)return"json";try{const o=JSON.parse(e.initialContent);return Array.isArray((t=o==null?void 0:o.root)==null?void 0:t.children)?"json":"markdown"}catch{return"markdown"}},[e.initialContent,e.contentRevision]),W=i.useMemo(()=>tn(e.initialContent||"",R),[e.initialContent,R,e.contentRevision]),{isDirty:ye,draftExists:q,markDraftSaved:Te}=pt({editor:d,documentId:e.meta.documentId,displayName:s,enabled:e.canEdit,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}});i.useEffect(()=>{var t;(t=e.onDraftExistsChange)==null||t.call(e,q)},[q,e.onDraftExistsChange]),en({isDirty:ye,draftExists:q}),i.useEffect(()=>{if(d)try{d.setDocument(R,W)}catch{}},[d,e.meta.documentId,e.contentRevision,W,R]),i.useEffect(()=>{d==null||d.setLocale(c==="zh"?ot:st)},[d,c]),i.useEffect(()=>{m(e.initialDisplayName)},[e.initialDisplayName,e.meta.documentId,e.contentRevision]),i.useEffect(()=>{f(e.meta.permission)},[e.meta.permission,e.meta.documentId]),i.useEffect(()=>{let t=!0;return(async()=>{try{const o=await Ge(e.meta.documentId);t&&O(o.bookmarked)}catch{}})(),()=>{t=!1}},[e.meta.documentId]);async function oe(){var t,o;if(!L){N(!0);try{g?(await et(e.meta.documentId),O(!1),(t=e.onShowToast)==null||t.call(e,a("bookmarkRemoved"))):(await tt(e.meta.documentId),O(!0),(o=e.onShowToast)==null||o.call(e,a("bookmarkAdded")))}finally{N(!1)}}}i.useEffect(()=>(e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=Fe),()=>{e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=void 0)})),i.useEffect(()=>{if(e.exportMarkdownRef)return e.exportMarkdownRef.current=()=>{const t=ie.current;if(!t)return"";try{const o=t.getDocument("markdown");return typeof o=="string"?o:String(o??"")}catch{return""}},()=>{e.exportMarkdownRef&&(e.exportMarkdownRef.current=void 0)}});function Le(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const Be=i.useCallback(t=>{ie.current=t,fe(t);const o=W;if(!o)return;const l=()=>{try{t.setDocument(R,o)}catch{requestAnimationFrame(()=>{try{t.setDocument(R,o)}catch{}})}};queueMicrotask(()=>{queueMicrotask(l)})},[R,W]);async function se(){if(!(!d||!e.canEdit)){U(!0);try{const t=me(d);if(!t)return;await e.onPublish(t,s,e.meta.documentId)}catch(t){throw t}finally{U(!1)}}}async function ge(){if(!e.canEdit)return;const t=e.initialDisplayName.trim();if(s.trim()!==t)try{await se()}catch{}}const A=i.useMemo(()=>e.domains.find(t=>t.domainId===e.meta.domainId),[e.domains,e.meta.domainId]),_e=i.useMemo(()=>{const t=(A==null?void 0:A.permission)??"public";return Ke(t)},[A==null?void 0:A.permission]);function Oe(t){return t===X.PRIVATE?a("permissionPrivate"):t===X.DOMAIN_READ?a("permissionInvite"):t===X.DOMAIN_WRITE?a("permissionDomainWrite"):t===X.PUBLIC_READ?a("permissionPublicRead"):a("permissionPublicEdit")}async function ze(){var t;if(k||u===e.meta.permission){b(!1);return}x(!0);try{const l=(d?me(d):null)??e.initialContent;await e.onPublish(l,s,e.meta.documentId,u),b(!1),(t=e.onShowToast)==null||t.call(e,a("docInfoPermissionUpdated"))}finally{x(!1)}}async function He(t){var o;if(!te){J(!0);try{const l=new Set(t.map(r=>r.visitorId)),_=new Map(t.map(r=>[r.visitorId,r.permission]));for(const[r]of T)l.has(r)||await at(e.meta.documentId,r);for(const{visitorId:r,permission:V}of t){const $=T.get(r);(!$||$!==V)&&await it(e.meta.documentId,r,V)}E(!1),(o=e.onShowToast)==null||o.call(e,a("docInfoInviteSuccess",{count:t.length}))}finally{J(!1)}}}async function Fe(){if(!d||!e.canEdit)return;if(!ye){console.log("[DocumentEditor.saveDraft] skipped: not dirty, documentId:",e.meta.documentId);return}const t=me(d);t&&(console.log("[DocumentEditor.saveDraft] saving draft, documentId:",e.meta.documentId,"content preview:",t.slice(0,80)),Te(),await Re(e.meta.documentId).execute(()=>Ae({documentId:e.meta.documentId,content:t,displayName:s,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}})))}const Ue=i.useMemo(()=>[{icon:Pt,key:"h1",label:"Heading 1",onSelect:t=>{t.dispatchCommand(de,{tag:"h1"})}},{icon:Tt,key:"h2",label:"Heading 2",onSelect:t=>{t.dispatchCommand(de,{tag:"h2"})}},{icon:Lt,key:"h3",label:"Heading 3",onSelect:t=>{t.dispatchCommand(de,{tag:"h3"})}},{type:"divider"},{icon:Bt,key:"hr",label:"Hr",onSelect:t=>{t.dispatchCommand(rt,{})}},{icon:_t,key:"table",label:"Table",onSelect:t=>{t.dispatchCommand(ct,{columns:"3",rows:"3"})}},{icon:Ot,key:"tex",label:"TeX",onSelect:t=>{t.dispatchCommand(lt,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>t.focus())}},{type:"divider"},{key:"file",label:"File",onSelect:t=>{Ht(o=>{for(const l of o)t.dispatchCommand(Nt,{file:l})},".pdf,.zip,.txt,.md,.csv,.html,.htm,audio/*,*/*")}},{key:"insert-link",label:"Insert Link",onSelect:t=>{t.dispatchCommand(dt,{url:"https://example.com"}),queueMicrotask(()=>t.focus())}},{key:"insert-codeInline",label:"Inline Code",onSelect:t=>{t.dispatchCommand(ut,void 0),queueMicrotask(()=>t.focus())}},{key:"insert-codeBlock",label:"Code Block",onSelect:t=>{t.dispatchCommand(mt,void 0),queueMicrotask(()=>t.focus())}},{icon:zt,key:"meta2d",label:"Meta2d",onSelect:t=>{t.dispatchCommand(ft,void 0),queueMicrotask(()=>t.focus())}},{icon:Xe,key:"markmap",label:"Markmap",onSelect:t=>{t.dispatchCommand(ht,void 0),queueMicrotask(()=>t.focus())}}].map(t=>"type"in t&&t.type==="divider"?t:{...t,extra:n.jsx("span",{style:{color:"var(--mdocs-text-muted)",fontFamily:"monospace",fontSize:12},children:t.key})}),[]),We=i.useMemo(()=>[yt,gt,xt,Me,vt,bt,kt,It,jt,Ct,St,ue(wt,{children:d?n.jsx(Ee,{editor:d,floating:!0,outlineCollapseTitle:a("outlineHide"),outlineExpandTitle:a("outlineShow"),outlineToggle:!0}):null}),ue(Dt,{handleUpload:async t=>{var o;try{return{url:await we(t,e.meta.documentId)}}catch(l){throw(o=e.onShowError)==null||o.call(e,De(l)),l}}}),ue(Me,{defaultBlockImage:!0,needRehost:t=>t.startsWith("blob:"),handleRehost:async t=>{var o;try{const _=await(await fetch(t)).blob(),r=new File([_],"image.png",{type:_.type});return{url:await we(r,e.meta.documentId)}}catch(l){throw(o=e.onShowError)==null||o.call(e,De(l)),l}}})],[d,a,e.meta.documentId,e.onShowError]),C=!!e.readerChrome,[z,re]=i.useState(!1),G=i.useRef(null),[xe,ce]=i.useState(0);i.useEffect(()=>{if(!C){re(!1),ce(0);return}if(z)return;const t=window.setTimeout(()=>re(!0),2800);return()=>window.clearTimeout(t)},[C,z,e.meta.documentId]),i.useEffect(()=>{w(!1),y(!1)},[e.meta.documentId]);function qe(t){!C||z||t.target.closest("button, a, input, textarea, select")||(G.current={startY:t.clientY,dragging:!0},t.currentTarget.setPointerCapture(t.pointerId))}function Ve(t){const o=G.current;if(!(o!=null&&o.dragging))return;const l=t.clientY-o.startY;ce(Math.max(-72,Math.min(0,l)))}function ve(t){const o=G.current;if(!(o!=null&&o.dragging))return;G.current=null;const l=t.clientY-o.startY;ce(0),l<-36&&re(!0);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}function K(){y(!1),w(!1)}function be(t,o){const l=(o==null?void 0:o.includeBookmark)??!0,_={width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{padding:"4px 16px",fontSize:"13px"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoCreator")}),n.jsx("span",{children:ne(e.meta.ownerVisitorId)})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoCreatedAt")}),n.jsx("span",{children:new Date(e.meta.createdAt).toLocaleString(c==="zh"?"zh-CN":"en-US")})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoSize")}),n.jsx("span",{children:Le(new Blob([e.initialContent]).size)})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[n.jsx("span",{style:{color:"var(--mdocs-text-muted, #888)"},children:a("docInfoUpdatedAt")}),n.jsx("span",{children:new Date(e.meta.updatedAt).toLocaleString(c==="zh"?"zh-CN":"en-US")})]})]}),n.jsx("div",{style:{height:"1px",background:"var(--mdocs-border, #e5e5e5)",margin:"8px 0"}}),l?n.jsxs("button",{type:"button",style:_,onMouseEnter:r=>{r.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:r=>{r.currentTarget.style.background="none"},onClick:()=>{oe(),t()},children:[n.jsx("span",{children:g?"⭐":"☆"}),n.jsx("span",{children:a(g?"bookmarkRemove":"bookmarkAdd")})]}):null,e.canManageInvites?n.jsxs("button",{type:"button",style:_,onMouseEnter:r=>{r.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:r=>{r.currentTarget.style.background="none"},onClick:()=>{t(),(async()=>{F(!0);try{const r=await nt(e.meta.documentId),V=new Map(r.map($=>[$.visitorId,$.permission]));j(V),E(!0)}finally{F(!1)}})()},children:[n.jsx(Xt,{size:14}),n.jsx("span",{children:a("docInfoInviteMember")})]}):null,n.jsxs("button",{type:"button",style:_,onMouseEnter:r=>{r.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:r=>{r.currentTarget.style.background="none"},onClick:()=>{t(),f(e.meta.permission),b(!0)},children:[n.jsx(Yt,{size:14}),n.jsx("span",{children:a("docInfoChangePermission")})]})]})}return n.jsxs("div",{className:"mdocs-editor"+(C?" mdocs-editor--reader":"")+(C&&z?" mdocs-editor--reader-docked":""),children:[n.jsx("div",{className:"mdocs-editor-toolbar"+(C?z?" mdocs-editor-toolbar--docked":" mdocs-editor-toolbar--float":""),style:C&&!z&&xe!==0?{transform:`translateY(${xe}px)`}:void 0,children:C?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mdocs-editor-toolbar-leading",onPointerDown:qe,onPointerMove:Ve,onPointerUp:ve,onPointerCancel:ve,children:[n.jsx("button",{type:"button",className:"mdocs-reader-nav-btn",onClick:()=>{var t;return(t=e.onOpenMobileNav)==null?void 0:t.call(e)},"aria-label":a("expandSidebar"),children:n.jsx(Qe,{size:18,strokeWidth:1.75})}),n.jsx("input",{className:"mdocs-editor-title-input",value:s,onChange:t=>m(t.target.value),onBlur:()=>void ge(),placeholder:a("displayNamePlaceholder"),disabled:!D,readOnly:!D})]}),n.jsx(je,{domains:e.domains.length?e.domains:[Ce],value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:a("currentDomainAria"),localizeName:t=>le(t,c,a)}),e.canEdit?n.jsx("button",{type:"button",className:"primary mdocs-reader-action-btn",disabled:h,onClick:()=>{D||B(!0),se().catch(()=>{})},children:a(h?"publishing":"publish")}):null,n.jsxs("div",{ref:M,className:"mdocs-reader-more-menu",children:[n.jsx("button",{type:"button",className:"mdocs-reader-more-btn","aria-label":"更多","aria-expanded":S,onClick:()=>w(t=>!t),children:n.jsx(Wt,{size:18,strokeWidth:1.75})}),S?n.jsxs("div",{className:"mdocs-reader-more-dropdown card",children:[n.jsxs("button",{type:"button",className:"mdocs-reader-more-item",disabled:L,onClick:()=>{oe(),K()},children:[n.jsx(Se,{size:16,strokeWidth:1.5,style:{color:g?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:g?"#faad14":"none"}}),n.jsx("span",{children:a(g?"bookmarkRemove":"bookmarkAdd")})]}),e.canEdit?n.jsx("button",{type:"button",className:"mdocs-reader-more-item mdocs-reader-more-item--danger",disabled:h,onClick:()=>{K(),e.onDelete()},children:n.jsx("span",{children:a("delete")})}):null,n.jsx("div",{className:"mdocs-reader-more-divider"}),be(K,{includeBookmark:!1})]}):null]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mdocs-editor-toolbar-leading",children:[n.jsx("input",{className:"mdocs-editor-title-input",value:s,onChange:t=>m(t.target.value),onBlur:()=>void ge(),placeholder:a("displayNamePlaceholder"),disabled:!D}),n.jsx(je,{domains:e.domains.length?e.domains:[Ce],value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:a("currentDomainAria"),localizeName:t=>le(t,c,a)}),e.onAiWrite?n.jsxs("button",{type:"button",className:"secondary",onClick:()=>{var t;return(t=e.onAiWrite)==null?void 0:t.call(e)},style:{padding:"4px 10px",whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",gap:6},children:[n.jsx("img",{src:Ze,alt:"",width:16,height:16,style:{display:"block"}}),"帮写"]}):null]}),n.jsx("span",{className:"mdocs-editor-toolbar-spacer","aria-hidden":!0}),n.jsxs("div",{className:"mdocs-editor-toolbar-trailing",children:[n.jsxs("button",{type:"button",className:"secondary mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>void oe(),disabled:L,"data-tooltip":g?"取消收藏":"收藏",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,opacity:L?.5:1},children:[n.jsx(Se,{size:18,strokeWidth:1.5,style:{color:g?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:g?"#faad14":"none"}}),g?n.jsx("span",{children:"已收藏"}):null]}),n.jsxs("div",{className:"mdocs-editor-toolbar-actions",children:[e.onSyncClick?n.jsxs("button",{type:"button",className:"mdocs-sync-btn mdocs-tooltip mdocs-tooltip-bottom"+(e.syncBehind?" behind":""),"data-tooltip":e.syncBehind?a("syncBehindHint"):a("syncPull"),onClick:()=>{var t;return void((t=e.onSyncClick)==null?void 0:t.call(e))},style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx(Vt,{size:16,strokeWidth:1.5}),n.jsx("span",{children:a("syncPull")})]}):null,D?n.jsxs(n.Fragment,{children:[localStorage.getItem("mdocs.autoPublish")!=="true"&&n.jsxs("span",{className:"mdocs-save-indicator",children:[n.jsx("span",{className:"mdocs-save-dot "+(h?"saving":q?"unsaved":"saved")}),n.jsx("span",{children:a(h?"publishing":q?"unsaved":"published")})]}),n.jsx("button",{type:"button",className:"primary",disabled:h,onClick:()=>{se().catch(()=>{})},children:a(h?"publishing":"publish")}),n.jsx("button",{type:"button",className:"danger",disabled:h,onClick:e.onDelete,children:a("delete")})]}):null,!D&&e.canEdit?n.jsx("button",{type:"button",className:"primary",onClick:()=>B(!0),children:a("edit")}):null,n.jsxs("button",{type:"button",className:"secondary mdocs-tooltip mdocs-tooltip-bottom",onClick:e.onToggleComments,"data-tooltip":"评论",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,background:e.commentPanelOpen?"var(--mdocs-hover-bg, #f0f0f0)":void 0},children:[n.jsx(pe,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}}),e.commentCount>0?n.jsx("span",{style:{fontSize:"0.85rem"},children:e.commentCount}):null]}),n.jsxs("div",{ref:H,className:"mdocs-tooltip mdocs-tooltip-bottom","data-tooltip":a("docInfo"),style:{position:"relative"},children:[n.jsx("button",{type:"button",className:"secondary",onClick:()=>y(!v),style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(Gt,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}})}),v?n.jsx("div",{className:"mdocs-doc-info-dropdown",children:be(K)}):null]})]})]})]})}),p&&n.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:t=>{t.target===t.currentTarget&&b(!1)},children:n.jsxs("div",{className:"mdocs-dialog card",style:{maxWidth:480},children:[n.jsx("h1",{style:{fontSize:"1.1rem",marginBottom:12},children:a("docInfoChangePermission")}),n.jsxs("div",{className:"muted",style:{marginBottom:12},children:[a("domainPermission"),":",A?le(A.domainName,c,a):e.meta.domainId]}),n.jsx("div",{style:{display:"grid",gap:8},children:_e.map(t=>n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[n.jsx("input",{type:"radio",name:"doc-permission",value:t,checked:u===t,onChange:()=>f(t)}),n.jsx("span",{children:Oe(t)})]},t))}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[n.jsx("button",{type:"button",onClick:()=>b(!1),children:a("cancel")}),n.jsx("button",{type:"button",className:"primary",disabled:k,onClick:()=>void ze(),children:a(k?"publishing":"saveAndPublish")})]})]})}),e.canManageInvites&&n.jsx(Ft,{open:I,title:a("docInfoInviteMember"),initialSelectedIds:[...T.keys()],initialPermissions:T,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:a("invitePermissionRead")},{value:"edit",label:a("invitePermissionEdit")}],onClose:()=>E(!1),onConfirm:t=>{He(t)}}),n.jsx(Mt,{children:n.jsx(ke,{flex:1,style:{minHeight:0},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[D&&d&&!C?n.jsx(Ee,{editor:d,outlineCollapseTitle:a("outlineHide"),outlineExpandTitle:a("outlineShow"),outlineToggle:!0}):null,n.jsx("div",{className:"mdocs-editor-content-area",style:{flex:1,display:"flex",minHeight:0},children:n.jsxs(ke,{variant:"outlined",horizontal:!0,style:{background:"var(--mdocs-surface)",flex:1,minHeight:0,minWidth:0,borderRadius:0,outline:"none"},children:[n.jsx("div",{className:"mdocs-editor-scroll-host",children:Pe?n.jsx(Et,{content:W,type:R,confirmPasteMarkdown:!0,editable:D,onInit:Be,plugins:We,lineEmptyPlaceholder:a("displayNamePlaceholder"),placeholder:a("displayNamePlaceholder"),slashOption:{items:Ue},className:"mdocs-document-editor-root"},e.meta.documentId):null}),d&&n.jsx(nn,{editor:d})]})})]})})})]})}export{yn as DocumentEditor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as b,j as o}from"./react-vendor-
|
|
1
|
+
import{r as b,j as o}from"./react-vendor-BuABiQkA.js";import{b as V,av as _,aw as J,ax as Q,ay as X}from"./index-BkKvQv2F.js";import{E as Y,B as Z}from"./react-GP8hKHRA.js";import"./ui-BQStT3dY.js";import"./motion-DX3HNq_4.js";import"./diagram-CT58wBdU.js";import"./editor-CL03se2B.js";import"./plus-ECzYbQfA.js";import"./copy-BE64wQqi.js";function B({lexicalJson:e,onMarkdown:n,onError:s}){const[u,l]=b.useState(null),i=b.useRef(!1);return b.useEffect(()=>{i.current=!1},[e]),b.useEffect(()=>{if(!(!u||i.current))try{u.setDocument("json",e);const c=u.getDocument("markdown");typeof c=="string"&&(i.current=!0,n(c))}catch{s==null||s()}},[u,e,n,s]),o.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:o.jsx(Y,{content:e,type:"json",editable:!1,onInit:l,plugins:[Z]})})}function ee(e){const{t:n}=V(),[s,u]=b.useState(0),l=e.segments.filter(t=>t.kind==="conflict"),i=e.unresolvedCount>0;b.useEffect(()=>{if(l.length===0){u(0);return}u(t=>Math.min(t,l.length-1))},[l.length]);function c(t){l.length!==0&&u(d=>{var f;const a=(d+t+l.length)%l.length;return(f=document.getElementById(`mdocs-merge-hunk-${a}`))==null||f.scrollIntoView({block:"center",behavior:"smooth"}),a})}let r=-1;return o.jsxs("div",{className:"mdocs-merge-inline-pane",children:[o.jsxs("div",{className:"mdocs-merge-inline-toolbar",children:[o.jsx("span",{className:"mdocs-merge-inline-hint",children:i?n("mergeReviewHint"):l.length===0?n("mergeNoConflicts"):n("mergeEditAfterResolve")}),l.length>0?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:e.onUseAllMine,children:n("mergeUseAllMine")}),o.jsx("button",{type:"button",onClick:e.onUseAllTheirs,children:n("mergeUseAllTheirs")})]}):null]}),i?o.jsxs("div",{className:"mdocs-merge-inline",role:"document",children:[e.segments.map((t,d)=>{if(t.kind==="unchanged")return o.jsx("pre",{className:"mdocs-merge-inline-same",children:t.lines.map((x,g)=>o.jsxs("div",{className:"mdocs-ai-write-line ctx",children:[o.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),o.jsx("span",{className:"mdocs-ai-write-code",children:x||" "})]},g))},`u-${d}`);r+=1;const a=r,f=t.resolution!=="unresolved",m=a===s;return o.jsxs("div",{id:`mdocs-merge-hunk-${a}`,className:"mdocs-merge-inline-hunk"+(m?" is-active":"")+(f?" is-resolved":""),onClick:()=>u(a),children:[f?o.jsx("div",{className:"mdocs-merge-hunk-resolved-tag",children:t.resolution==="remote"?n("mergeReceive"):n("mergeReject")}):o.jsxs("div",{className:"mdocs-merge-hunk-actions",children:[o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:x=>{x.stopPropagation(),e.onReject(t.id)},children:n("mergeReject")}),o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:x=>{x.stopPropagation(),e.onReceive(t.id)},children:n("mergeReceive")})]}),o.jsxs("pre",{className:"mdocs-ai-write-hunk-pre",children:[t.localLines.map((x,g)=>o.jsxs("div",{className:"mdocs-ai-write-line del",children:[o.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),o.jsx("span",{className:"mdocs-ai-write-code",children:x||" "})]},`l${g}`)),t.remoteLines.map((x,g)=>o.jsxs("div",{className:"mdocs-ai-write-line add",children:[o.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),o.jsx("span",{className:"mdocs-ai-write-code",children:x||" "})]},`r${g}`))]})]},t.id)}),l.length>0?o.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"冲突导航",children:[o.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>c(-1),children:"↑"}),o.jsxs("span",{children:[s+1," / ",l.length]}),o.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>c(1),children:"↓"}),l[s]&&l[s].resolution==="unresolved"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>e.onReject(l[s].id),children:n("mergeReject")}),o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>e.onReceive(l[s].id),children:n("mergeReceive")})]}):null]}):null]}):o.jsx("textarea",{className:"mdocs-merge-inline-editor",value:e.editableMarkdown,onChange:t=>e.onEditableChange(t.target.value),spellCheck:!1})]})}function te(e,n){let s={};for(let i=0;i<n.length;i++){const c=n[i];s[c]?s[c].push(i):s[c]=[i]}let l=[{buffer1index:-1,buffer2index:-1,chain:null}];for(let i=0;i<e.length;i++){const c=e[i],r=s[c]||[];let t=0,d=l[0];for(let a=0;a<r.length;a++){const f=r[a];let m;for(m=t;m<l.length&&!(l[m].buffer2index<f&&(m===l.length-1||l[m+1].buffer2index>f));m++);if(m<l.length){const x={buffer1index:i,buffer2index:f,chain:l[m]};if(t===l.length?l.push(d):l[t]=d,t=m+1,d=x,t===l.length)break}}l[t]=d}return l[l.length-1]}function q(e,n){const s=te(e,n);let u=[],l=e.length,i=n.length;for(let c=s;c!==null;c=c.chain){const r=l-c.buffer1index-1,t=i-c.buffer2index-1;l=c.buffer1index,i=c.buffer2index,(r||t)&&u.push({buffer1:[l+1,r],buffer1Content:e.slice(l+1,l+1+r),buffer2:[i+1,t],buffer2Content:n.slice(i+1,i+1+t)})}return u.reverse(),u}function ne(e,n,s){let u=[];function l(t,d){u.push({ab:d,oStart:t.buffer1[0],oLength:t.buffer1[1],abStart:t.buffer2[0],abLength:t.buffer2[1]})}q(n,e).forEach(t=>l(t,"a")),q(n,s).forEach(t=>l(t,"b")),u.sort((t,d)=>t.oStart-d.oStart);let i=[],c=0;function r(t){t>c&&(i.push({stable:!0,buffer:"o",bufferStart:c,bufferLength:t-c,bufferContent:n.slice(c,t)}),c=t)}for(;u.length;){let t=u.shift(),d=t.oStart,a=t.oStart+t.oLength,f=[t];for(r(d);u.length;){const m=u[0],x=m.oStart;if(x>a)break;a=Math.max(a,x+m.oLength),f.push(u.shift())}if(f.length===1){if(t.abLength>0){const m=t.ab==="a"?e:s;i.push({stable:!0,buffer:t.ab,bufferStart:t.abStart,bufferLength:t.abLength,bufferContent:m.slice(t.abStart,t.abStart+t.abLength)})}}else{let m={a:[e.length,-1,n.length,-1],b:[s.length,-1,n.length,-1]};for(;f.length;){t=f.shift();const v=t.oStart,p=v+t.oLength,L=t.abStart,w=L+t.abLength;let S=m[t.ab];S[0]=Math.min(L,S[0]),S[1]=Math.max(w,S[1]),S[2]=Math.min(v,S[2]),S[3]=Math.max(p,S[3])}const x=m.a[0]+(d-m.a[2]),g=m.a[1]+(a-m.a[3]),j=m.b[0]+(d-m.b[2]),h=m.b[1]+(a-m.b[3]);let y={stable:!1,aStart:x,aLength:g-x,aContent:e.slice(x,g),oStart:d,oLength:a-d,oContent:n.slice(d,a),bStart:j,bLength:h-j,bContent:s.slice(j,h)};i.push(y)}c=a}return r(n.length),i}function le(e,n,s,u){u=Object.assign({excludeFalseConflicts:!0,stringSeparator:/\s+/},u),typeof e=="string"&&(e=e.split(u.stringSeparator)),typeof n=="string"&&(n=n.split(u.stringSeparator)),typeof s=="string"&&(s=s.split(u.stringSeparator));let i=[];const c=ne(e,n,s);let r=[];function t(){r.length&&i.push({ok:r}),r=[]}function d(a,f){if(a.length!==f.length)return!1;for(let m=0;m<a.length;m++)if(a[m]!==f[m])return!1;return!0}return c.forEach(a=>{a.stable?r.push(...a.bufferContent):u.excludeFalseConflicts&&d(a.aContent,a.bContent)?r.push(...a.aContent):(t(),i.push({conflict:{a:a.aContent,aIndex:a.aStart,o:a.oContent,oIndex:a.oStart,b:a.bContent,bIndex:a.bStart}}))}),t(),i}const se=/^<!--\s*mdocs-merge-conflict:([^\s]+)\s*-->$/;function ie(e){return`<!-- mdocs-merge-conflict:${e} -->`}function oe(e){const n=e.trim().match(se);return(n==null?void 0:n[1])??null}function M(e){return e===""?[]:e.split(`
|
|
2
2
|
`)}function H(e,n){return e.length===n.length&&e.every((s,u)=>s===n[u])}function ce(e,n,s){const u=M(e),l=M(n),i=M(s);if(l.length===0&&n==="")return re(e,s);const c=le(u,l,i),r=[];let t=0,d=0,a=0,f=0;const m=(g,j,h,y)=>{r.push({kind:"conflict",id:`conflict-${t}`,conflictKind:y,baseLines:g,localLines:j,remoteLines:h,resolution:"unresolved"}),t+=1},x=(g,j,h)=>{if(j.length===0&&g.length===0&&h.length===0)return;if(H(g,j)&&H(h,j)){j.length>0&&r.push({kind:"unchanged",lines:[...j]});return}if(g.length===j.length&&h.length===j.length){let v=[];const p=()=>{v.length>0&&(r.push({kind:"unchanged",lines:v}),v=[])};for(let L=0;L<j.length;L+=1){const w=j[L],S=g[L],N=h[L];S===w&&N===w?v.push(w):(p(),m([w],[S],[N],S!==w&&N!==w&&S!==N?"true_conflict":"change"))}p();return}const y=g.join(`
|
|
3
3
|
`)!==j.join(`
|
|
4
4
|
`)&&h.join(`
|