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

Commit669b379

Browse files
author
FalkWolsky
committed
plugin creator fix dependencies
1 parent756b294 commit669b379

File tree

4 files changed

+47
-23
lines changed

4 files changed

+47
-23
lines changed

‎client/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"lint-staged":"^13.0.1",
5353
"lowcoder-dev-utils":"workspace:^",
5454
"mq-polyfill":"^1.1.8",
55-
"prettier":"3.1.0",
55+
"prettier":"^3.1.0",
5656
"rimraf":"^3.0.2",
5757
"rollup":"^2.79.0",
5858
"shelljs":"^0.8.5",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// Comments are supported, like tsconfig.json
3+
"entryPoints": ["src/index.ts"],
4+
"out":"docs"
5+
}

‎client/packages/lowcoder/src/base/codeEditor/autoFormat.tsx‎

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,36 @@ import { Language } from "./codeEditorTypes";
66

77
exportasyncfunctioncssFormatter(text:string){
88
constprettier=awaitimport("prettier/standalone");
9-
constparserPlugin=awaitimport("prettier/parser-postcss");
10-
returnprettier.format(text,{parser:"css",plugins:[parserPlugin],semi:false}).trim();
9+
constparserPlugin=awaitrequire("prettier/parser-postcss");
10+
return(awaitprettier.format(text,{parser:"css",plugins:[parserPlugin],semi:false})).trim();
1111
}
1212

1313
exportasyncfunctionhtmlFormatter(text:string){
1414
constprettier=awaitimport("prettier/standalone");
15-
constparserPlugin=awaitimport("prettier/parser-html");
16-
returnprettier.format(text,{parser:"html",plugins:[parserPlugin],semi:false}).trim();
15+
constparserPlugin=awaitrequire("prettier/parser-html");
16+
return(awaitprettier.format(text,{parser:"html",plugins:[parserPlugin],semi:false})).trim();
1717
}
1818

1919
asyncfunctiongetJavascriptFormatter(){
2020
constprettier=awaitimport("prettier/standalone");
21-
constparserBabel=awaitimport("prettier/parser-babel");
22-
return(text:string)=>
23-
prettier.format(text,{parser:"babel",plugins:[parserBabel],semi:false}).trim();
21+
constparserBabel=awaitrequire("prettier/parser-babel");
22+
returnasync(text:string)=>
23+
(awaitprettier.format(text,{parser:"babel",plugins:[parserBabel],semi:false})).trim();
2424
}
2525

2626
exportasyncfunctiongetJsonFormatter(){
2727
constprettier=awaitimport("prettier/standalone");
28-
constparserBabel=awaitimport("prettier/parser-babel");
29-
return(text:string)=>prettier.format(text,{parser:"json",plugins:[parserBabel]}).trim();
28+
constparserBabel=awaitrequire("prettier/parser-babel");
29+
returnasync(text:string)=>(awaitprettier.format(text,{parser:"json",plugins:[parserBabel]})).trim();
3030
}
3131

32-
functionformatJsSegment(formatter:(text:string)=>string,script:string){
32+
asyncfunctionformatJsSegment(formatter:(text:string)=>Promise<string>,script:string):Promise<string>{
3333
try{
34-
consts=formatter(script);
34+
consts=awaitformatter(script);
3535
returns.startsWith(";") ?s.slice(1) :s;
3636
}catch(e1){
3737
try{
38-
consts=formatter(`return (${script}\n);`);// same as evalScript()
38+
consts=awaitformatter(`return (${script}\n);`);// same as evalScript()
3939
returns.startsWith("return ") ?s.slice(7) :s;
4040
}catch(e2){
4141
throwe1;
@@ -45,7 +45,9 @@ function formatJsSegment(formatter: (text: string) => string, script: string) {
4545

4646
asyncfunctiongetJsSegmentFormatter(){
4747
constformatter=awaitgetJavascriptFormatter();
48-
return(segment:string)=>"{{"+formatJsSegment(formatter,segment.slice(2,-2))+"}}";
48+
returnasync(segment:string)=>{
49+
return"{{"+formatJsSegment(formatter,segment.slice(2,-2))+"}}";
50+
};
4951
}
5052

5153
exportasyncfunctionformatStringWithJsSnippets(text:string):Promise<string>{
@@ -75,15 +77,27 @@ export async function formatSqlWithJsSnippets(text: string) {
7577
if(jsSegments.length===0){
7678
returnnewText;
7779
}
78-
returnnewText.replace(/{{\d+}}/g,(s)=>{
80+
constreplacements:Promise<string>[]=[];
81+
constreplacedText=newText.replace(/{{\d+}}/g,(s)=>{
7982
constindex=parseInt(s.slice(4,-4));
8083
if(index>=0&&index<jsSegments.length){
81-
returnjsSegmentFormatter(jsSegments[index]);
84+
constreplacement=jsSegmentFormatter(jsSegments[index]);
85+
replacements.push(replacement);
86+
returns;// Return the original placeholder for now
8287
}
8388
returns;
8489
});
90+
91+
constformattedSegments=awaitPromise.all(replacements);
92+
letfinalText=replacedText;
93+
formattedSegments.forEach((formattedSegment,index)=>{
94+
finalText=finalText.replace(`{ {${index} } }`,formattedSegment);
95+
});
96+
97+
returnfinalText;
8598
}
8699

100+
87101
asyncfunctionformatJsonWithJsSnippetsImpl(text:string){
88102
if(!text||text.trim().length===0){
89103
return"";
@@ -108,15 +122,20 @@ async function formatJsonWithJsSnippetsImpl(text: string) {
108122
// here are 3 cases.
109123
// - when the original "{{}}" is not in quotes as the single key or value, the whole "{{ index }}" should be replaced.
110124
// - when the original "{{}}" is for concatenating strings, "{{ index }}" or "\\{\\{ index \\}\\}" should be replaced.
111-
returnformattedJSON.replace(/("{{\d+}}")|({{\d+}})|(\\\\{\\\\{\d+\\\\}\\\\})/g,(s)=>{
125+
constformattedSegments=awaitPromise.all(segments.map(async(segment)=>{
126+
if(isDynamicSegment(segment)){
127+
constformattedSegment=awaitjsSegmentFormatter(segment);
128+
returnformattedSegment;
129+
}
130+
returnsegment;
131+
}));
132+
133+
return(awaitformattedJSON).replace(/("{{\d+}}")|({{\d+}})|(\\\\{\\\\{\d+\\\\}\\\\})/g,(s)=>{
112134
constindex=parseInt(
113135
s.startsWith('"{{') ?s.slice(3,-3) :s.startsWith("{{") ?s.slice(2,-2) :s.slice(6,-6)
114136
);
115-
if(index>=0&&index<segments.length){
116-
constsegment=segments[index];
117-
if(isDynamicSegment(segment)){
118-
returnjsSegmentFormatter(segment);
119-
}
137+
if(index>=0&&index<formattedSegments.length){
138+
returnformattedSegments[index];
120139
}
121140
returns;
122141
});

‎client/packages/lowcoder/src/pages/tutorials/tutorialsConstant.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const editorContentClassName = "joyride-editor-content";
88
exportconsttableDataDivClassName="joyride-table-data-div";
99
exportconsteditorBottomClassName="joyride-editor-bottom";
1010

11-
exportconstdefaultJoyrideStyles:Styles={
11+
exportconstdefaultJoyrideStyles:Partial<Styles>={
1212
options:{
1313
arrowColor:"#4965F2",
1414
overlayColor:"rgba(0, 0, 0, 0.4)",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp