Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
vicotor
frontend
Commits
1a9582c0
Commit
1a9582c0
authored
Jun 16, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change editor language for vyper contracts
parent
a7264aeb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
monaco.ts
lib/csp/policies/monaco.ts
+1
-0
ContractSourceCode.tsx
ui/address/contract/ContractSourceCode.tsx
+10
-2
CodeEditor.tsx
ui/shared/monaco/CodeEditor.tsx
+7
-4
No files found.
lib/csp/policies/monaco.ts
View file @
1a9582c0
...
...
@@ -10,6 +10,7 @@ export function monaco(): CspDev.DirectiveDescriptor {
'
https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs/editor/editor.main.js
'
,
'
https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs/editor/editor.main.nls.js
'
,
'
https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs/basic-languages/solidity/solidity.js
'
,
'
https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs/basic-languages/elixir/elixir.js
'
,
'
https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs/base/worker/workerMain.js
'
,
],
'
style-src
'
:
[
...
...
ui/address/contract/ContractSourceCode.tsx
View file @
1a9582c0
...
...
@@ -142,11 +142,19 @@ const ContractSourceCode = ({ address, implementationAddress }: Props) => {
return
(
<>
<
Box
display=
{
sourceType
===
'
primary
'
?
'
block
'
:
'
none
'
}
>
<
CodeEditor
data=
{
primaryEditorData
}
remappings=
{
primaryContractQuery
.
data
?.
compiler_settings
?.
remappings
}
/>
<
CodeEditor
data=
{
primaryEditorData
}
remappings=
{
primaryContractQuery
.
data
?.
compiler_settings
?.
remappings
}
language=
{
primaryContractQuery
.
data
?.
language
??
undefined
}
/>
</
Box
>
{
secondaryEditorData
&&
(
<
Box
display=
{
sourceType
===
'
secondary
'
?
'
block
'
:
'
none
'
}
>
<
CodeEditor
data=
{
secondaryEditorData
}
remappings=
{
secondaryContractQuery
.
data
?.
compiler_settings
?.
remappings
}
/>
<
CodeEditor
data=
{
secondaryEditorData
}
remappings=
{
secondaryContractQuery
.
data
?.
compiler_settings
?.
remappings
}
language=
{
secondaryContractQuery
.
data
?.
language
??
undefined
}
/>
</
Box
>
)
}
</>
...
...
ui/shared/monaco/CodeEditor.tsx
View file @
1a9582c0
...
...
@@ -36,9 +36,10 @@ const EDITOR_HEIGHT = 500;
interface
Props
{
data
:
Array
<
File
>
;
remappings
?:
Array
<
string
>
;
language
?:
string
;
}
const
CodeEditor
=
({
data
,
remappings
}:
Props
)
=>
{
const
CodeEditor
=
({
data
,
remappings
,
language
}:
Props
)
=>
{
const
[
instance
,
setInstance
]
=
React
.
useState
<
Monaco
|
undefined
>
();
const
[
editor
,
setEditor
]
=
React
.
useState
<
monaco
.
editor
.
IStandaloneCodeEditor
|
undefined
>
();
const
[
index
,
setIndex
]
=
React
.
useState
(
0
);
...
...
@@ -53,6 +54,8 @@ const CodeEditor = ({ data, remappings }: Props) => {
const
editorWidth
=
containerRect
?
containerRect
.
width
-
(
isMobile
?
0
:
SIDE_BAR_WIDTH
)
:
0
;
const
editorLanguage
=
language
===
'
vyper
'
?
'
elixir
'
:
'
sol
'
;
React
.
useEffect
(()
=>
{
instance
?.
editor
.
setTheme
(
colorMode
===
'
light
'
?
'
blockscout-light
'
:
'
blockscout-dark
'
);
},
[
colorMode
,
instance
?.
editor
]);
...
...
@@ -69,7 +72,7 @@ const CodeEditor = ({ data, remappings }: Props) => {
const
loadedModelsPaths
=
loadedModels
.
map
((
model
)
=>
model
.
uri
.
path
);
const
newModels
=
data
.
slice
(
1
)
.
filter
((
file
)
=>
!
loadedModelsPaths
.
includes
(
file
.
file_path
))
.
map
((
file
)
=>
monaco
.
editor
.
createModel
(
file
.
source_code
,
'
sol
'
,
monaco
.
Uri
.
parse
(
file
.
file_path
)));
.
map
((
file
)
=>
monaco
.
editor
.
createModel
(
file
.
source_code
,
editorLanguage
,
monaco
.
Uri
.
parse
(
file
.
file_path
)));
loadedModels
.
concat
(
newModels
).
forEach
(
addFileImportDecorations
);
...
...
@@ -185,7 +188,7 @@ const CodeEditor = ({ data, remappings }: Props) => {
return
(
<
Box
overflow=
"hidden"
borderRadius=
"md"
height=
{
`${ EDITOR_HEIGHT }px`
}
>
<
MonacoEditor
language=
"sol"
language=
{
editorLanguage
}
path=
{
data
[
index
].
file_path
}
defaultValue=
{
data
[
index
].
source_code
}
options=
{
EDITOR_OPTIONS
}
...
...
@@ -216,7 +219,7 @@ const CodeEditor = ({ data, remappings }: Props) => {
<
MonacoEditor
className=
"editor-container"
height=
{
`${ EDITOR_HEIGHT }px`
}
language=
"sol"
language=
{
editorLanguage
}
path=
{
data
[
index
].
file_path
}
defaultValue=
{
data
[
index
].
source_code
}
options=
{
EDITOR_OPTIONS
}
...
...
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