@fgbg/mdocs 0.8.24 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/agent-skills/changelog/SKILL.md +47 -1
- package/agent-skills/index.json +8 -1
- package/agent-skills/usage-knowledge-graph/SKILL.md +126 -0
- package/agent-skills/usage-onboarding-ai/SKILL.md +36 -5
- package/dist/server/agent/Agent/run.js +60 -34
- package/dist/server/agent/Agent/run.js.map +1 -1
- package/dist/server/agent/Agent/tools-documents.js +1 -1
- package/dist/server/agent/Agent/tools-documents.js.map +1 -1
- package/dist/server/agent/Config/config.js +234 -64
- package/dist/server/agent/Config/config.js.map +1 -1
- package/dist/server/agent/Config/config.test.js +109 -0
- package/dist/server/agent/Config/config.test.js.map +1 -0
- package/dist/server/app.js +2 -0
- package/dist/server/app.js.map +1 -1
- package/dist/server/cli/self-update.js +50 -32
- package/dist/server/cli/self-update.js.map +1 -1
- package/dist/server/db/repositories/agent-model-config.repo.js +58 -27
- package/dist/server/db/repositories/agent-model-config.repo.js.map +1 -1
- package/dist/server/db/schema.js +96 -1
- package/dist/server/db/schema.js.map +1 -1
- package/dist/server/documents/build-graph.e2e.test.js +65 -0
- package/dist/server/documents/build-graph.e2e.test.js.map +1 -0
- package/dist/server/documents/document.service.js +34 -2
- package/dist/server/documents/document.service.js.map +1 -1
- package/dist/server/documents/graph/change-ratio.js +29 -0
- package/dist/server/documents/graph/change-ratio.js.map +1 -0
- package/dist/server/documents/graph/change-ratio.test.js +38 -0
- package/dist/server/documents/graph/change-ratio.test.js.map +1 -0
- package/dist/server/documents/graph/graph-agent.integration.test.js +95 -0
- package/dist/server/documents/graph/graph-agent.integration.test.js.map +1 -0
- package/dist/server/documents/graph/graph-agent.js +185 -0
- package/dist/server/documents/graph/graph-agent.js.map +1 -0
- package/dist/server/documents/graph/graph-file.js +58 -0
- package/dist/server/documents/graph/graph-file.js.map +1 -0
- package/dist/server/documents/graph/graph-file.test.js +28 -0
- package/dist/server/documents/graph/graph-file.test.js.map +1 -0
- package/dist/server/documents/graph/index.js +183 -0
- package/dist/server/documents/graph/index.js.map +1 -0
- package/dist/server/documents/graph/lifecycle.js +104 -0
- package/dist/server/documents/graph/lifecycle.js.map +1 -0
- package/dist/server/documents/graph/llm-chains.js +135 -0
- package/dist/server/documents/graph/llm-chains.js.map +1 -0
- package/dist/server/documents/graph/llm-utils.js +19 -0
- package/dist/server/documents/graph/llm-utils.js.map +1 -0
- package/dist/server/documents/graph/llm-utils.test.js +34 -0
- package/dist/server/documents/graph/llm-utils.test.js.map +1 -0
- package/dist/server/documents/graph/tools/concept-relations.tool.js +49 -0
- package/dist/server/documents/graph/tools/concept-relations.tool.js.map +1 -0
- package/dist/server/documents/graph/tools/extract-knowledge-points.tool.js +45 -0
- package/dist/server/documents/graph/tools/extract-knowledge-points.tool.js.map +1 -0
- package/dist/server/documents/graph/tools/generate-contains.tool.js +41 -0
- package/dist/server/documents/graph/tools/generate-contains.tool.js.map +1 -0
- package/dist/server/documents/graph/tools/induce-concepts.tool.js +43 -0
- package/dist/server/documents/graph/tools/induce-concepts.tool.js.map +1 -0
- package/dist/server/documents/graph/types.js +12 -0
- package/dist/server/documents/graph/types.js.map +1 -0
- package/dist/server/documents/graph/utils.js +41 -0
- package/dist/server/documents/graph/utils.js.map +1 -0
- package/dist/server/documents/graph/utils.test.js +87 -0
- package/dist/server/documents/graph/utils.test.js.map +1 -0
- package/dist/server/documents/graph-cache-io.js +254 -0
- package/dist/server/documents/graph-cache-io.js.map +1 -0
- package/dist/server/documents/graph-lifecycle.js +19 -0
- package/dist/server/documents/graph-lifecycle.js.map +1 -0
- package/dist/server/documents/graph-task.js +232 -0
- package/dist/server/documents/graph-task.js.map +1 -0
- package/dist/server/documents/graph.integration.test.js +213 -0
- package/dist/server/documents/graph.integration.test.js.map +1 -0
- package/dist/server/documents/graph.service.js +296 -0
- package/dist/server/documents/graph.service.js.map +1 -0
- package/dist/server/documents/markdown-to-lexical.js +111 -13
- package/dist/server/documents/markdown-to-lexical.js.map +1 -1
- package/dist/server/documents/markdown-to-lexical.test.js +37 -0
- package/dist/server/documents/markdown-to-lexical.test.js.map +1 -1
- package/dist/server/documents/tree.service.js +12 -6
- package/dist/server/documents/tree.service.js.map +1 -1
- package/dist/server/migrations/003-folder-desc-file-type.js +43 -0
- package/dist/server/migrations/003-folder-desc-file-type.js.map +1 -0
- package/dist/server/migrations/004-api-key-to-secrets.js +90 -0
- package/dist/server/migrations/004-api-key-to-secrets.js.map +1 -0
- package/dist/server/migrations/004-folder-desc-id.js +98 -0
- package/dist/server/migrations/004-folder-desc-id.js.map +1 -0
- package/dist/server/migrations/005-special-file-id-format.js +124 -0
- package/dist/server/migrations/005-special-file-id-format.js.map +1 -0
- package/dist/server/routes/agent.routes.js +69 -31
- package/dist/server/routes/agent.routes.js.map +1 -1
- package/dist/server/routes/assets.routes.js +68 -62
- package/dist/server/routes/assets.routes.js.map +1 -1
- package/dist/server/routes/assets.routes.upload.test.js +27 -0
- package/dist/server/routes/assets.routes.upload.test.js.map +1 -0
- package/dist/server/routes/documents.routes.js +1 -1
- package/dist/server/routes/documents.routes.js.map +1 -1
- package/dist/server/routes/folders.routes.js +2 -2
- package/dist/server/routes/folders.routes.js.map +1 -1
- package/dist/server/routes/graph.routes.js +112 -0
- package/dist/server/routes/graph.routes.js.map +1 -0
- package/dist/server/routes/tree.routes.js +1 -1
- package/dist/server/routes/tree.routes.js.map +1 -1
- package/dist/server/secrets/secrets-store.js +93 -0
- package/dist/server/secrets/secrets-store.js.map +1 -0
- package/dist/server/storage/paths.js +0 -1
- package/dist/server/storage/paths.js.map +1 -1
- package/dist/server/task-queue/TaskQueue.js +258 -0
- package/dist/server/task-queue/TaskQueue.js.map +1 -0
- package/dist/server/task-queue/TaskQueue.test.js +136 -0
- package/dist/server/task-queue/TaskQueue.test.js.map +1 -0
- package/dist/server/task-queue/index.js +18 -0
- package/dist/server/task-queue/index.js.map +1 -0
- package/dist/server/task-queue/log-store.js +84 -0
- package/dist/server/task-queue/log-store.js.map +1 -0
- package/dist/server/task-queue/types.js +5 -0
- package/dist/server/task-queue/types.js.map +1 -0
- package/dist/shared/docPath.js +3 -2
- package/dist/shared/docPath.js.map +1 -1
- package/dist/shared/file-types.js +35 -0
- package/dist/shared/file-types.js.map +1 -0
- package/dist/shared/graph-files.js +31 -0
- package/dist/shared/graph-files.js.map +1 -0
- package/dist/web/assets/AgentChatPanel-C8TMWDuE.js +6 -0
- package/dist/web/assets/AgentSkillFormCard-yk7PWF0W.js +6 -0
- package/dist/web/assets/AiWriteWorkbench-ChCJt24m.js +7 -0
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-DqPXDJHY.js → DiagramEditor-NtNY3sZL-Bw4wHaBD.js} +1 -1
- package/dist/web/assets/DocumentEditor-B3Dsq02C.js +26 -0
- package/dist/web/assets/{MergeView-Y3zB8V5p.js → MergeView-royv5YkB.js} +1 -1
- package/dist/web/assets/PlaygroundPage-B-_1l4Ix.js +8 -0
- package/dist/web/assets/SettingsPage-D8HfepZ8.js +1 -0
- package/dist/web/assets/{Toolbar-B36NxaTc.js → Toolbar-BDJ6WABq.js} +16 -21
- package/dist/web/assets/{VisitorPickerModal-drnOuPLP.js → VisitorPickerModal-DPKIoySi.js} +1 -1
- package/dist/web/assets/{copy-CX8GOyUb.js → copy-UwfRYkpI.js} +1 -1
- package/dist/web/assets/{diagram-3lhA7FYR.js → diagram--gCCJK__.js} +545 -545
- package/dist/web/assets/index-4TuRcE3b.js +248 -0
- package/dist/web/assets/index-C4ESYs7f.css +1 -0
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-CCgjRlVJ.js → meta2dEngine-BD2XbzaV-D1J2-XNv.js} +1 -1
- package/dist/web/assets/{motion-92iQWeIW.js → motion-DddvD-ez.js} +1 -1
- package/dist/web/assets/{plus-BWV299MC.js → plus-CiGwts52.js} +1 -1
- package/dist/web/assets/{react-BUhFwPCj.js → react-B99eF5mm.js} +146 -151
- package/dist/web/assets/{ui-06fxEgif.js → ui-BHvBMRFE.js} +3 -3
- package/dist/web/index.html +5 -4
- package/package.json +2 -1
- package/dist/web/assets/AgentChatPanel-BTCyf9Ww.js +0 -1
- package/dist/web/assets/AgentSkillFormCard-CAD6QqQ0.js +0 -6
- package/dist/web/assets/AiWriteWorkbench-PVv90TJS.js +0 -7
- package/dist/web/assets/DocumentEditor-zNIJgxe0.js +0 -21
- package/dist/web/assets/PlaygroundPage-DAaEm887.js +0 -8
- package/dist/web/assets/SettingsPage-DhdiNEhO.js +0 -1
- package/dist/web/assets/index-DgM2rYI-.js +0 -185
- package/dist/web/assets/index-S_lCknAk.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram
|
|
2
|
-
var hS=Object.defineProperty;var gS=(e,t,r)=>t in e?hS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var he=(e,t,r)=>gS(e,typeof t!="symbol"?t+"":t,r);import{r as d,j as N,R as q,a as bS,b as _o,c as vS,g as Tl,d as Xi,m as jl,T as su,e as M5,f as I5,h as F5,i as T5,k as j5,l as Db,n as yS,M as xS,o as wS,p as CS,q as _b,s as SS,t as kS,u as $S,v as DS,w as A5,S as _S,x as ES,y as MS,z as IS,A as ad,B as FS,_ as Ph,C as TS,P as jS,D as lu,E as AS,F as RS,G as zS,H as BS,I as PS,J as NS,K as OS,L as Eb,N as Nh,O as LS,Q as HS,U as qS,V as WS,W as VS,X as GS,Y as US,Z as XS,$ as YS,a0 as Mb,a1 as Ib,a2 as Fb,a3 as ma,a4 as KS,a5 as ZS,a6 as QS,a7 as JS}from"./react-vendor-BJFXgntS.js";import{c as ek,r as tk,g as rk,s as Oh,G as nk,m as al,u as ok,C as qn,M as ik,a as ak,_ as Xt,b as R5,d as Lh,T as sk,e as lk}from"./motion-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram--gCCJK__.js","assets/react-vendor-BJFXgntS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var hS=Object.defineProperty;var gS=(e,t,r)=>t in e?hS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var he=(e,t,r)=>gS(e,typeof t!="symbol"?t+"":t,r);import{r as d,j as N,R as q,a as bS,b as _o,c as vS,g as Tl,d as Xi,m as jl,T as su,e as M5,f as I5,h as F5,i as T5,k as j5,l as Db,n as yS,M as xS,o as wS,p as CS,q as _b,s as SS,t as kS,u as $S,v as DS,w as A5,S as _S,x as ES,y as MS,z as IS,A as ad,B as FS,_ as Ph,C as TS,P as jS,D as lu,E as AS,F as RS,G as zS,H as BS,I as PS,J as NS,K as OS,L as Eb,N as Nh,O as LS,Q as HS,U as qS,V as WS,W as VS,X as GS,Y as US,Z as XS,$ as YS,a0 as Mb,a1 as Ib,a2 as Fb,a3 as ma,a4 as KS,a5 as ZS,a6 as QS,a7 as JS}from"./react-vendor-BJFXgntS.js";import{c as ek,r as tk,g as rk,s as Oh,G as nk,m as al,u as ok,C as qn,M as ik,a as ak,_ as Xt,b as R5,d as Lh,T as sk,e as lk}from"./motion-DddvD-ez.js";const Hh=d.createContext(null);d.memo(({children:e,motion:t})=>N.jsx(Hh,{value:t,children:e}));const oee=()=>{const e=d.use(Hh);if(!e)throw new Error("Please wrap your app with <ConfigProvider> (or <MotionProvider>) and pass the motion component");return e};function ck(e){var t=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var o=e[n];if(typeof o!="string")throw new TypeError("Url must be a string. Received "+o);o!==""&&(n>0&&(o=o.replace(/^[\/]+/,"")),n<e.length-1?o=o.replace(/[\/]+$/,""):o=o.replace(/[\/]+$/,"/"),t.push(o))}var i=t.join("/");i=i.replace(/\/(\?|&|#[^!])/g,"$1");var a=i.split("?");return i=a.shift()+(a.length>0?"?":"")+a.join("&"),i}function Tb(){var e;return typeof arguments[0]=="object"?e=arguments[0]:e=[].slice.call(arguments),ck(e)}const uk="https://unpkg.com",dk="https://registry.npmmirror.com",z5=({pkg:e,version:t="latest",path:r,proxy:n})=>{switch(n){case"unpkg":return Tb(uk,`${e}@${t}`,r);default:return Tb(dk,e,t,"files",r)}},qh=d.createContext(null),B5=d.createContext({locale:"en",t:e=>e}),uc=e=>typeof(e==null?void 0:e.then)=="function",iee=d.memo(({children:e,config:t,locale:r,resources:n,motion:o})=>{const i=r??"en",[a,s]=d.useState(()=>n&&!uc(n)?n:void 0),[l,c]=d.useState(i),u=d.useRef(0);d.useEffect(()=>{const m=++u.current;if(!n){s(void 0),c(i);return}if(uc(n)){const h=i;n.then(g=>{u.current===m&&(s(g),c(h))}).catch(()=>{u.current});return}s(n),c(i)},[i,n]);const f=uc(n)?a:n,p=uc(n)?l:i;return N.jsx(B5,{value:d.useMemo(()=>{const m=Array.isArray(f)?f:f?Object.values(f):[],h=Object.assign({},...m);return{locale:p,t:v=>h[v]||v}},[p,f]),children:N.jsx(qh,{value:t??null,children:N.jsx(Hh,{value:o,children:e})})})}),jb=({pkg:e,version:t,path:r})=>z5({path:r,pkg:e,proxy:"aliyun",version:t}),Wh=()=>{const e=d.use(qh);return e?(e==null?void 0:e.proxy)!=="custom"?({pkg:t,version:r,path:n})=>z5({path:n,pkg:t,proxy:e.proxy,version:r}):(e==null?void 0:e.customCdnFn)||jb:jb},fk=()=>d.use(B5);function Fo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function cr(e){"@babel/helpers - typeof";return cr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cr(e)}function pk(e,t){if(cr(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(cr(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function P5(e){var t=pk(e,"string");return cr(t)=="symbol"?t:t+""}function mk(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,P5(n.key),n)}}function To(e,t,r){return t&&mk(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Kt(e,t,r){return(t=P5(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var hk=function(){function e(){Fo(this,e),Kt(this,"_cacheList",[ek])}return To(e,[{key:"add",value:function(r){var n=this.getCache(r.key);return n||(this._cacheList.push(r),r)}},{key:"delete",value:function(r){this._cacheList=this._cacheList.filter(function(n){return n.key!==r.key})}},{key:"hasCache",value:function(r){return this._cacheList.some(function(n){return n.key===r.key})}},{key:"getCache",value:function(r){return this._cacheList.find(function(n){return n.key===r})}},{key:"getCacheList",value:function(){return this._cacheList}}]),e}(),Ab=typeof document<"u",N5=function(t,r){return"".concat(t,"-").concat(r)},gk=function(t,r,n,o){var i=o.hashPriority;tk(t,r,n);var a=".".concat(N5(t.key,r.name)),s=i==="low"?":where(".concat(a,")"):a;if(t.inserted[r.name]===void 0){var l="",c=r;do{var u=t.insert(r===c?s:"",c,t.sheet,!0);!Ab&&u!==void 0&&(l+=u),c=c.next}while(c!==void 0);if(!Ab&&l.length!==0)return l}},Vh=function(t){return cr(t)==="object"&&"styles"in t&&"name"in t&&"toString"in t},bk=function e(t){for(var r="",n=0;n<t.length;n++){var o=t[n];if(o!==null){var i=void 0;switch(cr(o)){case"boolean":break;case"object":{if(Array.isArray(o))i=e(o);else{i="";for(var a in o)o[a]&&a&&(i&&(i+=" "),i+=a)}break}default:i=o}i&&(r&&(r+=" "),r+=i)}}return r},vk=function(t,r,n){var o=[],i=rk(t,o,n);return o.length<2?n:i+r(o)},yk=function(t,r){return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];var a=Oh(o,t.registered,void 0);return gk(t,a,!1,r),N5(t.key,a.name)}},xk=function(t,r){return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];var a=o.map(function(s){return Vh(s)?r(s):s});return vk(t.registered,r,bk(a))}},Gh=function(t,r){var n=yk(t,{hashPriority:r.hashPriority||"high",label:r.label}),o=xk(t,n);return{css:n,cx:o}},Al=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Oh(r)},O5="acss";function Rb(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function st(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rb(Object(r),!0).forEach(function(n){Kt(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rb(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var wk=function(t){return d.createContext(t)},Ck=function(t){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return d.memo(function(i){var a=t();return N.jsx(nk,{styles:Oh(n,void 0,st(st({},i),{},{theme:a}))})})}};const dt=e=>{const t=d.useRef(e);return t.current=e,d.useCallback((...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])};function uo(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}const zb=uo()?d.useLayoutEffect:d.useEffect,Wt=(e,t)=>{const r=d.useRef(!0);zb(()=>e(r.current),t),zb(()=>(r.current=!1,()=>{r.current=!0}),[])},S0=(e,t)=>{Wt(r=>{if(!r)return e()},t)},Sk=e=>{const t=d.useRef(!1),[r,n]=d.useState(e);d.useEffect(()=>(t.current=!1,()=>{t.current=!0}),[]);function o(i,a){a&&t.current||n(i)}return[r,o]};function er(e,t){const[r,n]=d.useState(e),o=t!==void 0?t:r;return Wt(i=>{i||n(t)},[t]),[o,n]}var L5={exports:{}},Zt={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-is.production.min.js
|
|
5
5
|
*
|
|
@@ -2710,7 +2710,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
2710
2710
|
overflow: hidden;
|
|
2711
2711
|
max-width: 100%;
|
|
2712
2712
|
height: auto;
|
|
2713
|
-
`})),WG=fr(wn.root,{defaultVariants:{variant:"filled"},variants:{variant:{filled:wn.filled,outlined:wn.outlined,borderless:wn.borderless}}}),VG="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjM0IzQjNCIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",GG="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjRUNFQ0VDIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",n9=d.memo(({children:e,visible:t})=>{const r=d.useRef(null);return d.useEffect(()=>{if(!r.current)return;const n=o=>{o.preventDefault()};t?r.current.addEventListener("wheel",n,{passive:!1}):r.current.removeEventListener("wheel",n)},[t]),N.jsx("div",{ref:r,children:e})});var UG={"image.copy":"Copy","image.copyFailed":"Copy Failed","image.copySuccess":"Copy Success","image.download":"Download","image.downloadFailed":"Download Failed","image.downloadSuccess":"Download Success","image.flipHorizontal":"Flip Horizontal","image.flipVertical":"Flip Vertical","image.rotateLeft":"Rotate Left","image.rotateRight":"Rotate Right","image.zoomIn":"Zoom In","image.zoomOut":"Zoom Out"};const XG=e=>new Promise((t,r)=>{const n=new Image,o=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(o);const i=document.createElement("canvas");i.width=n.naturalWidth,i.height=n.naturalHeight;const a=i.getContext("2d");if(!a){r(new Error("Canvas context not available"));return}a.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert to PNG"))},"image/png",1)},n.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},n.src=o}),YG=async e=>{const t=(e.type||"").toLowerCase();return t==="image/png"||t==="image/svg+xml"?{[t]:e}:{"image/png":await XG(e)}},KG=e=>{try{const t=new URL(e).pathname.match(/\/([^/]+)$/);return t?decodeURIComponent(t[1]):"image"}catch{return"image"}},ZG=e=>{var t;return{"image/svg+xml":"svg","image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/webp":"webp","image/gif":"gif"}[e==null?void 0:e.toLowerCase()]||((t=e==null?void 0:e.split("/")[1])==null?void 0:t.split("+")[0])||"png"},o9=d.memo(({children:e,info:t,minScale:r,maxScale:n})=>{const{t:o}=IW(UG),[i,a]=d.useState(null),[s,l]=d.useState(!1),[c,u]=d.useState(!1),{transform:{scale:f},actions:{onFlipY:p,onFlipX:m,onRotateLeft:h,onRotateRight:g,onZoomOut:v,onZoomIn:b},image:{url:y}}=t,x=d.useCallback(async()=>{u(!0);try{const S=await(await fetch(y,{mode:"cors"})).blob(),C=URL.createObjectURL(S);let k=KG(y);const D=ZG(S.type);k.includes(".")?k.endsWith(".svg+xml")&&(k=k.replace(/\.svg\+xml$/i,".svg")):k=`${k}.${D}`,await jW(C,k),URL.revokeObjectURL(C),La.success(o("image.downloadSuccess"))}catch{La.error(o("image.downloadFailed"))}finally{u(!1)}},[y,o]),w=d.useCallback(async()=>{l(!0);try{const S=await YG(await(await fetch(y,{mode:"cors"})).blob());await navigator.clipboard.write([new ClipboardItem(S)]),La.success(o("image.copySuccess"))}catch{La.error(o("image.copyFailed"))}finally{l(!1)}},[y,o]);return N.jsx(A1,{popupContainer:i??void 0,children:N.jsxs(ir,{horizontal:!0,className:wn.toolbar,gap:4,ref:a,children:[N.jsx(un,{icon:XH,title:o("image.flipHorizontal"),onClick:m}),N.jsx(un,{icon:GH,title:o("image.flipVertical"),onClick:p}),N.jsx(un,{icon:OH,title:o("image.rotateLeft"),onClick:h}),N.jsx(un,{icon:HH,title:o("image.rotateRight"),onClick:g}),N.jsx(un,{disabled:f===r,icon:tq,title:o("image.zoomOut"),onClick:v}),N.jsx(un,{disabled:f===n,icon:JH,title:o("image.zoomIn"),onClick:b}),N.jsx(un,{icon:e7,loading:s,title:o("image.copy"),onClick:w}),N.jsx(un,{icon:EH,loading:c,title:o("image.download"),onClick:x}),e]})})}),QG=e=>{const[t,r]=d.useState(!1);return d.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:u,...f}=e===!0?{}:e||{};return{actionsRender:(p,m)=>{const h=N.jsx(o9,{info:m,maxScale:a,minScale:i,children:s});return u?u(h,m):h},closeIcon:N.jsx(At,{color:"#fff",icon:Wu}),imageRender:(p,m)=>{const h=N.jsx(n9,{visible:t,children:p});return c?c(h,m):h},maxScale:a,minScale:i,onOpenChange:(p,m)=>{r(p),o==null||o(p,m),n==null||n(p,!p,m.current)},rootClassName:Fe(wn.preview,l),...f}},[e,t,wn])},{PreviewGroup:JG}=a1,i9=d.memo(({items:e,children:t,enable:r=!0,preview:n})=>{const o=QG(n);return r?N.jsx(JG,{items:e,preview:o,children:t}):t});i9.displayName="PreviewGroup";const eU=e=>{const[t,r]=d.useState(!1);return d.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:u,actionsRender:f,...p}=e===!0?{}:e||{};return{actionsRender:f||((m,h)=>{const g=N.jsx(o9,{info:h,maxScale:a,minScale:i,children:s});return u?u(g,h):g}),closeIcon:N.jsx(At,{color:"#fff",icon:Wu}),imageRender:(m,h)=>{const g=N.jsx(n9,{visible:t,children:m});return c?c(g,h):g},maxScale:a,minScale:i,onOpenChange:m=>{r(m),o==null||o(m),n==null||n(m,!m)},rootClassName:Fe(wn.preview,l),styles:{mask:{backdropFilter:"blur(8px)"}},...p}},[e,t,wn])},a9=d.memo(({ref:e,style:t,preview:r,isLoading:n,maxHeight:o="100%",maxWidth:i="100%",minHeight:a,minWidth:s,actions:l,className:c,alwaysShowActions:u,variant:f="filled",objectFit:p="cover",classNames:m,styles:h,onClick:g,width:v,height:b,...y})=>{const{isDarkMode:x}=En(),w=u?wn.actionsVisible:wn.actionsHidden,S=eU(r);return n?N.jsx("div",{onClick:g,children:N.jsx(oa.Avatar,{active:!0,style:{borderRadius:Ce.borderRadius,height:b,maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,width:v}})}):N.jsxs(ir,{className:Fe(WG({variant:f}),c),ref:e,style:t,children:[l&&N.jsx("div",{className:Fe(w,u?"":"actions-hidden"),children:l}),N.jsx(a1,{className:Fe(wn.image,m==null?void 0:m.image),fallback:x?VG:GG,height:b,loading:"lazy",preview:r===!1?!1:S,width:v,classNames:{root:Fe(wn.wrapper,m==null?void 0:m.wrapper)},style:{maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,objectFit:p||"cover",...h==null?void 0:h.image},styles:{root:h==null?void 0:h.wrapper},onClick:g,...y})]})});a9.displayName="Image";const ib=a9;ib.PreviewGroup=i9;const s9=[{displayName:"Lobe Theme",id:"lobe-theme"},{background:"#fbf9ff",displayName:"Mermaid Default",id:"default"},{background:"#fffcf8",displayName:"Mermaid Base",id:"base"},{background:"#000",displayName:"Mermaid Dark",id:"dark"},{background:"#f9ffeb",displayName:"Mermaid Forest",id:"forest"},{background:"#fff",displayName:"Mermaid Neutral",id:"neutral"}],Ko=new Map,R4=500,tU=()=>{if(Ko.size>R4){const e=Math.floor(R4*.2),t=Array.from(Ko.keys()).slice(0,e);for(const r of t)Ko.delete(r)}};let qf=null;const l9=()=>typeof window>"u"?Promise.resolve(null):(qf||(qf=Ph(()=>import("./diagram-3lhA7FYR.js").then(e=>e.d),__vite__mapDeps([0,1])).then(e=>e.default)),qf),c9=(e,t,r="strict")=>({fontFamily:e.fontFamilyCode,gantt:{useWidth:1920},securityLevel:r,startOnLoad:!1,theme:t||(e.isDarkMode?"dark":"neutral"),themeVariables:t?void 0:{errorBkgColor:e.colorTextDescription,errorTextColor:e.colorTextDescription,fontFamily:e.fontFamily,lineColor:e.colorTextSecondary,mainBkg:e.colorBgContainer,noteBkgColor:e.colorInfoBg,noteTextColor:e.colorInfoText,pie1:e.geekblue,pie2:e.colorWarning,pie3:e.colorSuccess,pie4:e.colorError,primaryBorderColor:e.colorBorder,primaryColor:e.colorBgContainer,primaryTextColor:e.colorText,secondaryBorderColor:e.colorInfoBorder,secondaryColor:e.colorInfoBg,secondaryTextColor:e.colorInfoText,tertiaryBorderColor:e.colorSuccessBorder,tertiaryColor:e.colorSuccessBg,tertiaryTextColor:e.colorSuccessText,textColor:e.colorText}}),rU=(e,{id:t,theme:r,securityLevel:n})=>{const o=f1(),[i,a]=d.useState(""),s=d.useMemo(()=>c9(o,r,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,r,n]),l=d.useMemo(()=>{const c=e.length<1e4?e:_l.hashStr(e);return[t,r||(o.isDarkMode?"d":"l"),c].filter(Boolean).join("-")},[e,t,o.isDarkMode,r]);return d.useEffect(()=>{const c=Ko.get(l);if(c){c.then(f=>{a(f)}).catch(()=>{});return}const u=(async()=>{try{const f=await l9();if(!f)return"";if(await f.parse(e)){f.initialize(s);const{svg:p}=await f.render(t,e);return p}else throw new Error("Mermaid 语法无效")}catch(f){return console.error("Mermaid 解析错误:",f),""}})();Ko.set(l,u),tU(),u.then(f=>{Ko.get(l)===u&&a(f)}).catch(()=>{Ko.get(l)===u&&Ko.delete(l)})},[l,e,t,s]),i},u9=d.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=d.useMemo(()=>{var g;if(!l)return(g=s9.find(v=>v.id===i))==null?void 0:g.background},[l,i]),u=rU(s,{id:q8(`mermaid-${d.useId()}`),theme:l?void 0:i}),f=!u,[p,m]=d.useState();d.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),d.useEffect(()=>{if(f||!u)return;let g=u;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(u,"image/svg+xml"),y=b.documentElement;if(y&&y.hasAttribute("viewBox")){const x=y.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(y.setAttribute("width",x[2]),y.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const v=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(v))},[f,u]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(ib,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Loading..."})})});u9.displayName="StaticMermaid";const nU=(e,{enabled:t=!0,id:r,theme:n})=>{const o=f1(),[i,a]=d.useState(""),s=d.useRef(""),l=d.useRef(e),c=d.useRef(void 0),u=d.useMemo(()=>c9(o,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,n]);return d.useEffect(()=>{l.current=e},[e]),d.useEffect(()=>{if(!t){a(""),s.current="";const m=c.current;m&&clearTimeout(m);return}const f=l.current;if(f===s.current&&i)return;const p=c.current;return p&&clearTimeout(p),c.current=setTimeout(async()=>{const m=l.current;if(m===f)try{const h=await l9();if(!h)return;if(await h.parse(m)){h.initialize(u);const{svg:g}=await h.render(r,m);l.current===m&&(a(g),s.current=m)}}catch(h){m===l.current&&console.error("Mermaid 解析错误:",h)}},300),()=>{const m=c.current;m&&clearTimeout(m)}},[t,e,r,u,i]),i},d9=d.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=d.useMemo(()=>{var g;if(!l)return(g=s9.find(v=>v.id===i))==null?void 0:g.background},[l,i]),u=nU(s,{enabled:!0,id:q8(`mermaid-${d.useId()}`),theme:l?void 0:i}),f=!u,[p,m]=d.useState();d.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),d.useEffect(()=>{if(f||!u){m(void 0);return}let g=u;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(u,"image/svg+xml"),y=b.documentElement;if(y&&y.hasAttribute("viewBox")){const x=y.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(y.setAttribute("width",x[2]),y.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const v=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(v))},[f,u]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(ib,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Rendering..."})})});d9.displayName="StreamMermaid";const oU=Jl`
|
|
2713
|
+
`})),WG=fr(wn.root,{defaultVariants:{variant:"filled"},variants:{variant:{filled:wn.filled,outlined:wn.outlined,borderless:wn.borderless}}}),VG="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjM0IzQjNCIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",GG="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjRUNFQ0VDIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",n9=d.memo(({children:e,visible:t})=>{const r=d.useRef(null);return d.useEffect(()=>{if(!r.current)return;const n=o=>{o.preventDefault()};t?r.current.addEventListener("wheel",n,{passive:!1}):r.current.removeEventListener("wheel",n)},[t]),N.jsx("div",{ref:r,children:e})});var UG={"image.copy":"Copy","image.copyFailed":"Copy Failed","image.copySuccess":"Copy Success","image.download":"Download","image.downloadFailed":"Download Failed","image.downloadSuccess":"Download Success","image.flipHorizontal":"Flip Horizontal","image.flipVertical":"Flip Vertical","image.rotateLeft":"Rotate Left","image.rotateRight":"Rotate Right","image.zoomIn":"Zoom In","image.zoomOut":"Zoom Out"};const XG=e=>new Promise((t,r)=>{const n=new Image,o=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(o);const i=document.createElement("canvas");i.width=n.naturalWidth,i.height=n.naturalHeight;const a=i.getContext("2d");if(!a){r(new Error("Canvas context not available"));return}a.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert to PNG"))},"image/png",1)},n.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},n.src=o}),YG=async e=>{const t=(e.type||"").toLowerCase();return t==="image/png"||t==="image/svg+xml"?{[t]:e}:{"image/png":await XG(e)}},KG=e=>{try{const t=new URL(e).pathname.match(/\/([^/]+)$/);return t?decodeURIComponent(t[1]):"image"}catch{return"image"}},ZG=e=>{var t;return{"image/svg+xml":"svg","image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/webp":"webp","image/gif":"gif"}[e==null?void 0:e.toLowerCase()]||((t=e==null?void 0:e.split("/")[1])==null?void 0:t.split("+")[0])||"png"},o9=d.memo(({children:e,info:t,minScale:r,maxScale:n})=>{const{t:o}=IW(UG),[i,a]=d.useState(null),[s,l]=d.useState(!1),[c,u]=d.useState(!1),{transform:{scale:f},actions:{onFlipY:p,onFlipX:m,onRotateLeft:h,onRotateRight:g,onZoomOut:v,onZoomIn:b},image:{url:y}}=t,x=d.useCallback(async()=>{u(!0);try{const S=await(await fetch(y,{mode:"cors"})).blob(),C=URL.createObjectURL(S);let k=KG(y);const D=ZG(S.type);k.includes(".")?k.endsWith(".svg+xml")&&(k=k.replace(/\.svg\+xml$/i,".svg")):k=`${k}.${D}`,await jW(C,k),URL.revokeObjectURL(C),La.success(o("image.downloadSuccess"))}catch{La.error(o("image.downloadFailed"))}finally{u(!1)}},[y,o]),w=d.useCallback(async()=>{l(!0);try{const S=await YG(await(await fetch(y,{mode:"cors"})).blob());await navigator.clipboard.write([new ClipboardItem(S)]),La.success(o("image.copySuccess"))}catch{La.error(o("image.copyFailed"))}finally{l(!1)}},[y,o]);return N.jsx(A1,{popupContainer:i??void 0,children:N.jsxs(ir,{horizontal:!0,className:wn.toolbar,gap:4,ref:a,children:[N.jsx(un,{icon:XH,title:o("image.flipHorizontal"),onClick:m}),N.jsx(un,{icon:GH,title:o("image.flipVertical"),onClick:p}),N.jsx(un,{icon:OH,title:o("image.rotateLeft"),onClick:h}),N.jsx(un,{icon:HH,title:o("image.rotateRight"),onClick:g}),N.jsx(un,{disabled:f===r,icon:tq,title:o("image.zoomOut"),onClick:v}),N.jsx(un,{disabled:f===n,icon:JH,title:o("image.zoomIn"),onClick:b}),N.jsx(un,{icon:e7,loading:s,title:o("image.copy"),onClick:w}),N.jsx(un,{icon:EH,loading:c,title:o("image.download"),onClick:x}),e]})})}),QG=e=>{const[t,r]=d.useState(!1);return d.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:u,...f}=e===!0?{}:e||{};return{actionsRender:(p,m)=>{const h=N.jsx(o9,{info:m,maxScale:a,minScale:i,children:s});return u?u(h,m):h},closeIcon:N.jsx(At,{color:"#fff",icon:Wu}),imageRender:(p,m)=>{const h=N.jsx(n9,{visible:t,children:p});return c?c(h,m):h},maxScale:a,minScale:i,onOpenChange:(p,m)=>{r(p),o==null||o(p,m),n==null||n(p,!p,m.current)},rootClassName:Fe(wn.preview,l),...f}},[e,t,wn])},{PreviewGroup:JG}=a1,i9=d.memo(({items:e,children:t,enable:r=!0,preview:n})=>{const o=QG(n);return r?N.jsx(JG,{items:e,preview:o,children:t}):t});i9.displayName="PreviewGroup";const eU=e=>{const[t,r]=d.useState(!1);return d.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:u,actionsRender:f,...p}=e===!0?{}:e||{};return{actionsRender:f||((m,h)=>{const g=N.jsx(o9,{info:h,maxScale:a,minScale:i,children:s});return u?u(g,h):g}),closeIcon:N.jsx(At,{color:"#fff",icon:Wu}),imageRender:(m,h)=>{const g=N.jsx(n9,{visible:t,children:m});return c?c(g,h):g},maxScale:a,minScale:i,onOpenChange:m=>{r(m),o==null||o(m),n==null||n(m,!m)},rootClassName:Fe(wn.preview,l),styles:{mask:{backdropFilter:"blur(8px)"}},...p}},[e,t,wn])},a9=d.memo(({ref:e,style:t,preview:r,isLoading:n,maxHeight:o="100%",maxWidth:i="100%",minHeight:a,minWidth:s,actions:l,className:c,alwaysShowActions:u,variant:f="filled",objectFit:p="cover",classNames:m,styles:h,onClick:g,width:v,height:b,...y})=>{const{isDarkMode:x}=En(),w=u?wn.actionsVisible:wn.actionsHidden,S=eU(r);return n?N.jsx("div",{onClick:g,children:N.jsx(oa.Avatar,{active:!0,style:{borderRadius:Ce.borderRadius,height:b,maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,width:v}})}):N.jsxs(ir,{className:Fe(WG({variant:f}),c),ref:e,style:t,children:[l&&N.jsx("div",{className:Fe(w,u?"":"actions-hidden"),children:l}),N.jsx(a1,{className:Fe(wn.image,m==null?void 0:m.image),fallback:x?VG:GG,height:b,loading:"lazy",preview:r===!1?!1:S,width:v,classNames:{root:Fe(wn.wrapper,m==null?void 0:m.wrapper)},style:{maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,objectFit:p||"cover",...h==null?void 0:h.image},styles:{root:h==null?void 0:h.wrapper},onClick:g,...y})]})});a9.displayName="Image";const ib=a9;ib.PreviewGroup=i9;const s9=[{displayName:"Lobe Theme",id:"lobe-theme"},{background:"#fbf9ff",displayName:"Mermaid Default",id:"default"},{background:"#fffcf8",displayName:"Mermaid Base",id:"base"},{background:"#000",displayName:"Mermaid Dark",id:"dark"},{background:"#f9ffeb",displayName:"Mermaid Forest",id:"forest"},{background:"#fff",displayName:"Mermaid Neutral",id:"neutral"}],Ko=new Map,R4=500,tU=()=>{if(Ko.size>R4){const e=Math.floor(R4*.2),t=Array.from(Ko.keys()).slice(0,e);for(const r of t)Ko.delete(r)}};let qf=null;const l9=()=>typeof window>"u"?Promise.resolve(null):(qf||(qf=Ph(()=>import("./diagram--gCCJK__.js").then(e=>e.n),__vite__mapDeps([0,1])).then(e=>e.default)),qf),c9=(e,t,r="strict")=>({fontFamily:e.fontFamilyCode,gantt:{useWidth:1920},securityLevel:r,startOnLoad:!1,theme:t||(e.isDarkMode?"dark":"neutral"),themeVariables:t?void 0:{errorBkgColor:e.colorTextDescription,errorTextColor:e.colorTextDescription,fontFamily:e.fontFamily,lineColor:e.colorTextSecondary,mainBkg:e.colorBgContainer,noteBkgColor:e.colorInfoBg,noteTextColor:e.colorInfoText,pie1:e.geekblue,pie2:e.colorWarning,pie3:e.colorSuccess,pie4:e.colorError,primaryBorderColor:e.colorBorder,primaryColor:e.colorBgContainer,primaryTextColor:e.colorText,secondaryBorderColor:e.colorInfoBorder,secondaryColor:e.colorInfoBg,secondaryTextColor:e.colorInfoText,tertiaryBorderColor:e.colorSuccessBorder,tertiaryColor:e.colorSuccessBg,tertiaryTextColor:e.colorSuccessText,textColor:e.colorText}}),rU=(e,{id:t,theme:r,securityLevel:n})=>{const o=f1(),[i,a]=d.useState(""),s=d.useMemo(()=>c9(o,r,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,r,n]),l=d.useMemo(()=>{const c=e.length<1e4?e:_l.hashStr(e);return[t,r||(o.isDarkMode?"d":"l"),c].filter(Boolean).join("-")},[e,t,o.isDarkMode,r]);return d.useEffect(()=>{const c=Ko.get(l);if(c){c.then(f=>{a(f)}).catch(()=>{});return}const u=(async()=>{try{const f=await l9();if(!f)return"";if(await f.parse(e)){f.initialize(s);const{svg:p}=await f.render(t,e);return p}else throw new Error("Mermaid 语法无效")}catch(f){return console.error("Mermaid 解析错误:",f),""}})();Ko.set(l,u),tU(),u.then(f=>{Ko.get(l)===u&&a(f)}).catch(()=>{Ko.get(l)===u&&Ko.delete(l)})},[l,e,t,s]),i},u9=d.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=d.useMemo(()=>{var g;if(!l)return(g=s9.find(v=>v.id===i))==null?void 0:g.background},[l,i]),u=rU(s,{id:q8(`mermaid-${d.useId()}`),theme:l?void 0:i}),f=!u,[p,m]=d.useState();d.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),d.useEffect(()=>{if(f||!u)return;let g=u;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(u,"image/svg+xml"),y=b.documentElement;if(y&&y.hasAttribute("viewBox")){const x=y.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(y.setAttribute("width",x[2]),y.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const v=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(v))},[f,u]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(ib,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Loading..."})})});u9.displayName="StaticMermaid";const nU=(e,{enabled:t=!0,id:r,theme:n})=>{const o=f1(),[i,a]=d.useState(""),s=d.useRef(""),l=d.useRef(e),c=d.useRef(void 0),u=d.useMemo(()=>c9(o,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,n]);return d.useEffect(()=>{l.current=e},[e]),d.useEffect(()=>{if(!t){a(""),s.current="";const m=c.current;m&&clearTimeout(m);return}const f=l.current;if(f===s.current&&i)return;const p=c.current;return p&&clearTimeout(p),c.current=setTimeout(async()=>{const m=l.current;if(m===f)try{const h=await l9();if(!h)return;if(await h.parse(m)){h.initialize(u);const{svg:g}=await h.render(r,m);l.current===m&&(a(g),s.current=m)}}catch(h){m===l.current&&console.error("Mermaid 解析错误:",h)}},300),()=>{const m=c.current;m&&clearTimeout(m)}},[t,e,r,u,i]),i},d9=d.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=d.useMemo(()=>{var g;if(!l)return(g=s9.find(v=>v.id===i))==null?void 0:g.background},[l,i]),u=nU(s,{enabled:!0,id:q8(`mermaid-${d.useId()}`),theme:l?void 0:i}),f=!u,[p,m]=d.useState();d.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),d.useEffect(()=>{if(f||!u){m(void 0);return}let g=u;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(u,"image/svg+xml"),y=b.documentElement;if(y&&y.hasAttribute("viewBox")){const x=y.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(y.setAttribute("width",x[2]),y.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const v=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(v))},[f,u]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(ib,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Rendering..."})})});d9.displayName="StreamMermaid";const oU=Jl`
|
|
2714
2714
|
0% {
|
|
2715
2715
|
opacity: 0;
|
|
2716
2716
|
}
|
package/dist/web/index.html
CHANGED
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
opacity: 0.65;
|
|
28
28
|
}
|
|
29
29
|
</style>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-4TuRcE3b.js"></script>
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BJFXgntS.js">
|
|
32
|
-
<link rel="modulepreload" crossorigin href="/assets/motion-
|
|
33
|
-
<link rel="modulepreload" crossorigin href="/assets/ui-
|
|
34
|
-
<link rel="
|
|
32
|
+
<link rel="modulepreload" crossorigin href="/assets/motion-DddvD-ez.js">
|
|
33
|
+
<link rel="modulepreload" crossorigin href="/assets/ui-BHvBMRFE.js">
|
|
34
|
+
<link rel="modulepreload" crossorigin href="/assets/diagram--gCCJK__.js">
|
|
35
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C4ESYs7f.css">
|
|
35
36
|
</head>
|
|
36
37
|
<body>
|
|
37
38
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgbg/mdocs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A Markdown knowledge base for small teams",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"motion": "^12.0.0",
|
|
60
60
|
"multer": "^2.1.1",
|
|
61
61
|
"node-diff3": "^3.2.0",
|
|
62
|
+
"react-force-graph-2d": "^1.29.1",
|
|
62
63
|
"react-markdown": "10.1.0",
|
|
63
64
|
"react-router-dom": "^7.14.2",
|
|
64
65
|
"remark": "^15.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as d,j as e}from"./react-vendor-BJFXgntS.js";import{ad as qe,ae as Re,i as fe,af as $e,ag as Ee,ah as De,ai as Me,aj as Fe,ak as Te,al as ke,am as ze,an as Pe,ao as Be}from"./index-DgM2rYI-.js";import{H as Le,S as He,A as Ke}from"./AgentSkillFormCard-CAD6QqQ0.js";import{P as Oe}from"./plus-BWV299MC.js";import{D as Ue,E as We}from"./ui-06fxEgif.js";import{C as Ge,a as Xe}from"./copy-CX8GOyUb.js";import"./motion-92iQWeIW.js";function ae(r){var n;return r==null||typeof r=="boolean"?"":typeof r=="string"||typeof r=="number"?String(r):Array.isArray(r)?r.map(ae).join(""):typeof r=="object"&&"props"in r?ae((n=r.props)==null?void 0:n.children):""}function Ye(r){const[n,c]=d.useState(!1),o=d.useRef(null),b=ae(r.children).replace(/\n$/,"");d.useEffect(()=>()=>{o.current!=null&&window.clearTimeout(o.current)},[]);async function y(){if(b)try{await navigator.clipboard.writeText(b),c(!0),o.current!=null&&window.clearTimeout(o.current),o.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 y(),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Ge,{size:14,"aria-hidden":!0}):e.jsx(Xe,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:r.children})]})}function ge(r){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(Ue,{remarkPlugins:[We],components:{pre:({children:n})=>e.jsx(Ye,{children:n})},children:r.children})})}const Je=["如何发布文档?","草稿是什么?","如何创建域?"];function xe(r,n){return n.map((c,o)=>{const b=c.skillNames&&c.skillNames.length>0?c.skillNames:c.skillIds&&c.skillIds.length>0?c.skillIds:void 0;return{id:`h-${r}-${o}-${c.role}`,role:c.role,content:c.content,skillNames:b}})}function Qe(r,n){const c=r.slice(),o=c[c.length-1];return(o==null?void 0:o.type)==="text"?c[c.length-1]={type:"text",text:o.text+n}:c.push({type:"text",text:n}),c}function Ve(r,n){const c=r.slice(),o=c[c.length-1];return(o==null?void 0:o.type)==="thinking"?c[c.length-1]={type:"thinking",text:o.text+n}:c.push({type:"thinking",text:n}),c}function ye(r){return r!=null&&r.length?r.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Ze(r){return!!(r!=null&&r.some(n=>n.type==="thinking"&&n.text.length>0))}function es(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 je(r){if(r>=1e3){const n=r/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(r)}function ss(r){const{block:n,onResolved:c}=r,[o,b]=d.useState(""),[y,_]=d.useState(!1),[A,C]=d.useState(1),q=d.useRef(!1),T=d.useRef(c);T.current=c;const v=n.status==="open",F=d.useRef(0);d.useEffect(()=>{if(!v)return;q.current=!1;const g=new Date(n.expiresAt).getTime(),u=Date.now(),z=Math.max(g-u,1);F.current=z,C(1);const L=()=>{const S=g-Date.now(),x=Math.max(0,Math.min(1,S/z));C(x),S<=0&&!q.current&&(q.current=!0,Pe(n.requestId).catch(()=>{}).finally(()=>{T.current(n.requestId,"","expired")}))};L();const H=window.setInterval(L,100);return()=>window.clearInterval(H)},[v,n.expiresAt,n.requestId]);async function D(g){const u=g.trim();if(!(!u||y||!v)){_(!0);try{await Be(n.requestId,u),c(n.requestId,u,"selected")}catch{c(n.requestId,u,"failed")}finally{_(!1)}}}async function X(){if(!(y||!v)){_(!0),q.current=!0;try{await ke(n.requestId),c(n.requestId,"","cancelled")}catch{c(n.requestId,"","failed")}finally{_(!1)}}}const R=Math.max(0,Math.ceil(A*F.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(v?"":" 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}),v?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[R,"s"]}):null]}),v?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(A*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${A})`}})}):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,v?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(g=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:y,onClick:()=>void D(g),children:g},g))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:o,disabled:y,placeholder:"或输入自己的内容…",onChange:g=>b(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),D(o))}}),e.jsx("button",{type:"button",disabled:y||!o.trim(),onClick:()=>void D(o),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:y,onClick:()=>void X(),children:"取消"})})]}):null]})}function ts(r){const b=2*Math.PI*8.75,y=Math.min(100,Math.max(0,r.percent)),_=b*(1-y/100),A=y>=90?"danger":y>=70?"warn":"ok",C=`上下文 ${y}% · 已用 ${je(r.used)} / ${je(r.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+A,"data-tooltip":C,"aria-label":C,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:b,strokeDashoffset:_,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function ns(r){var n;for(const c of r)if(!(c.role!=="assistant"||!((n=c.blocks)!=null&&n.length))){for(const o of c.blocks)if((o.type==="choice_card"||o.type==="skill_form_card")&&o.status==="open")return!0}return!1}const us=d.forwardRef(function(n,c){const{open:o,onClose:b,visitorName:y,anchorStyle:_,fullscreen:A,domainId:C,documentId:q,onOpenDocument:T,onTreeChanged:v,onDocumentOverwritten:F,onOpenCoding:D}=n,X=((y==null?void 0:y.trim().charAt(0))||"我").toUpperCase(),[R,g]=d.useState(!1),[u,z]=d.useState(null),[L,H]=d.useState(null),[S,x]=d.useState([]),[Y,K]=d.useState(null),[ie,Ne]=d.useState([]),[be,re]=d.useState(!1),[O,U]=d.useState(""),[P,le]=d.useState([]),[j,W]=d.useState(!1),[ce,$]=d.useState(null),[G,oe]=d.useState(null),[J,M]=d.useState(!1),[E,de]=d.useState(!1),ve=d.useRef(null),Q=d.useRef(null),w=d.useRef(null),ue=d.useRef(0),B=d.useRef(!0),V=d.useRef(S);V.current=S;function me(s){return ue.current+=1,`${s}-${ue.current}`}function Se(s,m=48){return s.scrollHeight-s.scrollTop-s.clientHeight<=m}function I(){const s=Q.current;!s||!B.current||(s.scrollTop=s.scrollHeight)}function we(){const s=Q.current;s&&(B.current=Se(s))}async function Ie(){re(!0);try{const s=await De();Ne(s.sessions),Y||K(s.lastOpenedSessionId)}catch{}finally{re(!1)}}async function Z(){try{const s=await Ee();oe(s)}catch{}}d.useEffect(()=>{var m;if(!o){g(!1),(m=w.current)==null||m.abort(),w.current=null,W(!1);return}let s=!1;return(async()=>{try{const a=await qe();s||(z(a),H(null))}catch(a){s||(z(null),H(a instanceof Error?a.message:String(a)))}})(),Z(),()=>{s=!0}},[o]),d.useEffect(()=>{if(!o)return;let s=!1;return(async()=>{try{const m=await Re();if(s)return;K(m.sessionId),x(a=>a.length>0?a:xe(m.sessionId,m.messages))}catch{}})(),()=>{s=!0}},[o]),d.useEffect(()=>{!o||!R||Ie()},[o,R]);function ee(){if(!E){if(ns(V.current)){M(!0);return}M(!1),b()}}async function Ae(){var a;if(E)return;de(!0);const s=V.current,m=[];for(const k of s)if(!(k.role!=="assistant"||!k.blocks))for(const p of k.blocks)p.type==="choice_card"&&p.status==="open"&&m.push(ke(p.requestId).catch(()=>{})),p.type==="skill_form_card"&&p.status==="open"&&m.push(ze(p.requestId).catch(()=>{}));await Promise.all(m),(a=w.current)==null||a.abort(),x(k=>k.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)})),M(!1),de(!1),b()}const se=d.useRef(ee);se.current=ee,d.useImperativeHandle(c,()=>({requestClose:()=>se.current()}),[]),d.useEffect(()=>{if(!o){M(!1);return}const s=m=>{if(m.key==="Escape"){if(J){E||M(!1);return}if(R){g(!1);return}se.current()}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[o,R,J,E]);async function te(s){var h;const m=s.trim();if(!m||j)return;if(!(u!=null&&u.enabled)){$((u==null?void 0:u.reason)==="missing_api_key"?"请先在设置 → AI 配置 DeepSeek API Key":(u==null?void 0:u.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(h=w.current)==null||h.abort();const a=new AbortController;w.current=a;const k={id:me("u"),role:"user",content:m,skillNames:P.length>0?[...P]:void 0},p=me("a");B.current=!0,x(N=>[...N,k,{id:p,role:"assistant",content:""}]),U(""),W(!0),$(null),g(!1),requestAnimationFrame(()=>I());try{let N=!1;await Te(m,{skillNames:P.length>0?P:void 0,references:{domainId:(C==null?void 0:C.trim())||void 0,documentId:(q==null?void 0:q.trim())||void 0},signal:a.signal,onEvent:i=>{i.type==="text_delta"?(x(f=>f.map(t=>{if(t.id!==p)return t;const l=Qe(t.blocks??[],i.text);return{...t,blocks:l,content:ye(l)}})),requestAnimationFrame(()=>I())):i.type==="thinking_delta"?(x(f=>f.map(t=>{if(t.id!==p)return t;const l=Ve(t.blocks??[],i.text);return{...t,blocks:l}})),requestAnimationFrame(()=>I())):i.type==="sources"?(x(f=>f.map(t=>{if(t.id!==p)return t;const l=(t.blocks??[]).slice(),ne=l[l.length-1];return(ne==null?void 0:ne.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"?(x(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"?(x(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"?(x(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"?(x(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"?x(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"?(x(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"?x(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"?v==null||v():i.type==="document_overwritten"?F==null||F({documentId:i.documentId,headCommitId:i.headCommitId}):i.type==="open_coding"?D==null||D({documentId:i.documentId,displayName:i.displayName}):i.type==="context_usage"?oe({percent:i.percent,used:i.used,limit:i.limit}):i.type==="error"&&(N=!0,$(i.message))}}),!a.signal.aborted&&!N&&le([])}catch(N){if(a.signal.aborted)return;$(N instanceof Error?N.message:String(N))}finally{w.current===a&&(w.current=null),W(!1)}}async function Ce(){var s;if(!j){(s=w.current)==null||s.abort(),$(null),g(!1),W(!1);try{const m=await Me();K(m.sessionId),x([]),U(""),B.current=!0,Z()}catch(m){$(m instanceof Error?m.message:String(m))}}}async function _e(s){var m;if(!j){if(s===Y){g(!1);return}(m=w.current)==null||m.abort(),$(null);try{const a=await Fe(s);K(a.sessionId),x(xe(a.sessionId,a.messages)),U(""),g(!1),B.current=!0,requestAnimationFrame(()=>I()),Z()}catch(a){$(a instanceof Error?a.message:String(a))}}}function pe(s){!s||!T||T(s)}if(!o)return null;const he=L??(u&&!u.enabled?u.reason==="missing_api_key"?"未配置 API Key:请打开设置 → AI":u.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:ve,className:"mdocs-agent-panel"+(A?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":A?!0:void 0,style:A?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:fe,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:j,onClick:()=>void Ce(),children:e.jsx(Oe,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(R?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>g(s=>!s),children:e.jsx(Le,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:ee,children:e.jsx($e,{size:16,strokeWidth:1.8})})]})]}),R?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:()=>g(!1),children:"返回对话"})]}),be?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):ie.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:ie.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(s.id===Y?" active":""),disabled:j,onClick:()=>void _e(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:es(s.updatedAt)})]})},s.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:Q,onScroll:we,children:S.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:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),he?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:he}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Je.map(s=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void te(s),disabled:j||!(u!=null&&u.enabled),children:s},s))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:S.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:fe,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,k)=>{var p;return a.type==="thinking"?a.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:j&&s.id===((p=S[S.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-${k}`):null:a.type==="text"?a.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(ge,{children:a.text})},`${s.id}-t-${k}`):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-${k}`):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-${k}`):a.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(ss,{block:a,onResolved:(h,N,i)=>{x(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"?N:l.selected}:l)}))}})},`${s.id}-ch-${k}`):a.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(He,{block:a,onResolved:(h,N,i)=>{x(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:N,submittedName:N==="submitted"?i:l.submittedName}:l)}))}})},`${s.id}-sf-${k}`):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(),pe(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-${k}`):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:()=>pe(h.documentId),children:h.title})}),e.jsx("td",{children:h.summary||"-"})]},h.documentId))})]})})]})},`${s.id}-d-${k}`)}),j&&s.id===((m=S[S.length-1])==null?void 0:m.id)&&!ye(s.blocks)&&!Ze(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(ge,{children:s.content}):j?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:X}):null]},s.id)})})}),ce?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:ce}):null,e.jsx(Ke,{selectedNames:P,onChange:le,disabled:j||!(u!=null&&u.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:u!=null&&u.enabled?"把你的问题告诉我…":"请先配置 API Key",value:O,disabled:j||!(u!=null&&u.enabled),onChange:s=>U(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),te(O))}}),G?e.jsx(ts,{percent:G.percent,used:G.used,limit:G.limit}):null,e.jsx("button",{type:"button",className:j?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:j?!1:!(u!=null&&u.enabled)||!O.trim(),onClick:()=>{var s;if(j){(s=w.current)==null||s.abort();return}te(O)},title:j?"停止":"发送","aria-label":j?"停止":"发送",children:j?"■":"↑"})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),J?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{E||M(!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:E,onClick:()=>M(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:E,onClick:()=>void Ae(),children:E?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{us as AgentChatPanel};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as q,_ as L,aq as D,am as _,ar as F}from"./index-DgM2rYI-.js";import{r as a,j as e}from"./react-vendor-BJFXgntS.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 B=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],O=q("history",B),j=5;function X(i){const t=a.useRef(!0),r=a.useRef(null),[d,k]=a.useState([]),[u,p]=a.useState(!1),[h,v]=a.useState(null);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const s=await L();if(!t.current)return;k(s)}catch(s){if(!t.current)return;v(s instanceof Error?s.message:String(s))}})()},[]),a.useEffect(()=>{if(!u)return;function s(o){const g=r.current;!g||g.contains(o.target)||p(!1)}function n(o){o.key==="Escape"&&p(!1)}return document.addEventListener("mousedown",s),document.addEventListener("keydown",n),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",n)}},[u]);const c=d.filter(s=>i.selectedNames.includes(s.name));function f(s){if(i.disabled)return;const n=new Set(i.selectedNames);if(n.has(s))n.delete(s);else{if(n.size>=j)return;n.add(s)}i.onChange([...n])}return d.length===0&&!h?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:r,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[u&&d.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",j," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:d.map(s=>{const n=i.selectedNames.includes(s.name),o=!n&&i.selectedNames.length>=j;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":n,className:"mdocs-agent-skill-popover-item"+(n?" mdocs-agent-skill-popover-item-on":""),disabled:i.disabled||o,onClick:()=>f(s.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:n?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:s.name}),s.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:s.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},s.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(u?" mdocs-agent-skill-ref-toggle-open":""),disabled:i.disabled||d.length===0,onClick:()=>p(s=>!s),"aria-expanded":u,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(s=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:i.disabled,onClick:()=>f(s.name),title:"移除引用",children:[s.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},s.name))]}),h?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:h}):null]})}const $=/^[A-Za-z0-9_]+$/;function K(i){const{block:t,onResolved:r}=i,[d,k]=a.useState(t.initialName),[u,p]=a.useState(t.initialDescription),[h,v]=a.useState(t.initialBody),[c,f]=a.useState(!1),[s,n]=a.useState(null),[o,g]=a.useState(1),x=a.useRef(!1),N=a.useRef(r);N.current=r;const m=t.status==="open",b=a.useRef(0);a.useEffect(()=>{if(!m)return;x.current=!1;const l=new Date(t.expiresAt).getTime(),C=Date.now(),y=Math.max(l-C,1);b.current=y,g(1);const S=()=>{const w=l-Date.now(),M=Math.max(0,Math.min(1,w/y));g(M),w<=0&&!x.current&&(x.current=!0,D(t.requestId).catch(()=>{}).finally(()=>{N.current(t.requestId,"expired")}))};S();const I=window.setInterval(S,100);return()=>window.clearInterval(I)},[m,t.expiresAt,t.requestId]);async function E(){if(c||!m)return;const l=d.trim();if(!l){n("名称不能为空");return}if(!$.test(l)){n("名称仅允许英文、数字、下划线");return}if(!h.trim()){n("正文不能为空");return}f(!0),n(null);try{await F(t.requestId,{name:l,description:u.trim(),body:h}),r(t.requestId,"submitted",l)}catch{r(t.requestId,"failed")}finally{f(!1)}}async function R(){if(!(c||!m)){f(!0),n(null),x.current=!0;try{await _(t.requestId),r(t.requestId,"cancelled")}catch{r(t.requestId,"failed")}finally{f(!1)}}}const A=Math.max(0,Math.ceil(o*b.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(m?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:t.title}),m?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[A,"s"]}):null]}),m?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${o})`}})}):null,t.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",t.submittedName?`:${t.submittedName}`:""]}):null,t.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,t.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,t.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,m?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:d,onChange:l=>k(l.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:u,onChange:l=>p(l.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:h,onChange:l=>v(l.target.value),rows:8,disabled:c})]}),s?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:s}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void R(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void E(),children:c?"提交中…":t.mode==="create"?"创建":"保存"})]})]}):null]})}export{X as A,O as H,K as S};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as u,j as n}from"./react-vendor-BJFXgntS.js";import{ad as le,ae as oe,i as re,ah as ce,ap as de,ai as ue,aj as me,ak as he}from"./index-DgM2rYI-.js";import{H as fe,S as ge,A as xe}from"./AgentSkillFormCard-CAD6QqQ0.js";import{P as ke}from"./plus-BWV299MC.js";import{D as ye,E as we}from"./ui-06fxEgif.js";import"./motion-92iQWeIW.js";function U(e){return e===""?[]:e.split(`
|
|
2
|
-
`)}function te(e){return e.join(`
|
|
3
|
-
`)}function K(e,i){const t=U(e),a=U(i),m=t.length,k=a.length,y=Array.from({length:m+1},()=>Array.from({length:k+1},()=>0));for(let C=m-1;C>=0;C--)for(let I=k-1;I>=0;I--)t[C]===a[I]?y[C][I]=y[C+1][I+1]+1:y[C][I]=Math.max(y[C+1][I],y[C][I+1]);const S=[];let x=0,w=0;for(;x<m||w<k;)if(x<m&&w<k&&t[x]===a[w])S.push({kind:"eq",oi:x,ni:w}),x++,w++;else if(w<k&&(x===m||y[x][w+1]>=y[x+1][w]))S.push({kind:"ins",oi:x,ni:w}),w++;else if(x<m)S.push({kind:"del",oi:x,ni:w}),x++;else break;const E=[];let c=0,D=0;for(;c<S.length;){if(S[c].kind==="eq"){c++;continue}const C=S[c].oi,I=S[c].ni,T=[],L=[];let v=C,H=I;for(;c<S.length&&S[c].kind!=="eq";){const A=S[c];A.kind==="del"?(T.push(t[A.oi]),v=A.oi+1):(L.push(a[A.ni]),H=A.ni+1),c++}E.push({id:`h${D++}`,oldStart:C,oldEnd:v,newStart:I,newEnd:H,oldLines:T,newLines:L})}return E}function je(e,i){const t=U(e);return te([...t.slice(0,i.oldStart),...i.newLines,...t.slice(i.oldEnd)])}function pe(e,i){const t=U(e);return te([...t.slice(0,i.newStart),...i.oldLines,...t.slice(i.newEnd)])}function J(e){return e===""?[]:e.split(`
|
|
4
|
-
`)}function z(e){return e.join(`
|
|
5
|
-
`)}function Ne(e,i){const t=J(e),a=[];let m=0;return i.forEach((k,y)=>{k.oldStart>m&&a.push({kind:"same",lines:t.slice(m,k.oldStart),key:`s-${m}-${k.oldStart}`}),a.push({kind:"hunk",hunk:k,hunkIndex:y,key:`h-${k.id}-${y}`}),m=k.oldEnd}),m<t.length?a.push({kind:"same",lines:t.slice(m),key:`s-${m}-end`}):i.length===0&&t.length===0&&a.push({kind:"same",lines:[],key:"s-empty"}),a}function be(e){const i=[],t=[];for(const a of e)a.kind==="same"?i.push(z(a.lines)):t.push(z(a.hunk.newLines));return{sameTexts:i,newTexts:t}}function Ce(e,i){const t=[];let a=0,m=0;for(const k of e)if(k.kind==="same"){const y=i.sameTexts[a++]??"";t.push(...J(y))}else{const y=i.newTexts[m++]??"";t.push(...J(y))}return z(t)}function Se(e){return e.oldLines.length===0?"add":e.newLines.length===0?"del":"mod"}function X(e){const i=Math.max(1,J(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:t=>e.onChange(t.target.value),onBlur:()=>e.onBlurFlush()})]})}function Ie(e){const i=!!e.sending,[t,a]=u.useState(0),[m,k]=u.useState(null),[y,S]=u.useState({sameTexts:[],newTexts:[]}),x=u.useRef(!1),w=u.useRef([]),E=u.useRef(y);E.current=y;const c=u.useMemo(()=>e.proposedMd==null||e.proposedMd===e.currentMd?[]:K(e.currentMd,e.proposedMd),[e.currentMd,e.proposedMd]),D=u.useMemo(()=>Ne(e.currentMd,c),[e.currentMd,c]);w.current=D;const C=!i&&c.length>0;u.useEffect(()=>{if(c.length===0){a(0);return}a(l=>Math.min(l,c.length-1))},[c.length]),u.useEffect(()=>{if(!C){x.current=!1;return}x.current||S(be(D))},[C,e.proposedMd,e.currentMd,D]);const I=m??t;function T(){return Ce(w.current,E.current)}function L(){if(!C)return e.proposedMd;const l=T();return x.current=!1,l===e.currentMd?(e.onProposedChange(null),null):(l!==e.proposedMd&&e.onProposedChange(l),l)}function v(l){const h=c.indexOf(l),g=T();if(x.current=!1,g===e.currentMd){e.onProposedChange(null);return}const p=K(e.currentMd,g),b=p[h]??p.find(O=>O.id===l.id);if(!b){e.onProposedChange(g);return}const j=je(e.currentMd,b);e.onCurrentChange(j),K(j,g).length===0?e.onProposedChange(null):e.onProposedChange(g)}function H(l){const h=c.indexOf(l),g=T();if(x.current=!1,g===e.currentMd){e.onProposedChange(null);return}const p=K(e.currentMd,g),b=p[h]??p.find(_=>_.id===l.id);if(!b){e.onProposedChange(g);return}const j=pe(g,b);j===e.currentMd?e.onProposedChange(null):e.onProposedChange(j)}function A(){const l=T();x.current=!1,e.onCurrentChange(l),e.onProposedChange(null)}function F(){x.current=!1,e.onProposedChange(null)}function B(l){c.length!==0&&a(h=>{const g=(h+l+c.length)%c.length,p=document.getElementById(`mdocs-ai-hunk-${g}`);return p==null||p.scrollIntoView({block:"center",behavior:"smooth"}),g})}function M(l,h){x.current=!0,S(g=>{const p=g.sameTexts.slice();return p[l]=h,{...g,sameTexts:p}})}function q(l,h){x.current=!0,S(g=>{const p=g.newTexts.slice();return p[l]=h,{...g,newTexts:p}})}const N=c[I]??null;let V=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?"接收中·编辑我的稿":c.length===0?e.proposedMd?"与提案一致(可编辑)":"Markdown 源码(可编辑)":`${c.length} 处变更(可改提案)`}),!i&&c.length>0?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:A,children:"全部接受"}),n.jsx("button",{type:"button",onClick:F,children:"全部拒绝"})]}):null]}),C?n.jsxs("div",{className:"mdocs-ai-write-inline",role:"document",children:[D.map(l=>{if(l.kind==="same"){const j=V++,_=y.sameTexts[j]??z(l.lines);return n.jsx("div",{className:"mdocs-ai-write-inline-same",children:n.jsx(X,{className:"ctx",value:_,"aria-label":"提案相同行",onChange:O=>M(j,O),onBlurFlush:()=>L()})},l.key)}const h=l.hunk,g=Se(h),p=l.hunkIndex===I,b=y.newTexts[l.hunkIndex]??z(h.newLines);return n.jsxs("div",{id:`mdocs-ai-hunk-${l.hunkIndex}`,className:`mdocs-ai-write-inline-hunk mdocs-ai-write-inline-hunk-${g}`+(p?" is-active":""),onMouseEnter:()=>k(l.hunkIndex),onMouseLeave:()=>k(null),onClick:()=>a(l.hunkIndex),children:[n.jsxs("div",{className:"mdocs-ai-write-hunk-hover",hidden:m!==l.hunkIndex,children:[n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:j=>{j.stopPropagation(),H(h)},children:"拒绝"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:j=>{j.stopPropagation(),v(h)},children:"接受"})]}),n.jsx("pre",{className:"mdocs-ai-write-hunk-pre",children:h.oldLines.map((j,_)=>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:j||" "})]},`o${_}`))}),h.newLines.length>0||b!==""||g!=="del"?n.jsx(X,{className:"add",value:b,"aria-label":"提案新增行",onChange:j=>q(l.hunkIndex,j),onBlurFlush:()=>L()}):null]},l.key)}),N?n.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"变更导航",children:[n.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>B(-1),children:"↑"}),n.jsxs("span",{children:[I+1," / ",c.length]}),n.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>B(1),children:"↓"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>H(N),children:"拒绝"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>v(N),children:"接受"})]}):null]}):n.jsx("textarea",{className:"mdocs-ai-write-editor",value:e.currentMd,onChange:l=>e.onCurrentChange(l.target.value),spellCheck:!1,placeholder:`# 标题
|
|
6
|
-
|
|
7
|
-
在此编辑 Markdown 源码…`})]})}let Z=0;function ee(e){return Z+=1,`${e}-${Date.now()}-${Z}`}function Me(e,i){const t=e.slice(),a=t[t.length-1];return(a==null?void 0:a.type)==="text"?t[t.length-1]={type:"text",text:a.text+i}:t.push({type:"text",text:i}),t}function ve(e,i){const t=e.slice(),a=t[t.length-1];return(a==null?void 0:a.type)==="thinking"?t[t.length-1]={type:"thinking",text:a.text+i}:t.push({type:"thinking",text:i}),t}function G(e,i){const t=i.trim();return t?[...e,{type:"tool",text:t}]:e}function Ae(e){return e.some(i=>i.type==="text"||i.type==="thinking"?i.text.length>0:!0)}function $e(e){const i=new Date(e);if(Number.isNaN(i.getTime()))return"";const t=new Date;return i.getFullYear()===t.getFullYear()&&i.getMonth()===t.getMonth()&&i.getDate()===t.getDate()?i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):i.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function ne(e,i){return i.map((t,a)=>{const m=`h-${e}-${a}-${t.role}`;if(t.role==="user"){const k=t.skillNames&&t.skillNames.length>0?t.skillNames:t.skillIds&&t.skillIds.length>0?t.skillIds:void 0;return{id:m,role:"user",content:t.content,skillNames:k}}return{id:m,role:"assistant",blocks:t.content?[{type:"text",text:t.content}]:[]}})}function He(e){const[i,t]=u.useState(e.initialMarkdown),[a,m]=u.useState(null),[k]=u.useState(e.initialMarkdown),[y,S]=u.useState(e.displayName||"未命名"),[x,w]=u.useState([]),[E,c]=u.useState(null),[D,C]=u.useState([]),[I,T]=u.useState(!1),[L,v]=u.useState(!1),[H,A]=u.useState(""),[F,B]=u.useState([]),[M,q]=u.useState(!1),[N,V]=u.useState(null),[l,h]=u.useState(null),[g,p]=u.useState(!1),b=u.useRef(null);async function j(){T(!0);try{const s=await ce("coding",e.documentId);C(s.sessions),E||c(s.lastOpenedSessionId)}catch{}finally{T(!1)}}if(u.useEffect(()=>{var d;if(!e.open){v(!1),(d=b.current)==null||d.abort();return}t(e.initialMarkdown),m(null),S(e.displayName||"未命名"),A(""),h(null),v(!1);let s=!1;return(async()=>{try{const r=await le();s||V(r)}catch{s||V({enabled:!1,skillsReady:!1,model:null})}try{const r=await oe("coding",e.documentId);if(s)return;c(r.sessionId),w(ne(r.sessionId,r.messages))}catch{s||(c(null),w([]))}j()})(),()=>{s=!0}},[e.open,e.initialMarkdown,e.displayName,e.documentId]),u.useEffect(()=>()=>{var s;return(s=b.current)==null?void 0:s.abort()},[]),u.useEffect(()=>{e.open&&L&&j()},[L,e.open,e.documentId]),!e.open)return null;const _=a!=null&&a!==i?K(i,a):[];async function O(){var s;if(!M){(s=b.current)==null||s.abort(),h(null),v(!1),q(!1);try{const d=await ue("coding",e.documentId);c(d.sessionId),w([]),A(""),j()}catch(d){h(d instanceof Error?d.message:String(d))}}}async function se(s){var d;if(!M){if(s===E){v(!1);return}(d=b.current)==null||d.abort(),h(null);try{const r=await me(s,"coding",e.documentId);c(r.sessionId),w(ne(r.sessionId,r.messages)),A(""),v(!1)}catch(r){h(r instanceof Error?r.message:String(r))}}}async function Q(){var Y;const s=H.trim();if(!s||M)return;if(!(N!=null&&N.enabled)){h("请先在设置 → AI 配置 API Key");return}(Y=b.current)==null||Y.abort();const d=new AbortController;b.current=d;const r=ee("u"),R=ee("a");w($=>[...$,{id:r,role:"user",content:s,skillNames:F.length>0?[...F]:void 0},{id:R,role:"assistant",blocks:[]}]),A(""),q(!0),h(null);const P=$=>{w(o=>o.map(f=>f.id===R&&f.role==="assistant"?{...f,blocks:$(f.blocks)}:f))};try{let $=!1;await he(s,{mode:"coding",skillNames:F.length>0?F:void 0,documentId:e.documentId,workingMarkdown:i,baseMarkdown:k,signal:d.signal,onEvent:o=>{o.type==="text_delta"?P(f=>Me(f,o.text)):o.type==="thinking_delta"?P(f=>ve(f,o.text)):o.type==="markdown_set"?m(o.markdown):o.type==="tool_notice"?P(f=>G(f,o.text)):o.type==="document_table"?P(f=>G(f,o.title)):o.type==="document_card"?P(f=>G(f,`读取文档「${o.title}」`)):o.type==="sources"?o.items.length>0&&P(f=>G(f,`已阅读 ${o.items.length} 个手册页面`)):o.type==="skill_form_card"?P(f=>[...f,{type:"skill_form_card",requestId:o.requestId,mode:o.mode,title:o.title,currentName:o.currentName,initialName:o.initialName,initialDescription:o.initialDescription,initialBody:o.initialBody,expiresAt:o.expiresAt,status:"open"}]):o.type==="skill_form_expired"?P(f=>f.map(W=>W.type==="skill_form_card"&&W.requestId===o.requestId&&W.status==="open"?{...W,status:"expired"}:W)):o.type==="error"&&($=!0,h(o.message))}}),!d.signal.aborted&&!$&&B([]),j()}catch($){d.signal.aborted||h($ instanceof Error?$.message:String($))}finally{b.current===d&&(b.current=null),q(!1)}}async function ie(){let s=i;if(_.length>0){if(!window.confirm(`还有 ${_.length} 段未审阅,将全部接受后写回。继续?`))return;s=a??i,t(s),m(null)}p(!0);const d=!e.documentId;try{const r=await e.onComplete({markdown:s,documentId:e.documentId,displayName:y.trim()||"未命名"}),R=r&&typeof r=="object"&&typeof r.documentId=="string"?r.documentId.trim():"";if(d&&R&&E)try{await de(E,R)}catch{}e.onClose()}catch(r){if(r!=null&&r.silent||r instanceof Error&&r.message==="cancelled")return;h(r instanceof Error?r.message:String(r))}finally{p(!1)}}function ae(){var s;(i!==k||a!=null)&&!window.confirm("取消帮写?未写回的修改将丢失。")||((s=b.current)==null||s.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:re,alt:"",className:"mdocs-ai-write-title-logo"}),n.jsx("strong",{children:"帮写"}),n.jsx("input",{className:"mdocs-ai-write-title",value:y,onChange:s=>S(s.target.value),"aria-label":"文档标题"})]}),n.jsxs("div",{className:"mdocs-ai-write-header-actions",children:[n.jsx("button",{type:"button",onClick:ae,disabled:g,children:"取消"}),n.jsx("button",{type:"button",className:"mdocs-ai-write-primary",onClick:()=>void ie(),disabled:g,children:g?"写回中…":"完成并写回"})]})]}),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:M,onClick:()=>void O(),children:n.jsx(ke,{size:16,strokeWidth:1.8})}),n.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(L?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>v(s=>!s),children:n.jsx(fe,{size:16,strokeWidth:1.8})})]})]}),L?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:()=>v(!1),children:"返回对话"})]}),I?n.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):D.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:D.map(s=>n.jsx("li",{children:n.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(s.id===E?" active":""),disabled:M,onClick:()=>void se(s.id),children:[n.jsx("span",{className:"mdocs-agent-panel-history-title",children:s.title}),n.jsx("span",{className:"mdocs-agent-panel-history-time",children:$e(s.updatedAt)})]})},s.id))})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mdocs-ai-write-chat-messages",children:x.length===0?n.jsx("p",{className:"mdocs-ai-write-hint",children:"描述你想写或改的内容。助手可读取右侧当前稿与进场快照,再更新提案;请按段接受或拒绝后完成写回。"}):x.map(s=>n.jsx("div",{className:"mdocs-ai-write-msg"+(s.role==="user"?" mdocs-ai-write-msg-user":""),children:s.role==="user"?n.jsxs(n.Fragment,{children:[s.skillNames&&s.skillNames.length>0?n.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",s.skillNames.length]}):null,s.content]}):Ae(s.blocks)?n.jsx("div",{className:"mdocs-ai-write-timeline",children:s.blocks.map((d,r)=>d.type==="thinking"?d.text?n.jsxs("details",{className:"mdocs-ai-write-thinking",open:M,children:[n.jsx("summary",{children:"思考中"}),n.jsx("pre",{className:"mdocs-ai-write-thinking-body",children:d.text})]},`${s.id}-think-${r}`):null:d.type==="tool"?n.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:d.text},`${s.id}-tool-${r}`):d.type==="skill_form_card"?n.jsx(ge,{block:d,onResolved:(R,P,Y)=>{w($=>$.map(o=>o.id!==s.id||o.role!=="assistant"?o:{...o,blocks:o.blocks.map(f=>f.type==="skill_form_card"&&f.requestId===R?{...f,status:P,submittedName:P==="submitted"?Y:f.submittedName}:f)}))}},`${s.id}-sf-${r}`):d.text?n.jsx("div",{className:"mdocs-agent-panel-md",children:n.jsx(ye,{remarkPlugins:[we],children:d.text})},`${s.id}-text-${r}`):null)}):M?n.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[n.jsx("span",{}),n.jsx("span",{}),n.jsx("span",{})]}):null},s.id))}),l?n.jsx("p",{className:"mdocs-ai-write-error",children:l}):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(xe,{selectedNames:F,onChange:B,disabled:M||!(N!=null&&N.enabled)}),n.jsx("textarea",{rows:2,value:H,disabled:M||!(N!=null&&N.enabled),placeholder:N!=null&&N.enabled?"说说要写什么…":"请先配置 API Key",onChange:s=>A(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),Q())}})]}),n.jsx("button",{type:"button",className:M?"mdocs-ai-write-stop":void 0,disabled:M?!1:!(N!=null&&N.enabled),onClick:()=>{var s;if(M){(s=b.current)==null||s.abort();return}Q()},children:M?"停止":"发送"})]})]})]}),n.jsx(Ie,{currentMd:i,proposedMd:a,sending:M,onCurrentChange:t,onProposedChange:m})]})]})}export{He as AiWriteWorkbench};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{r as i,j as n}from"./react-vendor-BJFXgntS.js";import{B as fe}from"./ui-06fxEgif.js";import{c as K,g as Ie,u as Se,a as he,d as Oe,b as ze,f as He,e as pe,h as Fe,P as Ue,D as We,F as qe,l as ye,i as Ve,S as $e,M as Ye,j as Je,r as Ge,k as Ke,m as J,n as Xe,o as Qe,p as ge}from"./index-DgM2rYI-.js";import{z as Ze,A as et,m as ie,n as tt,o as nt,p as at,r as it,s as ot,t as st,v as rt,x as ct,B as lt,R as dt,a as ut,b as xe,c as mt,d as ft,e as ht,f as yt,g as gt,h as xt,i as vt,w as oe,j as bt,O as kt,E as It,q as St,l as Ct,C as wt,D as jt}from"./react-BUhFwPCj.js";import{H as Mt,a as Et,b as Rt,M as Dt,T as Nt,S as At,W as Pt,N as Tt,o as Lt,c as ve}from"./Toolbar-B36NxaTc.js";import{V as Bt}from"./VisitorPickerModal-drnOuPLP.js";import"./motion-92iQWeIW.js";import"./editor-ONzd_YnO.js";import"./diagram-3lhA7FYR.js";import"./plus-BWV299MC.js";import"./copy-CX8GOyUb.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 _t=[["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"}]],Ot=K("refresh-cw",_t);/**
|
|
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 zt=[["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"}]],Ht=K("shield-user",zt);/**
|
|
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 pt=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Ft=K("text-align-justify",pt);/**
|
|
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 Ut=[["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"}]],Wt=K("users",Ut),qt=48;function G(e){try{const a=e.getDocument("markdown");return typeof a=="string"?a:""}catch{return null}}function Vt(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}function $t({editor:e,documentId:a,displayName:s,debounceMs:v=1e3,enabled:f=!0,localBaseCommitIdAtEditStart:N,snapshotMeta:_}){const[X,T]=i.useState(!1),[A,C]=i.useState(!1),[O,M]=i.useState(null),u=i.useRef(null),h=i.useRef(null),b=i.useRef(!1),k=i.useRef(""),x=i.useRef(!1),w=i.useRef(a),W=i.useRef(s),q=i.useRef(N),z=i.useRef(_);w.current=a,W.current=s,q.current=N,z.current=_;const j=i.useCallback(async()=>{if(!e)return;if(!k.current){console.log("[useAutoSave] performSave blocked: lastContentRef is empty");return}const l=Vt(e);l!=null&&(console.log("[useAutoSave] performSave saving draft, documentId:",w.current,"content preview:",l.slice(0,80)),await Ie(w.current).execute(()=>Se({documentId:w.current,content:l,displayName:W.current,localBaseCommitIdAtEditStart:q.current,snapshotMeta:z.current})),k.current=G(e)??k.current,C(!0),T(!1),M(Date.now()),b.current=!0,x.current=!1)},[e]);i.useEffect(()=>{let l=!1;return he(a).then(d=>{l||(d?(C(!0),M(d.updatedAt),b.current=!0):(C(!1),M(null),b.current=!1,x.current=!1))}),()=>{l=!0}},[a]),i.useEffect(()=>{var $,p;if(!f){($=h.current)==null||$.call(h),h.current=null;return}if(!e)return;const l=e.getLexicalEditor();if(!l)return;(p=h.current)==null||p.call(h);let d=!1,S=0,L=0;const H=()=>{if(d)return;const y=G(e);if(y===null){if(L+=1,L>qt)return;S=requestAnimationFrame(H);return}k.current=y;const c=l.registerUpdateListener(()=>{const P=G(e);P!==null&&P!==k.current&&(console.log("[useAutoSave] updateListener dirty, documentId:",a,"oldLen:",k.current.length,"newLen:",P.length),k.current=P,T(!0),x.current=!0,b.current=!1,u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null,j()},v))});h.current=()=>{c(),u.current&&(clearTimeout(u.current),u.current=null)}};return queueMicrotask(()=>{d||(S=requestAnimationFrame(H))}),()=>{var y;d=!0,cancelAnimationFrame(S),(y=h.current)==null||y.call(h)}},[f,e,a,s,v,N,_,j]),i.useEffect(()=>{var S;if(!f||!e)return;const l=(S=e.getLexicalEditor())==null?void 0:S.getRootElement();if(!l)return;const d=()=>{u.current&&(clearTimeout(u.current),u.current=null),x.current&&j()};return l.addEventListener("blur",d),()=>l.removeEventListener("blur",d)},[f,e,j]),i.useEffect(()=>{if(!f)return;const l=()=>{document.visibilityState==="hidden"&&(u.current&&(clearTimeout(u.current),u.current=null),x.current&&j())},d=()=>{x.current&&(u.current&&(clearTimeout(u.current),u.current=null),j())};return document.addEventListener("visibilitychange",l),window.addEventListener("beforeunload",d),()=>{document.removeEventListener("visibilitychange",l),window.removeEventListener("beforeunload",d)}},[f,j]);async function E(){await Oe(a),C(!1),T(!1),x.current=!1,b.current=!1,k.current=""}async function V(){const l=await he(a);return l?l.content:null}function I(){C(!0),T(!1),x.current=!1,M(Date.now()),b.current=!0,e&&(k.current=G(e)??"")}return{isDirty:X,draftExists:A,lastSavedAt:O,clearDraft:E,loadDraftContent:V,markDraftSaved:I}}function Yt({isDirty:e,draftExists:a}){const s=e&&!a;i.useEffect(()=>{if(!s)return;const v=f=>{f.preventDefault()};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[s])}function se(e){try{return JSON.stringify(e.getDocument("json"))}catch{return null}}const be='{"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 ke(e){const s=(e instanceof Error?e.message:String(e)).trim();return/^File too large$/i.test(s)?"文件过大(单文件上限 55MB)":/^unsupported file type$/i.test(s)?"不支持的文件类型":/^not an image$/i.test(s)?"不是有效的图片文件":s||"上传失败"}function Jt(e,a){if(!e)return a==="json"?be:e;if(a!=="json")return e;try{const s=JSON.parse(e);if(s!=null&&s.root&&Array.isArray(s.root.children)&&s.root.children.length===0)return be}catch{}return e}function Gt({editor:e}){const{visible:a}=wt();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(jt,{editor:e})})})}function cn(e){const{t:a,lang:s}=ze(),[v,f]=i.useState(!1),N=i.useRef(null),[_,X]=i.useState([]),[T,A]=i.useState(!1),[C,O]=i.useState(e.meta.permission),[M,u]=i.useState(!1),[h,b]=i.useState(!1),[k,x]=i.useState(!1),[w,W]=i.useState(new Map),[q,z]=i.useState(!1);i.useEffect(()=>{const t=o=>{N.current&&!N.current.contains(o.target)&&f(!1)};return v&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[v]),i.useEffect(()=>{let t=!0;return He().then(o=>{t&&X(o)}).catch(()=>{}),()=>{t=!1}},[]);function j(t){const o=_.find(r=>r.visitorId===t);return(o==null?void 0:o.visitorName)??t.slice(0,8)}const[E,V]=i.useState(e.initialDisplayName),[I,l]=i.useState(!1),[d,S]=i.useState(!1),[L,H]=i.useState(!1),[$,p]=i.useState(()=>localStorage.getItem("mdocs.autoEdit")!=="false"),y=e.canEdit&&$,[c,P]=i.useState(null),[Ce,re]=i.useState(!1),Q=i.useRef(null);i.useLayoutEffect(()=>{re(!1),P(null),Q.current=null},[e.meta.documentId]),i.useEffect(()=>{const t=requestAnimationFrame(()=>re(!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]),F=i.useMemo(()=>Jt(e.initialContent||"",R),[e.initialContent,R,e.contentRevision]),{isDirty:ce,draftExists:U,markDraftSaved:we}=$t({editor:c,documentId:e.meta.documentId,displayName:E,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,U)},[U,e.onDraftExistsChange]),Yt({isDirty:ce,draftExists:U}),i.useEffect(()=>{if(c)try{c.setDocument(R,F)}catch{}},[c,e.meta.documentId,e.contentRevision,F,R]),i.useEffect(()=>{c==null||c.setLocale(s==="zh"?Ze:et)},[c,s]),i.useEffect(()=>{V(e.initialDisplayName)},[e.initialDisplayName,e.meta.documentId,e.contentRevision]),i.useEffect(()=>{O(e.meta.permission)},[e.meta.permission,e.meta.documentId]),i.useEffect(()=>{let t=!0;return(async()=>{try{const o=await pe(e.meta.documentId);t&&S(o.bookmarked)}catch{}})(),()=>{t=!1}},[e.meta.documentId]);async function le(){var t,o;if(!L){H(!0);try{d?(await Ge(e.meta.documentId),S(!1),(t=e.onShowToast)==null||t.call(e,a("bookmarkRemoved"))):(await Ke(e.meta.documentId),S(!0),(o=e.onShowToast)==null||o.call(e,a("bookmarkAdded")))}finally{H(!1)}}}i.useEffect(()=>(e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=Pe),()=>{e.saveBeforeNavRef&&(e.saveBeforeNavRef.current=void 0)})),i.useEffect(()=>{if(e.exportMarkdownRef)return e.exportMarkdownRef.current=()=>{const t=Q.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 je(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const Me=i.useCallback(t=>{Q.current=t,P(t);const o=F;if(!o)return;const r=()=>{try{t.setDocument(R,o)}catch{requestAnimationFrame(()=>{try{t.setDocument(R,o)}catch{}})}};queueMicrotask(()=>{queueMicrotask(r)})},[R,F]);async function Z(){if(!(!c||!e.canEdit)){l(!0);try{const t=se(c);if(!t)return;await e.onPublish(t,E,e.meta.documentId)}catch(t){throw t}finally{l(!1)}}}async function Ee(){if(!e.canEdit)return;const t=e.initialDisplayName.trim();if(E.trim()!==t)try{await Z()}catch{}}const D=i.useMemo(()=>e.domains.find(t=>t.domainId===e.meta.domainId),[e.domains,e.meta.domainId]),Re=i.useMemo(()=>{const t=(D==null?void 0:D.permission)??"public";return Fe(t)},[D==null?void 0:D.permission]);function De(t){return t===J.PRIVATE?a("permissionPrivate"):t===J.DOMAIN_READ?a("permissionInvite"):t===J.DOMAIN_WRITE?a("permissionDomainWrite"):t===J.PUBLIC_READ?a("permissionPublicRead"):a("permissionPublicEdit")}async function Ne(){var t;if(M||C===e.meta.permission){A(!1);return}u(!0);try{const r=(c?se(c):null)??e.initialContent;await e.onPublish(r,E,e.meta.documentId,C),A(!1),(t=e.onShowToast)==null||t.call(e,a("docInfoPermissionUpdated"))}finally{u(!1)}}async function Ae(t){var o;if(!q){z(!0);try{const r=new Set(t.map(g=>g.visitorId)),ne=new Map(t.map(g=>[g.visitorId,g.permission]));for(const[g]of w)r.has(g)||await Xe(e.meta.documentId,g);for(const{visitorId:g,permission:ae}of t){const me=w.get(g);(!me||me!==ae)&&await Qe(e.meta.documentId,g,ae)}b(!1),(o=e.onShowToast)==null||o.call(e,a("docInfoInviteSuccess",{count:t.length}))}finally{z(!1)}}}async function Pe(){if(!c||!e.canEdit)return;if(!ce){console.log("[DocumentEditor.saveDraft] skipped: not dirty, documentId:",e.meta.documentId);return}const t=se(c);t&&(console.log("[DocumentEditor.saveDraft] saving draft, documentId:",e.meta.documentId,"content preview:",t.slice(0,80)),we(),await Ie(e.meta.documentId).execute(()=>Se({documentId:e.meta.documentId,content:t,displayName:E,localBaseCommitIdAtEditStart:e.meta.headCommitId??null,snapshotMeta:{permission:e.meta.permission,ownerVisitorId:e.meta.ownerVisitorId,domainId:e.meta.domainId}})))}const Te=i.useMemo(()=>[{icon:Mt,key:"h1",label:"Heading 1",onSelect:t=>{t.dispatchCommand(ie,{tag:"h1"})}},{icon:Et,key:"h2",label:"Heading 2",onSelect:t=>{t.dispatchCommand(ie,{tag:"h2"})}},{icon:Rt,key:"h3",label:"Heading 3",onSelect:t=>{t.dispatchCommand(ie,{tag:"h3"})}},{type:"divider"},{icon:Dt,key:"hr",label:"Hr",onSelect:t=>{t.dispatchCommand(tt,{})}},{icon:Nt,key:"table",label:"Table",onSelect:t=>{t.dispatchCommand(nt,{columns:"3",rows:"3"})}},{icon:At,key:"tex",label:"TeX",onSelect:t=>{t.dispatchCommand(at,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>t.focus())}},{type:"divider"},{key:"file",label:"File",onSelect:t=>{Lt(o=>{for(const r of o)t.dispatchCommand(St,{file:r})})}},{key:"insert-link",label:"Insert Link",onSelect:t=>{t.dispatchCommand(it,{url:"https://example.com"}),queueMicrotask(()=>t.focus())}},{key:"insert-codeInline",label:"Inline Code",onSelect:t=>{t.dispatchCommand(ot,void 0),queueMicrotask(()=>t.focus())}},{key:"insert-codeBlock",label:"Code Block",onSelect:t=>{t.dispatchCommand(st,void 0),queueMicrotask(()=>t.focus())}},{icon:Pt,key:"meta2d",label:"Meta2d",onSelect:t=>{t.dispatchCommand(rt,void 0),queueMicrotask(()=>t.focus())}},{icon:Tt,key:"markmap",label:"Markmap",onSelect:t=>{t.dispatchCommand(ct,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})}),[]),Le=i.useMemo(()=>[lt,dt,ut,xe,mt,ft,ht,yt,gt,xt,vt,oe(bt,{children:c?n.jsx(ve,{editor:c,floating:!0,outlineCollapseTitle:a("outlineHide"),outlineExpandTitle:a("outlineShow"),outlineToggle:!0}):null}),oe(Ct,{handleUpload:async t=>{var o;try{return{url:await ge(t,e.meta.documentId)}}catch(r){throw(o=e.onShowError)==null||o.call(e,ke(r)),r}}}),oe(xe,{defaultBlockImage:!0,needRehost:t=>t.startsWith("blob:"),handleRehost:async t=>{var o;try{const ne=await(await fetch(t)).blob(),g=new File([ne],"image.png",{type:ne.type});return{url:await ge(g,e.meta.documentId)}}catch(r){throw(o=e.onShowError)==null||o.call(e,ke(r)),r}}})],[c,a,e.meta.documentId,e.onShowError]),m=!!e.readerChrome,[B,ee]=i.useState(!1),Y=i.useRef(null),[de,te]=i.useState(0);i.useEffect(()=>{if(!m){ee(!1),te(0);return}if(B)return;const t=window.setTimeout(()=>ee(!0),2800);return()=>window.clearTimeout(t)},[m,B,e.meta.documentId]);function Be(t){!m||B||t.target.closest("button, a, input, textarea, select")||(Y.current={startY:t.clientY,dragging:!0},t.currentTarget.setPointerCapture(t.pointerId))}function _e(t){const o=Y.current;if(!(o!=null&&o.dragging))return;const r=t.clientY-o.startY;te(Math.max(-72,Math.min(0,r)))}function ue(t){const o=Y.current;if(!(o!=null&&o.dragging))return;Y.current=null;const r=t.clientY-o.startY;te(0),r<-36&&ee(!0);try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}return n.jsxs("div",{className:"mdocs-editor"+(m?" mdocs-editor--reader":"")+(m&&B?" mdocs-editor--reader-docked":""),children:[n.jsxs("div",{className:"mdocs-editor-toolbar"+(m?B?" mdocs-editor-toolbar--docked":" mdocs-editor-toolbar--float":""),style:m&&!B&&de!==0?{transform:`translate(-50%, ${de}px)`}:void 0,onPointerDown:Be,onPointerMove:_e,onPointerUp:ue,onPointerCancel:ue,children:[m?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(Ue,{size:18,strokeWidth:1.75})}):null,n.jsx("input",{className:"mdocs-editor-title-input",value:E,onChange:t=>V(t.target.value),onBlur:()=>void Ee(),placeholder:a("displayNamePlaceholder"),disabled:!y,readOnly:m&&!y}),m?null:n.jsx(We,{domains:e.domains.length?e.domains:[qe],value:e.currentDomainId,onChange:e.onDomainChange,onDomainsChange:e.onDomainsChange,ariaLabel:a("currentDomainAria"),localizeName:t=>ye(t,s,a)}),!m&&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:Ve,alt:"",width:16,height:16,style:{display:"block"}}),"帮写"]}):null,n.jsxs("button",{type:"button",className:"secondary mdocs-tooltip mdocs-tooltip-bottom",onClick:()=>void le(),disabled:L,"data-tooltip":d?"取消收藏":"收藏",style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:4,opacity:L?.5:1},children:[n.jsx($e,{size:18,strokeWidth:1.5,style:{color:d?"#faad14":"var(--mdocs-text-secondary, #6b7280)",fill:d?"#faad14":"none"}}),!m&&d?n.jsx("span",{children:"已收藏"}):null]}),m?null:n.jsx("span",{className:"mdocs-editor-toolbar-spacer","aria-hidden":!0}),n.jsxs("div",{className:"mdocs-editor-toolbar-actions",children:[!m&&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(Ot,{size:16,strokeWidth:1.5}),n.jsx("span",{children:a("syncPull")})]}):null,m&&e.canEdit?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"primary mdocs-reader-action-btn",disabled:I,onClick:()=>{y||p(!0),Z().catch(()=>{})},children:a(I?"publishing":"publish")}),n.jsx("button",{type:"button",className:"danger mdocs-reader-action-btn",disabled:I,onClick:()=>void e.onDelete(),children:a("delete")})]}):null,!m&&y?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 "+(I?"saving":U?"unsaved":"saved")}),n.jsx("span",{children:a(I?"publishing":U?"unsaved":"published")})]}),n.jsx("button",{type:"button",className:"primary",disabled:I,onClick:()=>{Z().catch(()=>{})},children:a(I?"publishing":"publish")}),n.jsx("button",{type:"button",className:"danger",disabled:I,onClick:e.onDelete,children:a("delete")})]}):null,!m&&!y&&e.canEdit?n.jsx("button",{type:"button",className:"primary",onClick:()=>p(!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(Ye,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}}),!m&&e.commentCount>0?n.jsx("span",{style:{fontSize:"0.85rem"},children:e.commentCount}):null]}),n.jsxs("div",{ref:N,className:"mdocs-tooltip mdocs-tooltip-bottom","data-tooltip":a("docInfo"),style:{position:"relative"},children:[n.jsx("button",{type:"button",className:"secondary",onClick:()=>f(!v),style:{padding:"4px 8px",minWidth:"auto",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(Ft,{size:18,strokeWidth:1.5,style:{color:"var(--mdocs-text-secondary, #6b7280)"}})}),v&&n.jsxs("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"var(--mdocs-surface, #fff)",border:"1px solid var(--mdocs-border, #e5e5e5)",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)",minWidth:"220px",zIndex:100,padding:"8px 0"},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:j(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(s==="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:je(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(s==="zh"?"zh-CN":"en-US")})]})]}),n.jsx("div",{style:{height:"1px",background:"var(--mdocs-border, #e5e5e5)",margin:"8px 0"}}),n.jsxs("button",{type:"button",style:{width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:t=>{t.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:t=>{t.currentTarget.style.background="none"},onClick:()=>{le()},children:[n.jsx("span",{children:d?"⭐":"☆"}),n.jsx("span",{children:a(d?"bookmarkRemove":"bookmarkAdd")})]}),e.canManageInvites&&n.jsxs("button",{type:"button",style:{width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:t=>{t.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:t=>{t.currentTarget.style.background="none"},onClick:()=>{f(!1),(async()=>{x(!0);try{const t=await Je(e.meta.documentId),o=new Map(t.map(r=>[r.visitorId,r.permission]));W(o),b(!0)}finally{x(!1)}})()},children:[n.jsx(Wt,{size:14}),n.jsx("span",{children:a("docInfoInviteMember")})]}),n.jsxs("button",{type:"button",style:{width:"100%",textAlign:"left",padding:"8px 16px",background:"none",border:"none",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:t=>{t.currentTarget.style.background="var(--mdocs-hover-bg, #f5f5f5)"},onMouseLeave:t=>{t.currentTarget.style.background="none"},onClick:()=>{f(!1),O(e.meta.permission),A(!0)},children:[n.jsx(Ht,{size:14}),n.jsx("span",{children:a("docInfoChangePermission")})]})]})]})]})]}),T&&n.jsx("div",{className:"mdocs-dialog-backdrop",style:{position:"fixed",zIndex:9999},onClick:t=>{t.target===t.currentTarget&&A(!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"),":",D?ye(D.domainName,s,a):e.meta.domainId]}),n.jsx("div",{style:{display:"grid",gap:8},children:Re.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:C===t,onChange:()=>O(t)}),n.jsx("span",{children:De(t)})]},t))}),n.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[n.jsx("button",{type:"button",onClick:()=>A(!1),children:a("cancel")}),n.jsx("button",{type:"button",className:"primary",disabled:M,onClick:()=>void Ne(),children:a(M?"publishing":"saveAndPublish")})]})]})}),e.canManageInvites&&n.jsx(Bt,{open:h,title:a("docInfoInviteMember"),initialSelectedIds:[...w.keys()],initialPermissions:w,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:a("invitePermissionRead")},{value:"edit",label:a("invitePermissionEdit")}],onClose:()=>b(!1),onConfirm:t=>{Ae(t)}}),n.jsx(kt,{children:n.jsx(fe,{flex:1,style:{minHeight:0},children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[y&&c&&!m?n.jsx(ve,{editor:c,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(fe,{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:Ce?n.jsx(It,{content:F,type:R,confirmPasteMarkdown:!0,editable:y,onInit:Me,plugins:Le,lineEmptyPlaceholder:a("displayNamePlaceholder"),placeholder:a("displayNamePlaceholder"),slashOption:{items:Te},className:"mdocs-document-editor-root"},e.meta.documentId):null}),c&&n.jsx(Gt,{editor:c})]})})]})})})]})}export{cn as DocumentEditor};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{r as n,j as o,ae as C}from"./react-vendor-BJFXgntS.js";import{u as N,E as T,R as I,a as E,b as M,c as j,d as O,e as P,f as A,g as _,h as D,i as H,w as g,j as L,k as F,l as q,I as U,m as b,n as V,o as z,p as J,q as W,r as B,s as $,t as K,v as Y,x as G,y as Z}from"./react-BUhFwPCj.js";import{v as Q,x as X,H as ee,y as te,A as k,z as oe}from"./ui-06fxEgif.js";import{H as re,a as ae,b as ne,M as le,T as ie,S as se,W as de,N as ce,c as R,o as me}from"./Toolbar-B36NxaTc.js";import"./editor-ONzd_YnO.js";import"./diagram-3lhA7FYR.js";import"./index-DgM2rYI-.js";import"./motion-92iQWeIW.js";import"./plus-BWV299MC.js";import"./copy-CX8GOyUb.js";const ue=({children:h,json:r,markdown:a,collapsible:m=!1,defaultActiveKey:y=["editor","text","json"],onJSONChange:p})=>{const[f,c]=n.useState(r),s=n.useRef(r);n.useEffect(()=>{r!==s.current&&(c(r),s.current=r)},[r]);const x=n.useCallback(d=>{s.current=d,c(d)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(Q,{}),o.jsx(X,{collapsible:m,defaultActiveKey:y,items:[{children:h,key:"editor",label:"Playground"},{children:o.jsx(ee,{language:"markdown",style:{fontSize:12,padding:16},variant:"borderless",children:a}),key:"text",label:"Text Output"},{children:o.jsx(te,{language:"json",onBlur:()=>{if(r!==s.current)try{const d=JSON.parse(s.current||"");p==null||p(d)}catch(d){console.error("Invalid JSON:",d)}},onValueChange:x,value:f,variant:"borderless"}),key:"json",label:"JSON Output"}],padding:{body:0},style:{border:"none",borderRadius:0,width:"100%"},variant:"outlined"})]})},he={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Welcome to the Lobe Editor Demo!",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"In case you were wondering what the black box at the bottom is – it's the debug view, showing the current state of the editor. You can disable it by pressing on the settings control in the bottom-left of your screen and toggling the debug view setting.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"quote",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"The playground is a demo environment built with ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"@lobehub/editor",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:". Try typing in ",type:"text",version:1},{detail:0,format:1,mode:"normal",style:"",text:"some text",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:" with ",type:"text",version:1},{detail:0,format:2,mode:"normal",style:"",text:"different formats",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Visit the ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lobe Editor website",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://editor.lobehub.com"},{detail:0,format:0,mode:"normal",style:"",text:" for documentation and more information.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Check out the code on our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"GitHub repository",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://github.com/lobehub/lobe-editor",url:"https://github.com/lobehub/lobe-editor"},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:2},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://github.com/lobehub/lobe-editor/blob/master/src/react/Editor/demos/index.tsx"},{detail:0,format:0,mode:"normal",style:"",text:" can be found here.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:3},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Join our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Discover Server",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://discord.gg/AYFPHvv2jT",url:"https://discord.gg/AYFPHvv2jT"},{detail:0,format:0,mode:"normal",style:"",text:" and chat with the team.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:4}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lastly, we're constantly adding cool new features to this playground. So make sure you check back here when you next get a chance 🙂.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"import",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"{",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:"Editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"}",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"from",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-success);",text:"@lobehub/editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:";",type:"code-highlight",version:1}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript",theme:"lobe-theme"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""}],direction:"ltr",format:"",indent:0,type:"root",version:1},ye={root:he};function S(h,r){let a;const m=(...y)=>{a!==void 0&&clearTimeout(a),a=setTimeout(()=>h(...y),r)};return m.cancel=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m}window.__scrollIntoView=Z;const pe=h=>{const r=N(),a=n.useRef([]),[m,y]=n.useState(""),[p,f]=n.useState(""),c=n.useMemo(()=>S(t=>{const e=t.getDocument("markdown"),l=t.getDocument("json");f(e||""),y(JSON.stringify(l||{},null,2))},200),[]),s=n.useMemo(()=>S(t=>{r&&(console.info("handleJSONChange",t),r.setDocument("json",t))},200),[r]),x=t=>{window.editor=t,c(t)};n.useEffect(()=>()=>{for(const t of a.current)URL.revokeObjectURL(t);a.current=[],c.cancel(),s.cancel(),delete window.editor,delete window.__scrollIntoView},[c,s]);const d=n.useMemo(()=>[{icon:o.jsx(k,{avatar:"💻",size:24}),key:"bot1",label:"前端研发专家",metadata:{id:"bot1"}},{icon:o.jsx(k,{avatar:"🌍",size:24}),key:"bot2",label:"中英文互译助手",metadata:{id:"bot2"}},{icon:o.jsx(k,{avatar:"📖",size:24}),key:"bot3",label:"学术写作增强专家",metadata:{id:"bot3"}}],[]),w=n.useMemo(()=>[{icon:re,key:"h1",label:"Heading 1",onSelect:e=>{e.dispatchCommand(b,{tag:"h1"})}},{icon:ae,key:"h2",label:"Heading 2",onSelect:e=>{e.dispatchCommand(b,{tag:"h2"})}},{icon:ne,key:"h3",label:"Heading 3",onSelect:e=>{e.dispatchCommand(b,{tag:"h3"})}},{type:"divider"},{icon:le,key:"hr",label:"Hr",onSelect:e=>{e.dispatchCommand(V,{})}},{icon:ie,key:"table",label:"Table",onSelect:e=>{e.dispatchCommand(z,{columns:"3",rows:"3"})}},{icon:se,key:"tex",label:"Tex",onSelect:e=>{e.dispatchCommand(J,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>{e.focus()})}},{type:"divider"},{key:"file",label:"File",onSelect:e=>{me(l=>{for(const u of l)e.dispatchCommand(W,{file:u})})}},{key:"set-text-content",label:"SetTextContent",onSelect:e=>{e.setDocument("text",`123
|
|
2
|
-
123`),queueMicrotask(()=>{e.focus()})}},{key:"insert-link",label:"InsertLink",onSelect:e=>{e.dispatchCommand(B,{url:"https://example.com"}),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeInline",label:"InsertCodeInline",onSelect:e=>{e.dispatchCommand($,void 0),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeBlock",label:"InsertCodeBlock",onSelect:e=>{e.dispatchCommand(K,void 0),queueMicrotask(()=>{e.focus()})}},{icon:de,key:"meta2d",label:"Meta2d",onSelect:e=>{e.dispatchCommand(Y,void 0),queueMicrotask(()=>{e.focus()})}},{icon:ce,key:"markmap",label:"Markmap",onSelect:e=>{e.dispatchCommand(G,void 0),queueMicrotask(()=>{e.focus()})}}].map(e=>e.type==="divider"?e:{...e,extra:o.jsx(oe,{code:!0,fontSize:12,type:"secondary",children:e.key})}),[]);return o.jsxs(ue,{json:m,markdown:p,onJSONChange:s,...h,children:[o.jsx(R,{editor:r}),o.jsx(T,{className:"mdocs-playground-editor",content:ye,editor:r,lineEmptyPlaceholder:"Start typing here...",mentionOption:{items:d,markdownWriter:t=>{var e;return`
|
|
3
|
-
<mention>${t.label}[${((e=t.metadata)==null?void 0:e.id)||t.label}]</mention>
|
|
4
|
-
`},onSelect:(t,e)=>{t.dispatchCommand(U,{label:String(e.label),metadata:{id:e.key}})},searchKeys:["label"]},onInit:x,onTextChange:c,pasteVSCodeAsCodeBlock:!0,placeholder:"Type something...",plugins:[I,E,M,j,O,P,A,_,D,H,g(L,{children:o.jsx(R,{editor:r,floating:!0})}),g(F,{delay:1e3,onAutoComplete:async({input:t,afterText:e,selectionType:l,abortSignal:u})=>{console.log("Auto-complete triggered:",{afterText:e,input:t,selectionType:l});try{const v=await fetch(`${location.origin}/nodeserver/completion`,{body:JSON.stringify({prompt:`Please complete the following text:
|
|
5
|
-
|
|
6
|
-
${t}`}),headers:{"Content-Type":"application/json"},method:"POST",signal:u});if(u.aborted)return console.log("Auto-complete aborted"),null;const i=await v.json();if(i)return typeof i.content=="string"&&i.content.startsWith(t)?i.content.replace(t,""):i.content}catch{}return null}}),g(M,{defaultBlockImage:!0,handleRehost:async t=>{const l=await(await fetch(t)).blob();return await new Promise((u,v)=>{const i=new FileReader;i.onloadend=()=>u({url:i.result}),i.onerror=v,i.readAsDataURL(l)})},needRehost:t=>(console.debug("needRehost",t),t.startsWith("blob:"))}),g(q,{handleUpload:async t=>(console.debug("Files uploaded:",t),new Promise(e=>{setTimeout(()=>{const l=URL.createObjectURL(t);a.current.push(l),e({url:l})},1e3)})),markdownWriter:t=>`
|
|
7
|
-
<file>${t.fileUrl}</file>
|
|
8
|
-
`})],slashOption:{items:w}})]})};function Ce(){return o.jsxs("div",{className:"mdocs-playground-page",children:[o.jsx("header",{className:"mdocs-playground-header",children:o.jsx(C,{className:"mdocs-playground-back",to:"/",children:"← mdocs"})}),o.jsx(pe,{})]})}export{Ce as PlaygroundPage};
|