Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47300c1

Browse files
author
FalkWolsky
committed
Secure JSON Stringify for Component Data in State Display
1 parent4e5e0b1 commit47300c1

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

‎client/packages/lowcoder/src/i18n/locales/en.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ export const en = {
105105
"toolbarPreload":"Scripts and Styles",
106106
"components":"Active Components",
107107
"modals":"in-App Modals",
108-
"expandTip":"Click toExpand {component}'s Data",
109-
"collapseTip":"Click toCollapse {component}'s Data",
108+
"expandTip":"Click toShow {component}'s Data",
109+
"collapseTip":"Click toHide {component}'s Data",
110110
"layers":"Layers",
111111
"activatelayers":"Use dynamic Layers",
112112
"selectedComponents":"Selected Components...",

‎client/packages/lowcoder/src/pages/editor/LeftContent.tsx‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { CollapseWrapper, DirectoryTreeStyle, Node } from "./styledComponents";
3333
import{DataNode,EventDataNode}from"antd/es/tree";
3434
import{isAggregationApp}from"util/appUtils";
3535
importModalfrom"antd/es/modal/Modal";
36-
importcopyToClipboardfrom"copy-to-clipboard";
3736

3837
constCollapseTitleWrapper=styled.div`
3938
display: flex;
@@ -69,8 +68,22 @@ function getLen(config: string | boolean | number) {
6968
return0;
7069
}
7170

71+
functionsafeStringify(obj:any,space=2){
72+
constcache=newSet();
73+
returnJSON.stringify(obj,(key,value)=>{
74+
if(typeofvalue==='object'&&value!==null){
75+
if(cache.has(value)){
76+
return'[Circular]';
77+
}
78+
cache.add(value);
79+
}
80+
returnvalue;
81+
},space);
82+
}
83+
84+
7285
functiontoDataView(value:any,name:string,desc?:ReactNode,modal?:boolean){
73-
conststr=typeofvalue==="function" ?"Function" :safeJSONStringify(value);
86+
conststr=typeofvalue==="function" ?"Function" :safeStringify(value);
7487
constdescRecord:Record<string,ReactNode>={};
7588
constshortenedString=modal===true ?(getLen(str)>42 ?str.slice(0,42)+"..." :str) :(getLen(str)>20 ?str.slice(0,20)+"..." :str);
7689
descRecord[name]=desc;
@@ -205,7 +218,7 @@ const CollapseView = React.memo(
205218
</CollapseTitleWrapper>
206219
</Tooltip>
207220
{Object.keys(data).length>0&&
208-
<CopyTextButtontext={JSON.stringify(data)}style={{color:"#aaa",marginRight:"8px"}}/>
221+
<CopyTextButtontext={safeStringify(data)}style={{color:"#aaa",marginRight:"8px"}}/>
209222
}
210223
</div>
211224
),
@@ -440,7 +453,7 @@ export const LeftContent = (props: LeftContentProps) => {
440453
maskClosable={true}// Prevent closing on background click
441454
>
442455
<div
443-
style={{whiteSpace:'pre-wrap',wordWrap:'break-word',maxHeight:"calc(100vh - 400px)",overflow:"scroll"}}
456+
style={{whiteSpace:'nowrap',wordWrap:'normal',maxHeight:"calc(100vh - 400px)",overflow:"scroll"}}
444457
onClick={(e)=>e.stopPropagation()}// Prevent closing on clicking inside the modal
445458
>
446459
{prepareData(data.data,data.dataDesc)}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp