Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
9839b5cb
Commit
9839b5cb
authored
Mar 06, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: enchance code editor syle
parent
430569d4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
3 deletions
+49
-3
index.tsx
...kflow/nodes/_base/components/editor/code-editor/index.tsx
+39
-3
style.css
...kflow/nodes/_base/components/editor/code-editor/style.css
+3
-0
panel.tsx
web/app/components/workflow/nodes/code/panel.tsx
+1
-0
index.tsx
...onents/workflow/nodes/http/components/edit-body/index.tsx
+3
-0
panel.tsx
...pp/components/workflow/nodes/template-transform/panel.tsx
+3
-0
No files found.
web/app/components/workflow/nodes/_base/components/editor/code-editor.tsx
→
web/app/components/workflow/nodes/_base/components/editor/code-editor
/index
.tsx
View file @
9839b5cb
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
Editor
from
'@monaco-editor/react'
import
Editor
from
'@monaco-editor/react'
import
React
from
'react'
import
React
,
{
useRef
}
from
'react'
import
Base
from
'./base'
import
Base
from
'.
.
/base'
import
{
CodeLanguage
}
from
'@/app/components/workflow/nodes/code/types'
import
{
CodeLanguage
}
from
'@/app/components/workflow/nodes/code/types'
import
'./style.css'
type
Props
=
{
type
Props
=
{
value
:
string
value
:
string
...
@@ -11,6 +12,7 @@ type Props = {
...
@@ -11,6 +12,7 @@ type Props = {
title
:
JSX
.
Element
title
:
JSX
.
Element
language
:
CodeLanguage
language
:
CodeLanguage
headerRight
?:
JSX
.
Element
headerRight
?:
JSX
.
Element
readOnly
?:
boolean
}
}
const
CodeEditor
:
FC
<
Props
>
=
({
const
CodeEditor
:
FC
<
Props
>
=
({
...
@@ -19,12 +21,43 @@ const CodeEditor: FC<Props> = ({
...
@@ -19,12 +21,43 @@ const CodeEditor: FC<Props> = ({
title
,
title
,
headerRight
,
headerRight
,
language
,
language
,
readOnly
,
})
=>
{
})
=>
{
const
[
isFocus
,
setIsFocus
]
=
React
.
useState
(
false
)
const
[
isFocus
,
setIsFocus
]
=
React
.
useState
(
false
)
const
handleEditorChange
=
(
value
:
string
|
undefined
)
=>
{
const
handleEditorChange
=
(
value
:
string
|
undefined
)
=>
{
onChange
(
value
||
''
)
onChange
(
value
||
''
)
}
}
const
editorRef
=
useRef
(
null
)
const
handleEditorDidMount
=
(
editor
:
any
,
monaco
:
any
)
=>
{
editorRef
.
current
=
editor
editor
.
onDidFocusEditorText
(()
=>
{
setIsFocus
(
true
)
})
editor
.
onDidBlurEditorText
(()
=>
{
setIsFocus
(
false
)
})
monaco
.
editor
.
defineTheme
(
'blur-theme'
,
{
base
:
'vs'
,
inherit
:
true
,
rules
:
[],
colors
:
{
'editor.background'
:
'#F2F4F7'
,
},
})
monaco
.
editor
.
defineTheme
(
'focus-theme'
,
{
base
:
'vs'
,
inherit
:
true
,
rules
:
[],
colors
:
{
'editor.background'
:
'#ffffff'
,
},
})
}
return
(
return
(
<
div
>
<
div
>
<
Base
<
Base
...
@@ -38,18 +71,21 @@ const CodeEditor: FC<Props> = ({
...
@@ -38,18 +71,21 @@ const CodeEditor: FC<Props> = ({
<
Editor
<
Editor
className=
'h-full'
className=
'h-full'
defaultLanguage=
{
language
===
CodeLanguage
.
javascript
?
'javascript'
:
'python'
}
defaultLanguage=
{
language
===
CodeLanguage
.
javascript
?
'javascript'
:
'python'
}
theme=
{
isFocus
?
'focus-theme'
:
'blur-theme'
}
value=
{
value
}
value=
{
value
}
onChange=
{
handleEditorChange
}
onChange=
{
handleEditorChange
}
// https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html
// https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html
options=
{
{
options=
{
{
readOnly
,
quickSuggestions
:
false
,
quickSuggestions
:
false
,
minimap
:
{
enabled
:
false
},
minimap
:
{
enabled
:
false
},
lineNumbersMinChars
:
1
,
// would change line num width
// lineNumbers: (num) =>
{
// lineNumbers: (num) =>
{
// return <div>
{
num
}<
/
div
>
// return <div>
{
num
}<
/
div
>
// }
// }
}
}
}
}
onMount=
{
handleEditorDidMount
}
/>
/>
</
Base
>
</
Base
>
</
div
>
</
div
>
)
)
...
...
web/app/components/workflow/nodes/_base/components/editor/code-editor/style.css
0 → 100644
View file @
9839b5cb
.margin-view-overlays
{
padding-left
:
10px
;
}
\ No newline at end of file
web/app/components/workflow/nodes/code/panel.tsx
View file @
9839b5cb
...
@@ -59,6 +59,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
...
@@ -59,6 +59,7 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
<
Split
/>
<
Split
/>
{
inputs
.
code_language
}
{
inputs
.
code_language
}
<
CodeEditor
<
CodeEditor
readOnly=
{
readOnly
}
title=
{
title=
{
<
TypeSelector
<
TypeSelector
options=
{
codeLanguages
}
options=
{
codeLanguages
}
...
...
web/app/components/workflow/nodes/http/components/edit-body/index.tsx
View file @
9839b5cb
...
@@ -9,6 +9,7 @@ import useKeyValueList from '../../hooks/use-key-value-list'
...
@@ -9,6 +9,7 @@ import useKeyValueList from '../../hooks/use-key-value-list'
import
KeyValue
from
'../key-value'
import
KeyValue
from
'../key-value'
import
TextEditor
from
'../../../_base/components/editor/text-editor'
import
TextEditor
from
'../../../_base/components/editor/text-editor'
import
CodeEditor
from
'../../../_base/components/editor/code-editor'
import
CodeEditor
from
'../../../_base/components/editor/code-editor'
import
{
CodeLanguage
}
from
'../../../code/types'
type
Props
=
{
type
Props
=
{
readonly
:
boolean
readonly
:
boolean
...
@@ -123,8 +124,10 @@ const EditBody: FC<Props> = ({
...
@@ -123,8 +124,10 @@ const EditBody: FC<Props> = ({
{
type
===
BodyType
.
json
&&
(
{
type
===
BodyType
.
json
&&
(
<
CodeEditor
<
CodeEditor
readOnly=
{
readonly
}
title=
{
<
div
className=
'uppercase'
>
JSON
</
div
>
}
title=
{
<
div
className=
'uppercase'
>
JSON
</
div
>
}
value=
{
payload
.
data
}
onChange=
{
handleBodyValueChange
}
value=
{
payload
.
data
}
onChange=
{
handleBodyValueChange
}
language=
{
CodeLanguage
.
javascript
}
/>
/>
)
}
)
}
</
div
>
</
div
>
...
...
web/app/components/workflow/nodes/template-transform/panel.tsx
View file @
9839b5cb
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
from
'react'
import
React
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
CodeLanguage
}
from
'../code/types'
import
useConfig
from
'./use-config'
import
useConfig
from
'./use-config'
import
type
{
TemplateTransformNodeType
}
from
'./types'
import
type
{
TemplateTransformNodeType
}
from
'./types'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
...
@@ -46,6 +47,8 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
...
@@ -46,6 +47,8 @@ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
</
Field
>
</
Field
>
<
Split
/>
<
Split
/>
<
CodeEditor
<
CodeEditor
readOnly=
{
readOnly
}
language=
{
CodeLanguage
.
python3
}
title=
{
title=
{
<
div
className=
'uppercase'
>
{
t
(
`${i18nPrefix}.code`
)
}
</
div
>
<
div
className=
'uppercase'
>
{
t
(
`${i18nPrefix}.code`
)
}
</
div
>
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment