@ -156,16 +156,16 @@ export const EditorUI = (props: EditorUIProps) => {
\ t \ t \ t \ t \ t \ t \ t | | _ ) | | _ | | | \ \ / | | | | \ \ / | | | | | | | _ |
\ t \ t \ t \ t \ t \ t \ t | _ < | | ___ | | | | | | / \ \ | | | | _ | | | | _ _ _
\ t \ t \ t \ t \ t \ t \ t | _ | \ \ _ \ \ | _____ | | _ | | _ | | ___ | /_/ \ \ _ \ \ | ___ | | ____ / | _____ | \ n \ n
\ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts' } ) } : \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + S : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text1' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + Shift + F : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text2' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + Shift + A : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text3' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + SHIFT + S : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text4' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.editorKeyboardShortcuts' } ) } : \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + Alt + F : $ { intl . formatMessage ( { id : 'editor.editorKeyboardShortcuts.text1' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.importantLinks' } ) } : \ n
\ t \ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.importantLinks.text1' } ) } : https : //remix-project.org/\n
\ t \ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.importantLinks.text2' } ) } : https : //remix-ide.readthedocs.io/en/latest/\n
\ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts' } ) } : \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + S : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text1' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + Shift + F : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text2' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + Shift + A : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text3' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + SHIFT + S : $ { intl . formatMessage ( { id : 'editor.keyboardShortcuts.text4' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.editorKeyboardShortcuts' } ) } : \ n
\ t \ t \ t \ t \ t \ t \ t \ tCTRL + Alt + F : $ { intl . formatMessage ( { id : 'editor.editorKeyboardShortcuts.text1' } ) } \ n
\ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.importantLinks' } ) } : \ n
\ t \ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.importantLinks.text1' } ) } : https : //remix-project.org/\n
\ t \ t \ t \ t \ t \ t \ t \ t $ { intl . formatMessage ( { id : 'editor.importantLinks.text2' } ) } : https : //remix-ide.readthedocs.io/en/latest/\n
\ t \ t \ t \ t \ t \ t \ t \ tGithub : https : //github.com/ethereum/remix-project\n
\ t \ t \ t \ t \ t \ t \ t \ tGitter : https : //gitter.im/ethereum/remix\n
\ t \ t \ t \ t \ t \ t \ t \ tMedium : https : //medium.com/remix-ide\n
@ -487,7 +487,7 @@ export const EditorUI = (props: EditorUIProps) => {
const addDecoration = ( decoration : sourceAnnotation | sourceMarker , filePath : string , typeOfDecoration : string ) = > {
const model = editorModelsState [ filePath ] ? . model
if ( ! model ) return { currentDecorations : [ ] }
if ( ! model ) return { currentDecorations : [ ] }
const monacoDecoration = convertToMonacoDecoration ( decoration , typeOfDecoration )
return {
currentDecorations : model.deltaDecorations ( [ ] , [ monacoDecoration ] ) ,
@ -652,7 +652,7 @@ export const EditorUI = (props: EditorUIProps) => {
if ( ! pasteCodeRef . current && e && e . range && e . range . startLineNumber >= 0 && e . range . endLineNumber >= 0 && e . range . endLineNumber - e . range . startLineNumber > 10 ) {
const modalContent : AlertModal = {
id : 'newCodePasted' ,
title : intl.formatMessage ( { id : 'editor.title1' } ) ,
title : intl.formatMessage ( { id : 'editor.title1' } ) ,
message : (
< div >
{ ' ' }
@ -661,7 +661,7 @@ export const EditorUI = (props: EditorUIProps) => {
< div >
< FormattedMessage id = "editor.title1.message2" / >
< div className = "mt-2" >
< FormattedMessage id = "editor.title1.message3" values = { { span : ( chunks ) = > < span className = "text-warning" > { chunks } < / span > } } / >
< FormattedMessage id = "editor.title1.message3" values = { { span : ( chunks ) = > < span className = "text-warning" > { chunks } < / span > } } / >
< / div >
< div className = "text-warning mt-2" >
< FormattedMessage id = "editor.title1.message4" / >
@ -693,7 +693,7 @@ export const EditorUI = (props: EditorUIProps) => {
// add context menu items
const zoominAction = {
id : 'zoomIn' ,
label : intl.formatMessage ( { id : 'editor.zoomIn' } ) ,
label : intl.formatMessage ( { id : 'editor.zoomIn' } ) ,
contextMenuOrder : 0 , // choose the order
contextMenuGroupId : 'zooming' , // create a new grouping
keybindings : [
@ -706,7 +706,7 @@ export const EditorUI = (props: EditorUIProps) => {
}
const zoomOutAction = {
id : 'zoomOut' ,
label : intl.formatMessage ( { id : 'editor.zoomOut' } ) ,
label : intl.formatMessage ( { id : 'editor.zoomOut' } ) ,
contextMenuOrder : 0 , // choose the order
contextMenuGroupId : 'zooming' , // create a new grouping
keybindings : [
@ -719,7 +719,7 @@ export const EditorUI = (props: EditorUIProps) => {
}
const formatAction = {
id : 'autoFormat' ,
label : intl.formatMessage ( { id : 'editor.formatCode' } ) ,
label : intl.formatMessage ( { id : 'editor.formatCode' } ) ,
contextMenuOrder : 0 , // choose the order
contextMenuGroupId : 'formatting' , // create a new grouping
keybindings : [
@ -735,14 +735,14 @@ export const EditorUI = (props: EditorUIProps) => {
let gptGenerateDocumentationAction
const executeGptGenerateDocumentationAction = {
id : 'generateDocumentation' ,
label : intl.formatMessage ( { id : 'editor.generateDocumentation' } ) ,
label : intl.formatMessage ( { id : 'editor.generateDocumentation' } ) ,
contextMenuOrder : 0 , // choose the order
contextMenuGroupId : 'gtp' , // create a new grouping
keybindings : [ ] ,
run : async ( ) = > {
const file = await props . plugin . call ( 'fileManager' , 'getCurrentFile' )
const content = await props . plugin . call ( 'fileManager' , 'readFile' , file )
const message = intl . formatMessage ( { id : 'editor.generateDocumentationByAI' } , { content , currentFunction : currentFunction.current } )
const message = intl . formatMessage ( { id : 'editor.generateDocumentationByAI' } , { content , currentFunction : currentFunction.current } )
await props . plugin . call ( 'openaigpt' , 'message' , message )
_paq . push ( [ 'trackEvent' , 'ai' , 'openai' , 'generateDocumentation' ] )
} ,
@ -751,14 +751,14 @@ export const EditorUI = (props: EditorUIProps) => {
let gptExplainFunctionAction
const executegptExplainFunctionAction = {
id : 'explainFunction' ,
label : intl.formatMessage ( { id : 'editor.explainFunction' } ) ,
label : intl.formatMessage ( { id : 'editor.explainFunction' } ) ,
contextMenuOrder : 1 , // choose the order
contextMenuGroupId : 'gtp' , // create a new grouping
keybindings : [ ] ,
run : async ( ) = > {
const file = await props . plugin . call ( 'fileManager' , 'getCurrentFile' )
const content = await props . plugin . call ( 'fileManager' , 'readFile' , file )
const message = intl . formatMessage ( { id : 'editor.explainFunctionByAI' } , { content , currentFunction : currentFunction.current } )
const message = intl . formatMessage ( { id : 'editor.explainFunctionByAI' } , { content , currentFunction : currentFunction.current } )
await props . plugin . call ( 'openaigpt' , 'message' , message )
_paq . push ( [ 'trackEvent' , 'ai' , 'openai' , 'explainFunction' ] )
} ,
@ -767,7 +767,7 @@ export const EditorUI = (props: EditorUIProps) => {
let solgptExplainFunctionAction
const executeSolgptExplainFunctionAction = {
id : 'solExplainFunction' ,
label : intl.formatMessage ( { id : 'editor.explainFunctionSol' } ) ,
label : intl.formatMessage ( { id : 'editor.explainFunctionSol' } ) ,
contextMenuOrder : 1 , // choose the order
contextMenuGroupId : 'sol-gtp' , // create a new grouping
keybindings : [ ] ,
@ -781,12 +781,11 @@ export const EditorUI = (props: EditorUIProps) => {
} ,
}
const freeFunctionCondition = editor . createContextKey ( 'freeFunctionCondition' , false )
let freeFunctionAction
const executeFreeFunctionAction = {
id : 'executeFreeFunction' ,
label : intl.formatMessage ( { id : 'editor.executeFreeFunction' } ) ,
label : intl.formatMessage ( { id : 'editor.executeFreeFunction' } ) ,
contextMenuOrder : 0 , // choose the order
contextMenuGroupId : 'execute' , // create a new grouping
precondition : 'freeFunctionCondition' ,
@ -803,10 +802,10 @@ export const EditorUI = (props: EditorUIProps) => {
const file = await props . plugin . call ( 'fileManager' , 'getCurrentFile' )
props . plugin . call ( 'solidity-script' , 'execute' , file , freeFunctionNode . name )
} else {
props . plugin . call ( 'notification' , 'toast' , intl . formatMessage ( { id : 'editor.toastText1' } ) )
props . plugin . call ( 'notification' , 'toast' , intl . formatMessage ( { id : 'editor.toastText1' } ) )
}
} else {
props . plugin . call ( 'notification' , 'toast' , intl . formatMessage ( { id : 'editor.toastText2' } ) )
props . plugin . call ( 'notification' , 'toast' , intl . formatMessage ( { id : 'editor.toastText2' } ) )
}
} ,
}
@ -847,27 +846,26 @@ export const EditorUI = (props: EditorUIProps) => {
return
}
const { nodesAtPosition } = await retrieveNodesAtPosition ( props . editorAPI , props . plugin )
const freeFunctionNode = nodesAtPosition . find ( ( node ) = > node . kind === 'freeFunction' )
if ( freeFunctionNode ) {
executeFreeFunctionAction . label = intl . formatMessage ( { id : 'editor.executeFreeFunction2' } , { name : freeFunctionNode.name } )
executeFreeFunctionAction . label = intl . formatMessage ( { id : 'editor.executeFreeFunction2' } , { name : freeFunctionNode.name } )
freeFunctionAction = editor . addAction ( executeFreeFunctionAction )
}
const functionImpl = nodesAtPosition . find ( ( node ) = > node . kind === 'function' )
if ( functionImpl ) {
currentFunction . current = functionImpl . name
executeGptGenerateDocumentationAction . label = intl . formatMessage ( { id : 'editor.generateDocumentation2' } , { name : functionImpl.name } )
executeGptGenerateDocumentationAction . label = intl . formatMessage ( { id : 'editor.generateDocumentation2' } , { name : functionImpl.name } )
gptGenerateDocumentationAction = editor . addAction ( executeGptGenerateDocumentationAction )
executegptExplainFunctionAction . label = intl . formatMessage ( { id : 'editor.explainFunction2' } , { name : functionImpl.name } )
executegptExplainFunctionAction . label = intl . formatMessage ( { id : 'editor.explainFunction2' } , { name : functionImpl.name } )
gptExplainFunctionAction = editor . addAction ( executegptExplainFunctionAction )
executeSolgptExplainFunctionAction . label = intl . formatMessage ( { id : 'editor.explainFunctionSol' } )
executeSolgptExplainFunctionAction . label = intl . formatMessage ( { id : 'editor.explainFunctionSol' } )
solgptExplainFunctionAction = editor . addAction ( executeSolgptExplainFunctionAction )
} else {
} else {
// do not allow single character explaining
if ( editor . getModel ( ) . getValueInRange ( editor . getSelection ( ) ) . length <= 1 ) { return }
executeSolgptExplainFunctionAction . label = intl . formatMessage ( { id : 'editor.explainFunctionSol' } )
executeSolgptExplainFunctionAction . label = intl . formatMessage ( { id : 'editor.explainFunctionSol' } )
solgptExplainFunctionAction = editor . addAction ( executeSolgptExplainFunctionAction )
}
freeFunctionCondition . set ( ! ! freeFunctionNode )
@ -915,7 +913,7 @@ export const EditorUI = (props: EditorUIProps) => {
monacoRef . current . languages . register ( { id : 'remix-circom' } )
// Allow JSON schema requests
monacoRef . current . languages . json . jsonDefaults . setDiagnosticsOptions ( { enableSchemaRequest : true } )
monacoRef . current . languages . json . jsonDefaults . setDiagnosticsOptions ( { enableSchemaRequest : true } )
// Register a tokens provider for the language
monacoRef . current . languages . setMonarchTokensProvider ( 'remix-solidity' , solidityTokensProvider as any )