@gientech/modual 1.2.8 → 1.3.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/dist/assets/index-Bpnc4tRH.js +1284 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/style3.css +1 -1
- package/dist/chat.js +85 -79
- package/dist/databaseId.js +1 -1
- package/dist/package.json +1 -1
- package/dist/streamFilesReader.js +2 -2
- package/package.json +100 -99
- package/src/examples/chat/components/DrawerGraphPreview.tsx +77 -0
- package/src/examples/chat/index.tsx +126 -87
- package/src/modules/chat/index.tsx +1 -2
- package/src/modules/nodegraph/index.tsx +1 -0
- package/src/utils/testconfigs/index.ts +1 -1
- package/stats.html +1 -1
- package/vite.config.ts +0 -1
- package/dist/assets/index-97TKgPKE.js +0 -1284
package/dist/databaseId.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as v,Fragment as fe}from"react/jsx-runtime";import{useMemo as J,useState as C,useRef as de,useCallback as j,useEffect as ye}from"react";import{message as X,Drawer as De,Modal as me,Tooltip as Fe,Switch as Se,Popover as Me,Badge as Ce,Tag as ze}from"antd";import{u as Le}from"./assets/index-CpW6Dhpp.js";import{F as _e,k as be,J as $,C as Ve,U as Ne,m as Ue}from"./assets/index-DIm7RgkM.js";import{c as Ae}from"./assets/index-CEK88UzR.js";/* empty css */import{
|
|
1
|
+
import{jsx as e,jsxs as v,Fragment as fe}from"react/jsx-runtime";import{useMemo as J,useState as C,useRef as de,useCallback as j,useEffect as ye}from"react";import{message as X,Drawer as De,Modal as me,Tooltip as Fe,Switch as Se,Popover as Me,Badge as Ce,Tag as ze}from"antd";import{u as Le}from"./assets/index-CpW6Dhpp.js";import{F as _e,k as be,J as $,C as Ve,U as Ne,m as Ue}from"./assets/index-DIm7RgkM.js";import{c as Ae}from"./assets/index-CEK88UzR.js";/* empty css */import{I as Be}from"./assets/index-Bpnc4tRH.js";import Re from"axios";import{X as pe}from"./assets/x-vPcWt3fC.js";import"./assets/styled-components.browser.esm-DPkS13KC.js";import"react-dom";import"./assets/circle-alert-g2Y6zAjt.js";/**
|
|
2
2
|
* @license lucide-react v0.456.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dist/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Vn=Object.defineProperty;var wn=p=>{throw TypeError(p)};var Yn=(p,o,y)=>o in p?Vn(p,o,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[o]=y;var se=(p,o,y)=>Yn(p,typeof o!="symbol"?o+"":o,y),ln=(p,o,y)=>o.has(p)||wn("Cannot "+y);var R=(p,o,y)=>(ln(p,o,"read from private field"),y?y.call(p):o.get(p)),Lt=(p,o,y)=>o.has(p)?wn("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(p):o.set(p,y),Bt=(p,o,y,f)=>(ln(p,o,"write to private field"),f?f.call(p,y):o.set(p,y),y),Mt=(p,o,y)=>(ln(p,o,"access private method"),y);var un=(p,o,y,f)=>({set _(_){Bt(p,o,_,y)},get _(){return R(p,o,f)}});import{jsxs,jsx,Fragment}from"react/jsx-runtime";import c__default,{forwardRef,createElement,useState,useRef,useEffect,useCallback,useMemo}from"react";import{d as dt$1}from"./assets/styled-components.browser.esm-DPkS13KC.js";import axios from"axios";import{a as getAugmentedNamespace}from"./assets/_commonjsHelpers-gnU0ypJ3.js";import{
|
|
1
|
+
var Vn=Object.defineProperty;var wn=p=>{throw TypeError(p)};var Yn=(p,o,y)=>o in p?Vn(p,o,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[o]=y;var se=(p,o,y)=>Yn(p,typeof o!="symbol"?o+"":o,y),ln=(p,o,y)=>o.has(p)||wn("Cannot "+y);var R=(p,o,y)=>(ln(p,o,"read from private field"),y?y.call(p):o.get(p)),Lt=(p,o,y)=>o.has(p)?wn("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(p):o.set(p,y),Bt=(p,o,y,f)=>(ln(p,o,"write to private field"),f?f.call(p,y):o.set(p,y),y),Mt=(p,o,y)=>(ln(p,o,"access private method"),y);var un=(p,o,y,f)=>({set _(_){Bt(p,o,_,y)},get _(){return R(p,o,f)}});import{jsxs,jsx,Fragment}from"react/jsx-runtime";import c__default,{forwardRef,createElement,useState,useRef,useEffect,useCallback,useMemo}from"react";import{d as dt$1}from"./assets/styled-components.browser.esm-DPkS13KC.js";import axios from"axios";import{a as getAugmentedNamespace}from"./assets/_commonjsHelpers-gnU0ypJ3.js";import{A as AL,S as Sc}from"./assets/index-Bpnc4tRH.js";import{c as createLucideIcon,C as ChevronRight}from"./assets/index-CEK88UzR.js";import{X}from"./assets/x-vPcWt3fC.js";import"react-dom";/**
|
|
2
2
|
* @license lucide-react v0.456.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -167,7 +167,7 @@ var Vn=Object.defineProperty;var wn=p=>{throw TypeError(p)};var Yn=(p,o,y)=>o in
|
|
|
167
167
|
0% { transform: rotate(0deg); }
|
|
168
168
|
100% { transform: rotate(360deg); }
|
|
169
169
|
}
|
|
170
|
-
`))},Oe=(p,o)=>{var y,f,_,Y,W;console.log("=== Fviewer renderTextContent ==="),console.log("data:",p),console.log("data.content:",p.content);let K="";typeof p.content=="string"?K=p.content:(y=p.content)!=null&&y.text?K=p.content.text:(f=p.content)!=null&&f.content&&(K=p.content.content),console.log("\u5B9E\u9645\u6587\u672C\u5185\u5BB9:",K);const M=useRef(null),b=useRef(null);return useEffect(()=>{if(M.current&&b.current&&K){const w=setTimeout(()=>{var T;const S=((T=M.current)==null?void 0:T.scrollHeight)||0,v=Math.max(S+80,200);b.current&&(b.current.style.minHeight=`${v}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",v))},100);return()=>clearTimeout(w)}},[K]),c__default.createElement("div",{style:{height:"100%",overflow:"auto",backgroundColor:"#f5f5f5",padding:"20px",display:"flex",justifyContent:"center",position:"relative"}},c__default.createElement("div",{ref:b,style:{width:"100%",maxWidth:"800px",backgroundColor:"white",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"40px",margin:"20px 0",position:"relative",transform:`scale(${o.scale||1})`,transition:"transform 0.2s ease-in-out",transformOrigin:"top center"}},c__default.createElement("div",{ref:M,style:{width:"100%",overflow:"visible"}},c__default.createElement(IL,{dataSource:{type:xc.TEXT,content:K},size:"md",theme:{primaryColor:((W=(Y=(_=o.styles)==null?void 0:_.theme)==null?void 0:Y.colors)==null?void 0:W.primary)||"#007bff",backgroundColor:"transparent",textColor:"#333",borderColor:"transparent",borderRadius:"0",padding:"0"},style:{border:"none",background:"transparent",width:"100%",height:"auto",overflow:"visible"}})),c__default.createElement("div",{style:{position:"absolute",top:"0",left:"0",right:"0",height:"2px",background:"linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%)",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}})))},He=({data:p,parentProps:o,isTableMode:y=!1})=>{var f,_,Y,W,K,M,b,w,T,S,v,c;const t=useRef(null),r=useRef(null),a=useRef(null),F=useRef(!1);useRef(0),useRef(null);const[m]=useState(!1),l=(V,O)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:V,scrollHeight:O}),o.eventsEmit&&o.eventsEmit("markdown_scroll",{scrollTop:V,scrollHeight:O})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),o.eventsEmit&&o.eventsEmit("markdown_scroll_to_top")},i=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),o.eventsEmit&&o.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=V=>{var O,z;try{if(!y)return;const G=typeof p.content=="string"?p.content:((O=p.content)==null?void 0:O.content)||"";if(!G||I.length===0)return;const _t=JSON.stringify(I.map(Ot=>({o:Ot.offsets,c:Ot.color}))),wt=`${G.length}:${G.substring(0,64)}:${G.substring(G.length-64)}|${_t}`;if(((z=V.dataset)==null?void 0:z.tableAnnoRuntimeSig)===wt)return;setTimeout(()=>{Pt(),V.dataset&&(V.dataset.tableAnnoRuntimeSig=wt)},50)}catch(G){console.warn("[MarkdownRendered] apply failed",G)}};const E=c__default.useCallback(V=>{var O;return(O=e.current)==null?void 0:O.call(e,V)},[]),x=useCallback(()=>{var V;if(!m||!t.current)return;const O=window.getSelection();if(!O||O.isCollapsed)return;const z=O.getRangeAt(0),G=z.toString().trim();if(!G)return;const _t=t.current;let wt=0,Ot=0;const q=document.createTreeWalker(_t,NodeFilter.SHOW_TEXT,{acceptNode:P=>{var j;return(j=P.parentElement)!=null&&j.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let d=q.nextNode();for(;d;){if(d===z.startContainer){Ot=wt+z.startOffset;break}wt+=((V=d.textContent)==null?void 0:V.length)||0,d=q.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:G,startOffset:Ot,charCount:wt,container:z.startContainer.textContent});const u={id:`md-anno-${Date.now()}`,start:Ot,end:Ot+G.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",u),o.eventsEmit&&o.eventsEmit("md_annotation_add",u),O.removeAllRanges()},[m,o.eventsEmit]),N=y?[]:(o.annotationData||[]).filter(V=>"start"in V&&"end"in V&&!("pageNumber"in V)),I=y?(o.annotationData||[]).filter(V=>"offsets"in V&&Array.isArray(V.offsets)):[],St=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u6E05\u7A7A\u6240\u6709\u6807\u6CE8 ==="),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u6E05\u7A7A\u6807\u6CE8");return}const V=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",V.length),V.length>0&&V.forEach(O=>{const z=O.parentNode;z&&z.replaceChild(document.createTextNode(O.textContent||""),O)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),Pt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",I),!t.current||!I.length){console.log("\u8868\u683C\u6807\u6CE8\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u9000\u51FA");return}const V=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",V.length),V.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}F.current=!0,I.forEach((O,z)=>{const G=O.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",O),!Array.isArray(G)||!G.length||!Array.isArray(G[0])||G[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",O);return}G.forEach((_t,wt)=>{const[Ot,q]=_t;if(typeof Ot!="number"||typeof q!="number"){console.warn("[TableAnnotation] offset is not [number, number]",_t);return}V.forEach((d,u)=>{var P,j,U;let $;const s=d.tBodies&&d.tBodies.length>0?Array.from(d.tBodies[0].rows):[];if(s.length>0)$=s[Ot];else{const k=((j=(P=d.tHead)==null?void 0:P.rows)==null?void 0:j.length)||0;$=Array.from(d.rows)[Ot+k]}if(!$){console.warn("[TableAnnotation] row out of range",{row:Ot,tableIndex:u});return}const h=(U=$.cells)==null?void 0:U[q];if(!h){console.warn("[TableAnnotation] cell is undefined",{row:Ot,col:q,tableIndex:u});return}const C=O.color||"rgba(255, 229, 153, 0.5)",A=getComputedStyle(h).backgroundColor;h.getAttribute("data-table-annotated")==="1"&&(A===C||h.style.backgroundColor===C)||(h.style.setProperty("background",C,"important"),h.style.setProperty("background-color",C,"important"),h.setAttribute("data-table-annotated","1")),O.content&&(h.title=O.content),wt===0&&z===0&&setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{F.current=!1})},[I]),bt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!N.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}r.current&&clearTimeout(r.current);const V=()=>{var O;console.log("\u5F00\u59CB\u5E94\u7528\u6807\u6CE8...");const z=(O=t.current)==null?void 0:O.querySelectorAll(".md-annotation");console.log("\u79FB\u9664\u73B0\u6709\u6807\u6CE8\u6570\u91CF:",(z==null?void 0:z.length)||0),z==null||z.forEach(u=>{const P=u.parentNode;P&&P.replaceChild(document.createTextNode(u.textContent||""),u)});const G=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:u=>{var P;return(P=u.parentElement)!=null&&P.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),_t=[];let wt;for(;wt=G.nextNode();)_t.push(wt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",_t.length),_t.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),r.current=setTimeout(()=>{V()},200);return}let Ot=0;const q=_t.map(u=>{var P;const j=Ot;return Ot+=((P=u.textContent)==null?void 0:P.length)||0,{node:u,start:j,end:Ot,text:u.textContent}});console.log("\u6587\u672C\u8282\u70B9\u4F4D\u7F6E:",q),console.log("\u603B\u6587\u672C\u957F\u5EA6:",Ot);const d=[...N].sort((u,P)=>P.start-u.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",d),d.forEach(u=>{const{start:P,end:j,color:U}=u;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:u,nodePositions:q});const $=q.filter(s=>P<s.end&&j>s.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",$.length),$.forEach(({node:s,start:h})=>{var C,A,k,B,D,g;const L=Math.max(0,P-h),At=Math.min(((C=s.textContent)==null?void 0:C.length)||0,j-h);if(console.log("\u672C\u5730\u4F4D\u7F6E:",{localStart:L,localEnd:At,nodeTextLength:(A=s.textContent)==null?void 0:A.length}),L>=At){console.log("\u672C\u5730\u4F4D\u7F6E\u65E0\u6548\uFF0C\u8DF3\u8FC7");return}const H=((k=s.textContent)==null?void 0:k.slice(0,L))||"",Q=((B=s.textContent)==null?void 0:B.slice(L,At))||"",vt=((D=s.textContent)==null?void 0:D.slice(At))||"";console.log("\u5206\u5272\u6587\u672C:",{before:H,annotatedText:Q,after:vt});const Tt=document.createElement("span");Tt.className="md-annotation",Tt.style.backgroundColor=U||"#FFE599",Tt.textContent=Q;const It=document.createDocumentFragment();H&&It.appendChild(document.createTextNode(H)),It.appendChild(Tt),vt&&It.appendChild(document.createTextNode(vt)),(g=s.parentNode)==null||g.replaceChild(It,s),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",Q)})})};r.current=setTimeout(()=>{V()},100)},[N]);return useEffect(()=>{var V;if(y){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const O=typeof p.content=="string"?p.content:((V=p.content)==null?void 0:V.content)||"";if(!O||typeof O!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8\u9AD8\u4EAE ==="),console.log("markdownRef.current:",t.current),console.log("isTableMode:",y),console.log("mdAnnotations:",N),console.log("tableAnnotations:",I),console.log("data.content:",p.content),console.log("\u5B9E\u9645\u5185\u5BB9:",O),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA\u6807\u6CE8\u5E94\u7528");return}if(y||St(),!y&&N.length>0){bt();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[y,I,N]),useEffect(()=>{if(!y)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,y]),useEffect(()=>{var V;const O=typeof p.content=="string"?p.content:((V=p.content)==null?void 0:V.content)||"";if(!O||typeof O!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8C03\u8BD5\u4FE1\u606F\u6253\u5370");return}console.log("=== Markdown\u5185\u5BB9\u4FE1\u606F ==="),console.log("isTableMode:",y),console.log("\u5185\u5BB9\u957F\u5EA6:",O.length||0),typeof O=="string"?(console.log("\u5185\u5BB9\u524D100\u5B57\u7B26:",O.substring(0,100)),console.log("\u5185\u5BB9\u540E100\u5B57\u7B26:",O.substring(O.length-100))):(console.log("\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B:",typeof O),console.log("\u5185\u5BB9\u503C:",O)),console.log("\u6807\u6CE8\u6570\u636E:",N),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",I)},[N,I,y]),useEffect(()=>{if(y&&t.current){const V=setTimeout(()=>{var O;const z=(O=t.current)==null?void 0:O.querySelectorAll("table");z&&z.length>0&&(console.log("\u8C03\u6574\u8868\u683C\u5C3A\u5BF8\uFF0C\u627E\u5230\u8868\u683C\u6570\u91CF:",z.length),z.forEach((G,_t)=>{if(G instanceof HTMLTableElement){G.style.width="100%",G.style.minWidth="100%",G.style.tableLayout="auto";const wt=G.closest(".markdown-table-mode");wt&&wt instanceof HTMLElement&&(wt.style.width="100%",wt.style.overflowX="auto"),console.log(`\u8868\u683C ${_t+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(V)}},[y,p.content]),useEffect(()=>()=>{r.current&&clearTimeout(r.current),a.current&&(a.current.disconnect(),a.current=null)},[]),c__default.createElement("div",{style:{height:"100%",width:"100%",overflow:"auto"},className:`markdown-container markdown-scrollbar ${y?"markdown-table-mode":""}`},c__default.createElement("style",null,Se),c__default.createElement("div",{ref:t},c__default.createElement(IL,{dataSource:{type:xc.MARKDOWN,content:(()=>{var V,O;return typeof p.content=="string"?p.content:(V=p.content)!=null&&V.text?p.content.text:(O=p.content)!=null&&O.content?p.content.content:""})()},size:"md",onScroll:y?void 0:l,onScrollToTop:y?void 0:n,onScrollToBottom:y?void 0:i,onRendered:E,theme:{primaryColor:((Y=(_=(f=o.styles)==null?void 0:f.theme)==null?void 0:_.colors)==null?void 0:Y.primary)||"#007bff",backgroundColor:((M=(K=(W=o.styles)==null?void 0:W.theme)==null?void 0:K.colors)==null?void 0:M.background)||"#f8f9fa",textColor:((T=(w=(b=o.styles)==null?void 0:b.theme)==null?void 0:w.colors)==null?void 0:T.text)||"#343a40",borderColor:((c=(v=(S=o.styles)==null?void 0:S.theme)==null?void 0:v.colors)==null?void 0:c.border)||"#dee2e6",borderRadius:y?"0px":"8px",padding:y?"0px":"20px"},style:{height:"100%",border:"none",background:"transparent",overflowY:y?"visible":"scroll"}})))},Ze=({markdown:p,onRendered:o,tableAnnotations:y=[]})=>{const f=useRef(null),_=W=>{const K=W.split(/\r?\n/).filter(S=>S.trim().length>0);let M=-1;for(let S=0;S<K.length-1;S++){const v=K[S].trim(),c=K[S+1].trim();if(v.startsWith("|")&&v.endsWith("|")&&c.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=S;break}}if(M===-1)return null;const b=K[M].split("|").slice(1,-1).map(S=>S.trim()),w=[];for(let S=M+2;S<K.length;S++){const v=K[S].trim();if(!v.startsWith("|")||!v.endsWith("|"))break;w.push(v)}const T=w.map(S=>S.split("|").slice(1,-1).map(v=>v.trim()));return{headers:b,rows:T}},Y=c__default.useMemo(()=>_(p),[p]);return useEffect(()=>{const W=()=>{try{if(!f.current||!y.length)return;const M=f.current.querySelectorAll("table");if(!M||M.length===0)return;y.forEach((b,w)=>{(b.offsets||[]).forEach((T,S)=>{const[v,c]=T;M.forEach(t=>{var r,a,F;const m=t.tBodies&&t.tBodies.length>0?Array.from(t.tBodies[0].rows):[];let l;if(m.length>0)l=m[v];else{const e=((a=(r=t.tHead)==null?void 0:r.rows)==null?void 0:a.length)||0;l=Array.from(t.rows)[v+e]}if(!l)return;const n=(F=l.cells)==null?void 0:F[c];if(!n)return;const i=b.color||"rgba(255, 229, 153, 0.5)";n.getAttribute("data-table-annotated")==="1"||(n.style.setProperty("background",i,"important"),n.style.setProperty("background-color",i,"important"),n.setAttribute("data-table-annotated","1"),b.content&&(n.title=b.content)),w===0&&S===0&&setTimeout(()=>n.scrollIntoView({behavior:"smooth",block:"start"}),50)})})})}catch(M){console.warn("[MinimalMarkdownTable] apply annotations failed",M)}},K=requestAnimationFrame(()=>{W(),o&&o()});return()=>cancelAnimationFrame(K)},[p,y,o]),Y?c__default.createElement("div",{ref:f,className:"markdown-table-mode z-mdtbl-wrapper"},c__default.createElement("style",null,`
|
|
170
|
+
`))},Oe=(p,o)=>{var y,f,_,Y,W;console.log("=== Fviewer renderTextContent ==="),console.log("data:",p),console.log("data.content:",p.content);let K="";typeof p.content=="string"?K=p.content:(y=p.content)!=null&&y.text?K=p.content.text:(f=p.content)!=null&&f.content&&(K=p.content.content),console.log("\u5B9E\u9645\u6587\u672C\u5185\u5BB9:",K);const M=useRef(null),b=useRef(null);return useEffect(()=>{if(M.current&&b.current&&K){const w=setTimeout(()=>{var T;const S=((T=M.current)==null?void 0:T.scrollHeight)||0,v=Math.max(S+80,200);b.current&&(b.current.style.minHeight=`${v}px`,console.log("\u6587\u672C\u7EB8\u5F20\u9AD8\u5EA6\u8C03\u6574\u5B8C\u6210:",v))},100);return()=>clearTimeout(w)}},[K]),c__default.createElement("div",{style:{height:"100%",overflow:"auto",backgroundColor:"#f5f5f5",padding:"20px",display:"flex",justifyContent:"center",position:"relative"}},c__default.createElement("div",{ref:b,style:{width:"100%",maxWidth:"800px",backgroundColor:"white",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"40px",margin:"20px 0",position:"relative",transform:`scale(${o.scale||1})`,transition:"transform 0.2s ease-in-out",transformOrigin:"top center"}},c__default.createElement("div",{ref:M,style:{width:"100%",overflow:"visible"}},c__default.createElement(AL,{dataSource:{type:Sc.TEXT,content:K},size:"md",theme:{primaryColor:((W=(Y=(_=o.styles)==null?void 0:_.theme)==null?void 0:Y.colors)==null?void 0:W.primary)||"#007bff",backgroundColor:"transparent",textColor:"#333",borderColor:"transparent",borderRadius:"0",padding:"0"},style:{border:"none",background:"transparent",width:"100%",height:"auto",overflow:"visible"}})),c__default.createElement("div",{style:{position:"absolute",top:"0",left:"0",right:"0",height:"2px",background:"linear-gradient(90deg, #e0e0e0 0%, #f0f0f0 50%, #e0e0e0 100%)",borderTopLeftRadius:"8px",borderTopRightRadius:"8px"}})))},He=({data:p,parentProps:o,isTableMode:y=!1})=>{var f,_,Y,W,K,M,b,w,T,S,v,c;const t=useRef(null),r=useRef(null),a=useRef(null),F=useRef(!1);useRef(0),useRef(null);const[m]=useState(!1),l=(V,O)=>{console.log("=== Markdownit\u6EDA\u52A8\u4E8B\u4EF6\u89E6\u53D1 ==="),console.log("\u6EDA\u52A8\u4F4D\u7F6E:",{scrollTop:V,scrollHeight:O}),o.eventsEmit&&o.eventsEmit("markdown_scroll",{scrollTop:V,scrollHeight:O})},n=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u9876\u90E8 ==="),o.eventsEmit&&o.eventsEmit("markdown_scroll_to_top")},i=()=>{console.log("=== Markdownit\u6EDA\u52A8\u5230\u5E95\u90E8 ==="),o.eventsEmit&&o.eventsEmit("markdown_scroll_to_bottom")},e=useRef();e.current=V=>{var O,z;try{if(!y)return;const G=typeof p.content=="string"?p.content:((O=p.content)==null?void 0:O.content)||"";if(!G||I.length===0)return;const _t=JSON.stringify(I.map(Ot=>({o:Ot.offsets,c:Ot.color}))),wt=`${G.length}:${G.substring(0,64)}:${G.substring(G.length-64)}|${_t}`;if(((z=V.dataset)==null?void 0:z.tableAnnoRuntimeSig)===wt)return;setTimeout(()=>{Pt(),V.dataset&&(V.dataset.tableAnnoRuntimeSig=wt)},50)}catch(G){console.warn("[MarkdownRendered] apply failed",G)}};const E=c__default.useCallback(V=>{var O;return(O=e.current)==null?void 0:O.call(e,V)},[]),x=useCallback(()=>{var V;if(!m||!t.current)return;const O=window.getSelection();if(!O||O.isCollapsed)return;const z=O.getRangeAt(0),G=z.toString().trim();if(!G)return;const _t=t.current;let wt=0,Ot=0;const q=document.createTreeWalker(_t,NodeFilter.SHOW_TEXT,{acceptNode:P=>{var j;return(j=P.parentElement)!=null&&j.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let d=q.nextNode();for(;d;){if(d===z.startContainer){Ot=wt+z.startOffset;break}wt+=((V=d.textContent)==null?void 0:V.length)||0,d=q.nextNode()}console.log("\u9009\u4E2D\u6587\u672C\u4FE1\u606F:",{text:G,startOffset:Ot,charCount:wt,container:z.startContainer.textContent});const u={id:`md-anno-${Date.now()}`,start:Ot,end:Ot+G.length,color:"#FFE599"};console.log("\u521B\u5EFA\u65B0\u6807\u6CE8:",u),o.eventsEmit&&o.eventsEmit("md_annotation_add",u),O.removeAllRanges()},[m,o.eventsEmit]),N=y?[]:(o.annotationData||[]).filter(V=>"start"in V&&"end"in V&&!("pageNumber"in V)),I=y?(o.annotationData||[]).filter(V=>"offsets"in V&&Array.isArray(V.offsets)):[],St=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u6E05\u7A7A\u6240\u6709\u6807\u6CE8 ==="),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u6E05\u7A7A\u6807\u6CE8");return}const V=t.current.querySelectorAll(".md-annotation");console.log("\u6E05\u7A7AMarkdown\u6807\u6CE8\u6570\u91CF:",V.length),V.length>0&&V.forEach(O=>{const z=O.parentNode;z&&z.replaceChild(document.createTextNode(O.textContent||""),O)}),console.log("\u6240\u6709\u6807\u6CE8\u5DF2\u6E05\u7A7A")},[]),Pt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528\u8868\u683C\u6807\u6CE8 ==="),console.log("tableAnnotations:",I),!t.current||!I.length){console.log("\u8868\u683C\u6807\u6CE8\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u9000\u51FA");return}const V=t.current.querySelectorAll("table");if(console.log("\u627E\u5230\u8868\u683C\u6570\u91CF:",V.length),V.length===0){console.log("\u6CA1\u6709\u627E\u5230\u8868\u683C\u5143\u7D20");return}F.current=!0,I.forEach((O,z)=>{const G=O.offsets;if(console.log("\u5904\u7406\u8868\u683C\u6807\u6CE8:",O),!Array.isArray(G)||!G.length||!Array.isArray(G[0])||G[0].length!==2){console.warn("[TableAnnotation] annotation.offsets is not valid",O);return}G.forEach((_t,wt)=>{const[Ot,q]=_t;if(typeof Ot!="number"||typeof q!="number"){console.warn("[TableAnnotation] offset is not [number, number]",_t);return}V.forEach((d,u)=>{var P,j,U;let $;const s=d.tBodies&&d.tBodies.length>0?Array.from(d.tBodies[0].rows):[];if(s.length>0)$=s[Ot];else{const k=((j=(P=d.tHead)==null?void 0:P.rows)==null?void 0:j.length)||0;$=Array.from(d.rows)[Ot+k]}if(!$){console.warn("[TableAnnotation] row out of range",{row:Ot,tableIndex:u});return}const h=(U=$.cells)==null?void 0:U[q];if(!h){console.warn("[TableAnnotation] cell is undefined",{row:Ot,col:q,tableIndex:u});return}const C=O.color||"rgba(255, 229, 153, 0.5)",A=getComputedStyle(h).backgroundColor;h.getAttribute("data-table-annotated")==="1"&&(A===C||h.style.backgroundColor===C)||(h.style.setProperty("background",C,"important"),h.style.setProperty("background-color",C,"important"),h.setAttribute("data-table-annotated","1")),O.content&&(h.title=O.content),wt===0&&z===0&&setTimeout(()=>{h.scrollIntoView({behavior:"smooth",block:"start"})},300)})})}),requestAnimationFrame(()=>{F.current=!1})},[I]),bt=useCallback(()=>{if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8 ==="),!t.current||!N.length){console.log("\u6761\u4EF6\u4E0D\u6EE1\u8DB3\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}r.current&&clearTimeout(r.current);const V=()=>{var O;console.log("\u5F00\u59CB\u5E94\u7528\u6807\u6CE8...");const z=(O=t.current)==null?void 0:O.querySelectorAll(".md-annotation");console.log("\u79FB\u9664\u73B0\u6709\u6807\u6CE8\u6570\u91CF:",(z==null?void 0:z.length)||0),z==null||z.forEach(u=>{const P=u.parentNode;P&&P.replaceChild(document.createTextNode(u.textContent||""),u)});const G=document.createTreeWalker(t.current,NodeFilter.SHOW_TEXT,{acceptNode:u=>{var P;return(P=u.parentElement)!=null&&P.closest("pre")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),_t=[];let wt;for(;wt=G.nextNode();)_t.push(wt);if(console.log("\u627E\u5230\u6587\u672C\u8282\u70B9\u6570\u91CF:",_t.length),_t.length===0){console.log("\u6CA1\u6709\u627E\u5230\u6587\u672C\u8282\u70B9\uFF0C\u5EF6\u8FDF\u91CD\u8BD5..."),r.current=setTimeout(()=>{V()},200);return}let Ot=0;const q=_t.map(u=>{var P;const j=Ot;return Ot+=((P=u.textContent)==null?void 0:P.length)||0,{node:u,start:j,end:Ot,text:u.textContent}});console.log("\u6587\u672C\u8282\u70B9\u4F4D\u7F6E:",q),console.log("\u603B\u6587\u672C\u957F\u5EA6:",Ot);const d=[...N].sort((u,P)=>P.start-u.start);console.log("\u6392\u5E8F\u540E\u7684\u6807\u6CE8:",d),d.forEach(u=>{const{start:P,end:j,color:U}=u;console.log("\u5904\u7406\u6807\u6CE8:",{annotation:u,nodePositions:q});const $=q.filter(s=>P<s.end&&j>s.start);console.log("\u76F8\u5173\u8282\u70B9\u6570\u91CF:",$.length),$.forEach(({node:s,start:h})=>{var C,A,k,B,D,g;const L=Math.max(0,P-h),At=Math.min(((C=s.textContent)==null?void 0:C.length)||0,j-h);if(console.log("\u672C\u5730\u4F4D\u7F6E:",{localStart:L,localEnd:At,nodeTextLength:(A=s.textContent)==null?void 0:A.length}),L>=At){console.log("\u672C\u5730\u4F4D\u7F6E\u65E0\u6548\uFF0C\u8DF3\u8FC7");return}const H=((k=s.textContent)==null?void 0:k.slice(0,L))||"",Q=((B=s.textContent)==null?void 0:B.slice(L,At))||"",vt=((D=s.textContent)==null?void 0:D.slice(At))||"";console.log("\u5206\u5272\u6587\u672C:",{before:H,annotatedText:Q,after:vt});const Tt=document.createElement("span");Tt.className="md-annotation",Tt.style.backgroundColor=U||"#FFE599",Tt.textContent=Q;const It=document.createDocumentFragment();H&&It.appendChild(document.createTextNode(H)),It.appendChild(Tt),vt&&It.appendChild(document.createTextNode(vt)),(g=s.parentNode)==null||g.replaceChild(It,s),console.log("\u6210\u529F\u5E94\u7528\u6807\u6CE8:",Q)})})};r.current=setTimeout(()=>{V()},100)},[N]);return useEffect(()=>{var V;if(y){console.log("[MarkdownContentView] table mode: skip effect, wait for onRendered");return}const O=typeof p.content=="string"?p.content:((V=p.content)==null?void 0:V.content)||"";if(!O||typeof O!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u6807\u6CE8\u5E94\u7528");return}if(console.log("=== \u5F00\u59CB\u5E94\u7528Markdown\u6807\u6CE8\u9AD8\u4EAE ==="),console.log("markdownRef.current:",t.current),console.log("isTableMode:",y),console.log("mdAnnotations:",N),console.log("tableAnnotations:",I),console.log("data.content:",p.content),console.log("\u5B9E\u9645\u5185\u5BB9:",O),!t.current){console.log("markdownRef\u4E0D\u5B58\u5728\uFF0C\u9000\u51FA\u6807\u6CE8\u5E94\u7528");return}if(y||St(),!y&&N.length>0){bt();return}console.log("\u6CA1\u6709\u9700\u8981\u5E94\u7528\u7684\u6807\u6CE8")},[y,I,N]),useEffect(()=>{if(!y)return document.addEventListener("mouseup",x),()=>{document.removeEventListener("mouseup",x)}},[x,y]),useEffect(()=>{var V;const O=typeof p.content=="string"?p.content:((V=p.content)==null?void 0:V.content)||"";if(!O||typeof O!="string"){console.log("Markdown\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8C03\u8BD5\u4FE1\u606F\u6253\u5370");return}console.log("=== Markdown\u5185\u5BB9\u4FE1\u606F ==="),console.log("isTableMode:",y),console.log("\u5185\u5BB9\u957F\u5EA6:",O.length||0),typeof O=="string"?(console.log("\u5185\u5BB9\u524D100\u5B57\u7B26:",O.substring(0,100)),console.log("\u5185\u5BB9\u540E100\u5B57\u7B26:",O.substring(O.length-100))):(console.log("\u5185\u5BB9\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B:",typeof O),console.log("\u5185\u5BB9\u503C:",O)),console.log("\u6807\u6CE8\u6570\u636E:",N),console.log("\u8868\u683C\u6807\u6CE8\u6570\u636E:",I)},[N,I,y]),useEffect(()=>{if(y&&t.current){const V=setTimeout(()=>{var O;const z=(O=t.current)==null?void 0:O.querySelectorAll("table");z&&z.length>0&&(console.log("\u8C03\u6574\u8868\u683C\u5C3A\u5BF8\uFF0C\u627E\u5230\u8868\u683C\u6570\u91CF:",z.length),z.forEach((G,_t)=>{if(G instanceof HTMLTableElement){G.style.width="100%",G.style.minWidth="100%",G.style.tableLayout="auto";const wt=G.closest(".markdown-table-mode");wt&&wt instanceof HTMLElement&&(wt.style.width="100%",wt.style.overflowX="auto"),console.log(`\u8868\u683C ${_t+1} \u5C3A\u5BF8\u8C03\u6574\u5B8C\u6210`)}}))},500);return()=>clearTimeout(V)}},[y,p.content]),useEffect(()=>()=>{r.current&&clearTimeout(r.current),a.current&&(a.current.disconnect(),a.current=null)},[]),c__default.createElement("div",{style:{height:"100%",width:"100%",overflow:"auto"},className:`markdown-container markdown-scrollbar ${y?"markdown-table-mode":""}`},c__default.createElement("style",null,Se),c__default.createElement("div",{ref:t},c__default.createElement(AL,{dataSource:{type:Sc.MARKDOWN,content:(()=>{var V,O;return typeof p.content=="string"?p.content:(V=p.content)!=null&&V.text?p.content.text:(O=p.content)!=null&&O.content?p.content.content:""})()},size:"md",onScroll:y?void 0:l,onScrollToTop:y?void 0:n,onScrollToBottom:y?void 0:i,onRendered:E,theme:{primaryColor:((Y=(_=(f=o.styles)==null?void 0:f.theme)==null?void 0:_.colors)==null?void 0:Y.primary)||"#007bff",backgroundColor:((M=(K=(W=o.styles)==null?void 0:W.theme)==null?void 0:K.colors)==null?void 0:M.background)||"#f8f9fa",textColor:((T=(w=(b=o.styles)==null?void 0:b.theme)==null?void 0:w.colors)==null?void 0:T.text)||"#343a40",borderColor:((c=(v=(S=o.styles)==null?void 0:S.theme)==null?void 0:v.colors)==null?void 0:c.border)||"#dee2e6",borderRadius:y?"0px":"8px",padding:y?"0px":"20px"},style:{height:"100%",border:"none",background:"transparent",overflowY:y?"visible":"scroll"}})))},Ze=({markdown:p,onRendered:o,tableAnnotations:y=[]})=>{const f=useRef(null),_=W=>{const K=W.split(/\r?\n/).filter(S=>S.trim().length>0);let M=-1;for(let S=0;S<K.length-1;S++){const v=K[S].trim(),c=K[S+1].trim();if(v.startsWith("|")&&v.endsWith("|")&&c.replace(/\s|:|\|/g,"").match(/^[-]+$/)){M=S;break}}if(M===-1)return null;const b=K[M].split("|").slice(1,-1).map(S=>S.trim()),w=[];for(let S=M+2;S<K.length;S++){const v=K[S].trim();if(!v.startsWith("|")||!v.endsWith("|"))break;w.push(v)}const T=w.map(S=>S.split("|").slice(1,-1).map(v=>v.trim()));return{headers:b,rows:T}},Y=c__default.useMemo(()=>_(p),[p]);return useEffect(()=>{const W=()=>{try{if(!f.current||!y.length)return;const M=f.current.querySelectorAll("table");if(!M||M.length===0)return;y.forEach((b,w)=>{(b.offsets||[]).forEach((T,S)=>{const[v,c]=T;M.forEach(t=>{var r,a,F;const m=t.tBodies&&t.tBodies.length>0?Array.from(t.tBodies[0].rows):[];let l;if(m.length>0)l=m[v];else{const e=((a=(r=t.tHead)==null?void 0:r.rows)==null?void 0:a.length)||0;l=Array.from(t.rows)[v+e]}if(!l)return;const n=(F=l.cells)==null?void 0:F[c];if(!n)return;const i=b.color||"rgba(255, 229, 153, 0.5)";n.getAttribute("data-table-annotated")==="1"||(n.style.setProperty("background",i,"important"),n.style.setProperty("background-color",i,"important"),n.setAttribute("data-table-annotated","1"),b.content&&(n.title=b.content)),w===0&&S===0&&setTimeout(()=>n.scrollIntoView({behavior:"smooth",block:"start"}),50)})})})}catch(M){console.warn("[MinimalMarkdownTable] apply annotations failed",M)}},K=requestAnimationFrame(()=>{W(),o&&o()});return()=>cancelAnimationFrame(K)},[p,y,o]),Y?c__default.createElement("div",{ref:f,className:"markdown-table-mode z-mdtbl-wrapper"},c__default.createElement("style",null,`
|
|
171
171
|
.z-mdtbl-wrapper { overflow: auto; position: relative; }
|
|
172
172
|
.z-mdtbl { border-collapse: separate; border-spacing: 0; background: transparent; box-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06); border-radius: 8px; }
|
|
173
173
|
.z-mdtbl th, .z-mdtbl td { border: 1px solid #e5e7eb; padding: 10px 14px; font-size: 13px; line-height: 1.4; color: inherit; }
|
package/package.json
CHANGED
|
@@ -1,99 +1,100 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@gientech/modual",
|
|
3
|
-
"private": false,
|
|
4
|
-
"author": "hanfeng_Zhang",
|
|
5
|
-
"version": "1.
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"types": "dist/lib_enter.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/lib_enter.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"./chat": {
|
|
16
|
-
"types": "./dist/chat.d.ts",
|
|
17
|
-
"import": "./dist/chat.js",
|
|
18
|
-
"default": "./dist/chat.js"
|
|
19
|
-
},
|
|
20
|
-
"./database": {
|
|
21
|
-
"types": "./dist/database.d.ts",
|
|
22
|
-
"import": "./dist/database.js",
|
|
23
|
-
"default": "./dist/database.js"
|
|
24
|
-
},
|
|
25
|
-
"./databaseId": {
|
|
26
|
-
"types": "./dist/databaseId.d.ts",
|
|
27
|
-
"import": "./dist/databaseId.js",
|
|
28
|
-
"default": "./dist/databaseId.js"
|
|
29
|
-
},
|
|
30
|
-
"./sensitive": {
|
|
31
|
-
"types": "./dist/sensitive.d.ts",
|
|
32
|
-
"import": "./dist/sensitive.js",
|
|
33
|
-
"default": "./dist/sensitive.js"
|
|
34
|
-
},
|
|
35
|
-
"./streamFilesReader": {
|
|
36
|
-
"types": "./dist/streamFilesReader.d.ts",
|
|
37
|
-
"import": "./dist/streamFilesReader.js",
|
|
38
|
-
"default": "./dist/streamFilesReader.js"
|
|
39
|
-
},
|
|
40
|
-
"./style.css": "./dist/assets/style.css"
|
|
41
|
-
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"@mxmweb/
|
|
60
|
-
"@mxmweb/fviewer": "
|
|
61
|
-
"@mxmweb/
|
|
62
|
-
"@mxmweb/xviewer": "
|
|
63
|
-
"@mxmweb/zui": "
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"react": "
|
|
70
|
-
"react-
|
|
71
|
-
},
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
"src
|
|
92
|
-
"src
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@gientech/modual",
|
|
3
|
+
"private": false,
|
|
4
|
+
"author": "hanfeng_Zhang",
|
|
5
|
+
"version": "1.3.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/lib_enter.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/lib_enter.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./chat": {
|
|
16
|
+
"types": "./dist/chat.d.ts",
|
|
17
|
+
"import": "./dist/chat.js",
|
|
18
|
+
"default": "./dist/chat.js"
|
|
19
|
+
},
|
|
20
|
+
"./database": {
|
|
21
|
+
"types": "./dist/database.d.ts",
|
|
22
|
+
"import": "./dist/database.js",
|
|
23
|
+
"default": "./dist/database.js"
|
|
24
|
+
},
|
|
25
|
+
"./databaseId": {
|
|
26
|
+
"types": "./dist/databaseId.d.ts",
|
|
27
|
+
"import": "./dist/databaseId.js",
|
|
28
|
+
"default": "./dist/databaseId.js"
|
|
29
|
+
},
|
|
30
|
+
"./sensitive": {
|
|
31
|
+
"types": "./dist/sensitive.d.ts",
|
|
32
|
+
"import": "./dist/sensitive.js",
|
|
33
|
+
"default": "./dist/sensitive.js"
|
|
34
|
+
},
|
|
35
|
+
"./streamFilesReader": {
|
|
36
|
+
"types": "./dist/streamFilesReader.d.ts",
|
|
37
|
+
"import": "./dist/streamFilesReader.js",
|
|
38
|
+
"default": "./dist/streamFilesReader.js"
|
|
39
|
+
},
|
|
40
|
+
"./style.css": "./dist/assets/style.css"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@mxmweb/nodegraph": "^1.x.x",
|
|
44
|
+
"@mxmweb/aichat": "^1.7.x",
|
|
45
|
+
"@mxmweb/fviewer": "^1.2.x",
|
|
46
|
+
"@mxmweb/rtext": "^1.1.*",
|
|
47
|
+
"@mxmweb/xviewer": "^1.2.x",
|
|
48
|
+
"@mxmweb/zui": "^1.3.x",
|
|
49
|
+
"@mxmweb/zui-components": "*",
|
|
50
|
+
"@mxmweb/zui-elements": "*",
|
|
51
|
+
"@mxmweb/zui-icons": "*",
|
|
52
|
+
"@mxmweb/zui-layouts": "*",
|
|
53
|
+
"@mxmweb/zui-theme": "*",
|
|
54
|
+
"react": ">=18 <20",
|
|
55
|
+
"react-dom": ">=18 <20"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@mxmweb/nodegraph": "1.0.7",
|
|
59
|
+
"@mxmweb/rtext": "1.1.45",
|
|
60
|
+
"@mxmweb/fviewer": "1.2.2",
|
|
61
|
+
"@mxmweb/aichat": "1.8.0",
|
|
62
|
+
"@mxmweb/xviewer": "1.1.40",
|
|
63
|
+
"@mxmweb/zui": "1.3.7"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"antd": "^5.18.0",
|
|
67
|
+
"clipboard": "^2.0.11",
|
|
68
|
+
"react": "^18.3.1",
|
|
69
|
+
"react-dom": "^18.3.1",
|
|
70
|
+
"react-flip-toolkit": "^7.2.4"
|
|
71
|
+
},
|
|
72
|
+
"include": [
|
|
73
|
+
"src/application/**/*"
|
|
74
|
+
],
|
|
75
|
+
"exclude": [
|
|
76
|
+
"node_modules",
|
|
77
|
+
"src/main.tsx",
|
|
78
|
+
"src/Preview.tsx",
|
|
79
|
+
"type.d.ts",
|
|
80
|
+
"vite-env.d.ts"
|
|
81
|
+
],
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=16.0.0"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"dev": "vite",
|
|
87
|
+
"build": "vite build --mode production",
|
|
88
|
+
"build:docs": "node ../../scripts/generate-docs.js && vite build --mode production",
|
|
89
|
+
"preview": "vite preview",
|
|
90
|
+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
91
|
+
"lint:fix": "eslint src --ext ts,tsx --fix",
|
|
92
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,css,md}\"",
|
|
93
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,css,md}\"",
|
|
94
|
+
"release": "semantic-release",
|
|
95
|
+
"release:dry": "semantic-release --dry-run",
|
|
96
|
+
"dev:demo": "node scripts/dev-demo.js",
|
|
97
|
+
"build:demo": "node scripts/build-demo.js",
|
|
98
|
+
"preview:demo": "node scripts/preview-demo.js"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { rag_dev_server } from "../../../utils/testconfigs";
|
|
4
|
+
import {KnowledgeGraphPreview, registerPreviewViewer} from '@mxmweb/nodegraph';
|
|
5
|
+
registerPreviewViewer();
|
|
6
|
+
|
|
7
|
+
const DrawerGraphPreview = ({
|
|
8
|
+
curFileInfo,
|
|
9
|
+
onClose
|
|
10
|
+
}: {
|
|
11
|
+
curFileInfo: any;
|
|
12
|
+
onClose: any;
|
|
13
|
+
}) => {
|
|
14
|
+
const [config, setConfig] = useState({
|
|
15
|
+
title: '',
|
|
16
|
+
subtitle: '',
|
|
17
|
+
backgroundColor: '#f8f9fa',
|
|
18
|
+
showGrid: true,
|
|
19
|
+
showLegend: false,
|
|
20
|
+
showTooltip: true,
|
|
21
|
+
showFullscreen: false,
|
|
22
|
+
showMinimap: false,
|
|
23
|
+
});
|
|
24
|
+
const [graphList,setGraphList]=useState<any>({nodeList:[],edgeList:[]})
|
|
25
|
+
const getGraphData = async(curFileInfo:any)=>{
|
|
26
|
+
if(!curFileInfo?.id || !curFileInfo?.cyphers || !curFileInfo?.fetchUrl)return
|
|
27
|
+
try {
|
|
28
|
+
const {cyphers,fetchUrl,id} = curFileInfo || {}
|
|
29
|
+
const res = await axios.post(fetchUrl,{cyphers:[
|
|
30
|
+
"match (n:`疾病`)-[e]-(m) where id(n) == \"疾病上睑下垂\" return n,e,m;"
|
|
31
|
+
],ontologyId:id}, {
|
|
32
|
+
headers: { Authorization: rag_dev_server.token },
|
|
33
|
+
})
|
|
34
|
+
console.log('getGraphData res',res);
|
|
35
|
+
setGraphList(res?.data || {})
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.log('error',error);
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//const { getToken } = useAppPassport();
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
getGraphData(curFileInfo)
|
|
44
|
+
},[curFileInfo])
|
|
45
|
+
|
|
46
|
+
useEffect(()=>{
|
|
47
|
+
console.log('graphList',graphList);
|
|
48
|
+
|
|
49
|
+
},[graphList])
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
<div className="h-[52px] leading-[52px] font-bold text-[16px] px-[15px] overflow-hidden border-t-none border-l-none border-b-[1px] border-solid border-[rgb(222,226,230)]">
|
|
53
|
+
{curFileInfo?.name || '图谱预览'}
|
|
54
|
+
</div>
|
|
55
|
+
<div className="w-full h-[calc(100vh-52)]" style={{width: '100%',height:'calc(100vh - 52px)'}}>
|
|
56
|
+
<KnowledgeGraphPreview
|
|
57
|
+
data={graphList}
|
|
58
|
+
layout={{ type: 'force', linkDistance: 190 }}
|
|
59
|
+
title={config.title}
|
|
60
|
+
subtitle={config.subtitle}
|
|
61
|
+
backgroundColor={config.backgroundColor}
|
|
62
|
+
showGrid={config.showGrid}
|
|
63
|
+
showLegend={config.showLegend}
|
|
64
|
+
showTooltip={config.showTooltip}
|
|
65
|
+
showFullscreen={config.showFullscreen}
|
|
66
|
+
showMinimap={config.showMinimap}
|
|
67
|
+
customPlugins={{}}
|
|
68
|
+
onReady={(graph: any) => {
|
|
69
|
+
console.log('KnowledgeGraphPreview ready:', graph);
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default DrawerGraphPreview;
|
|
@@ -2,6 +2,8 @@ import { useState } from 'react';
|
|
|
2
2
|
import withGientechChatAdopter from '../../modules/chat';
|
|
3
3
|
import { Brain, Search } from 'lucide-react';
|
|
4
4
|
import { rag_dev_server } from '../../utils/testconfigs';
|
|
5
|
+
import { ConfigProvider, Drawer } from 'antd';
|
|
6
|
+
import DrawerGraphPreview from './components/DrawerGraphPreview';
|
|
5
7
|
const defaultToken =rag_dev_server.token;
|
|
6
8
|
const defaultUrl = rag_dev_server.url;
|
|
7
9
|
|
|
@@ -31,65 +33,69 @@ const GientechChat = withGientechChatAdopter();
|
|
|
31
33
|
export default function Preview() {
|
|
32
34
|
const [token] = useState(defaultToken);
|
|
33
35
|
const [url] = useState(defaultUrl);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
const [open, setOpen] = useState(false);
|
|
37
|
+
const [drawerType, setDrawerType] = useState<string>("graphPreview");
|
|
38
|
+
const [curFileInfo, setCurFileInfo] = useState<any>({
|
|
39
|
+
});
|
|
40
|
+
let parsedStyles = {
|
|
41
|
+
theme: {
|
|
42
|
+
colors: {
|
|
43
|
+
primary: '#4E6EF2',
|
|
44
|
+
secondary: '#6c757d',
|
|
45
|
+
success: '#008000',
|
|
46
|
+
warning: '#FFA500',
|
|
47
|
+
error: '#FF0000',
|
|
48
|
+
info: '#0000FF',
|
|
49
|
+
background: '#ffff',
|
|
50
|
+
text: '#000000',
|
|
51
|
+
border: '#dee2e6',
|
|
52
|
+
disabled: '#808080',
|
|
53
|
+
disabledBackground: '#F5F5F5',
|
|
54
|
+
disabledText: '#808080',
|
|
55
|
+
shadow: '#000000',
|
|
56
|
+
appBackground: '#fff',
|
|
57
|
+
listBackground: '#f9f9f9',
|
|
58
|
+
dashboardBackground: '#ffffff',
|
|
59
|
+
sidebarBg: 'transparent',
|
|
60
|
+
itemBg: 'transparent',
|
|
61
|
+
itemHoverBg: '#f0f4ff',
|
|
62
|
+
activeItemBg: 'linear-gradient(#E3ECFF, #EEEBFF)',
|
|
63
|
+
activeItemText: '#1D2129',
|
|
64
|
+
itemText: '#333',
|
|
65
|
+
groupBg: 'transparent',
|
|
66
|
+
groupText: '#333',
|
|
67
|
+
groupBorder: '#dee2e6',
|
|
68
|
+
},
|
|
69
|
+
space: {
|
|
70
|
+
sidebar: 'md',
|
|
71
|
+
size: 'md',
|
|
72
|
+
radius: 'md',
|
|
73
|
+
padding: 'md',
|
|
74
|
+
margin: 'md',
|
|
75
|
+
shadow: 'md',
|
|
76
|
+
lineHeight: 'md',
|
|
77
|
+
},
|
|
78
|
+
icons: {
|
|
79
|
+
aiAvatar: '/icons/sheets.png',
|
|
80
|
+
userAvatar:
|
|
81
|
+
'http://10.15.12.13:9000/dev-rag-data/header_pic/JIABINBIN00/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20231212161213.jpg',
|
|
82
|
+
pdf: '/icons/pdf.png',
|
|
83
|
+
word: '/icons/docx-file.png',
|
|
84
|
+
image: '/icons/image.png',
|
|
85
|
+
video: '/icons/video.png',
|
|
86
|
+
audio: '/icons/audio.png',
|
|
87
|
+
excel: '/icons/sheets.png',
|
|
88
|
+
ppt: '/icons/pptx.png',
|
|
89
|
+
docx: '/icons/docx-file.png',
|
|
90
|
+
sheets: '/icons/sheets.png',
|
|
91
|
+
pptx: '/icons/pptx.png',
|
|
92
|
+
txt: '/icons/txt.png',
|
|
93
|
+
},
|
|
94
|
+
others: {
|
|
95
|
+
baseFontWeight: 'normal',
|
|
96
|
+
},
|
|
62
97
|
},
|
|
63
|
-
|
|
64
|
-
sidebar: 'md',
|
|
65
|
-
size: 'md',
|
|
66
|
-
radius: 'md',
|
|
67
|
-
padding: 'md',
|
|
68
|
-
margin: 'md',
|
|
69
|
-
shadow: 'md',
|
|
70
|
-
lineHeight: 'md',
|
|
71
|
-
},
|
|
72
|
-
icons: {
|
|
73
|
-
aiAvatar: '/icons/sheets.png',
|
|
74
|
-
userAvatar:
|
|
75
|
-
'http://10.15.12.13:9000/dev-rag-data/header_pic/JIABINBIN00/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20231212161213.jpg',
|
|
76
|
-
pdf: '/icons/pdf.png',
|
|
77
|
-
word: '/icons/docx-file.png',
|
|
78
|
-
image: '/icons/image.png',
|
|
79
|
-
video: '/icons/video.png',
|
|
80
|
-
audio: '/icons/audio.png',
|
|
81
|
-
excel: '/icons/sheets.png',
|
|
82
|
-
ppt: '/icons/pptx.png',
|
|
83
|
-
docx: '/icons/docx-file.png',
|
|
84
|
-
sheets: '/icons/sheets.png',
|
|
85
|
-
pptx: '/icons/pptx.png',
|
|
86
|
-
txt: '/icons/txt.png',
|
|
87
|
-
},
|
|
88
|
-
others: {
|
|
89
|
-
baseFontWeight: 'normal',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
98
|
+
};
|
|
93
99
|
return (
|
|
94
100
|
<div className="w-screen h-screen relative">
|
|
95
101
|
<GientechChat
|
|
@@ -103,38 +109,71 @@ let parsedStyles = {
|
|
|
103
109
|
styles={parsedStyles}
|
|
104
110
|
eventsEmit={(eventName, data) => {
|
|
105
111
|
console.log('eventName', eventName, 'data', data);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
switch (eventName) {
|
|
113
|
+
case 'graph_reference:click':
|
|
114
|
+
if(!data)return
|
|
115
|
+
|
|
116
|
+
setCurFileInfo(data);
|
|
117
|
+
setOpen(true);
|
|
118
|
+
break
|
|
119
|
+
case 'conversations:delete_icon_clicked':
|
|
120
|
+
const label = data.data?.label || '未命名会话';
|
|
121
|
+
if (window.confirm(`确定要删除会话「${label}」吗?删除后无法恢复。`)) {
|
|
122
|
+
data
|
|
123
|
+
.async_deleteConversation()
|
|
124
|
+
.then(() => {
|
|
125
|
+
data.fn_removeItemFromList();
|
|
126
|
+
})
|
|
127
|
+
.catch(() => {
|
|
128
|
+
// 删除失败
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
break
|
|
132
|
+
case 'conversations:rename_icon_clicked':
|
|
133
|
+
const oldLabel = data.data?.label || '未命名会话';
|
|
134
|
+
const newLabel = window.prompt(`请输入新的会话名称(原名:${oldLabel}):`, oldLabel);
|
|
135
|
+
if (newLabel && newLabel !== oldLabel) {
|
|
136
|
+
data
|
|
137
|
+
.async_renameConversation(newLabel)
|
|
138
|
+
.then(() => {
|
|
139
|
+
data.fn_renameItemInList(newLabel);
|
|
140
|
+
})
|
|
141
|
+
.catch(() => {
|
|
142
|
+
// 重命名失败
|
|
143
|
+
});
|
|
144
|
+
}
|
|
119
145
|
}
|
|
120
|
-
if (eventName === 'conversations:rename_icon_clicked') {
|
|
121
|
-
const oldLabel = data.data?.label || '未命名会话';
|
|
122
|
-
const newLabel = window.prompt(`请输入新的会话名称(原名:${oldLabel}):`, oldLabel);
|
|
123
|
-
if (newLabel && newLabel !== oldLabel) {
|
|
124
|
-
data
|
|
125
|
-
.async_renameConversation(newLabel)
|
|
126
|
-
.then(() => {
|
|
127
|
-
data.fn_renameItemInList(newLabel);
|
|
128
|
-
})
|
|
129
|
-
.catch(() => {
|
|
130
|
-
// 重命名失败
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
console.log('eventName', eventName, 'data', data);
|
|
136
146
|
}}
|
|
137
147
|
/>
|
|
148
|
+
<ConfigProvider
|
|
149
|
+
drawer={{
|
|
150
|
+
styles: {
|
|
151
|
+
body: { padding: 0 },
|
|
152
|
+
header: { display: "none" }
|
|
153
|
+
}
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<Drawer
|
|
157
|
+
autoFocus={false}
|
|
158
|
+
onClose={() => setOpen(false)}
|
|
159
|
+
open={open}
|
|
160
|
+
width={600}
|
|
161
|
+
className="overflow-x-hidden"
|
|
162
|
+
destroyOnClose
|
|
163
|
+
afterOpenChange={(open) => {
|
|
164
|
+
if (!open) {
|
|
165
|
+
setCurFileInfo(null);
|
|
166
|
+
}
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
{drawerType === "graphPreview" && (
|
|
170
|
+
<DrawerGraphPreview
|
|
171
|
+
curFileInfo={curFileInfo as any}
|
|
172
|
+
onClose={() => setOpen(false)}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
175
|
+
</Drawer>
|
|
176
|
+
</ConfigProvider>
|
|
138
177
|
</div>
|
|
139
178
|
);
|
|
140
179
|
}
|