|
|
@ -152,16 +152,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| _ < | |___ | | | | | | / \\ | | | |_| | | |___ |
|
|
|
\t\t\t\t\t\t\t| _ < | |___ | | | | | | / \\ | | | |_| | | |___ |
|
|
|
\t\t\t\t\t\t\t|_| \\_\\ |_____| |_| |_| |___| /_/\\_\\ |___| |____/ |_____|\n\n |
|
|
|
\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${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 + 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 + 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 + 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\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${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\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${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.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\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\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\tGitter: https://gitter.im/ethereum/remix\n
|
|
|
|
\t\t\t\t\t\t\t\tMedium: https://medium.com/remix-ide\n
|
|
|
|
\t\t\t\t\t\t\t\tMedium: https://medium.com/remix-ide\n
|
|
|
@ -472,7 +472,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
|
|
|
|
|
|
|
|
const addDecoration = (decoration: sourceAnnotation | sourceMarker, filePath: string, typeOfDecoration: string) => { |
|
|
|
const addDecoration = (decoration: sourceAnnotation | sourceMarker, filePath: string, typeOfDecoration: string) => { |
|
|
|
const model = editorModelsState[filePath]?.model |
|
|
|
const model = editorModelsState[filePath]?.model |
|
|
|
if (!model) return { currentDecorations: [] } |
|
|
|
if (!model) return { currentDecorations: []} |
|
|
|
const monacoDecoration = convertToMonacoDecoration(decoration, typeOfDecoration) |
|
|
|
const monacoDecoration = convertToMonacoDecoration(decoration, typeOfDecoration) |
|
|
|
return { |
|
|
|
return { |
|
|
|
currentDecorations: model.deltaDecorations([], [monacoDecoration]), |
|
|
|
currentDecorations: model.deltaDecorations([], [monacoDecoration]), |
|
|
@ -629,7 +629,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) { |
|
|
|
if (!pasteCodeRef.current && e && e.range && e.range.startLineNumber >= 0 && e.range.endLineNumber >= 0 && e.range.endLineNumber - e.range.startLineNumber > 10) { |
|
|
|
const modalContent: AlertModal = { |
|
|
|
const modalContent: AlertModal = { |
|
|
|
id: 'newCodePasted', |
|
|
|
id: 'newCodePasted', |
|
|
|
title: intl.formatMessage({id: 'editor.title1'}), |
|
|
|
title: intl.formatMessage({ id: 'editor.title1' }), |
|
|
|
message: ( |
|
|
|
message: ( |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
{' '} |
|
|
|
{' '} |
|
|
@ -638,7 +638,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<FormattedMessage id="editor.title1.message2" /> |
|
|
|
<FormattedMessage id="editor.title1.message2" /> |
|
|
|
<div className="mt-2"> |
|
|
|
<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> |
|
|
|
<div className="text-warning mt-2"> |
|
|
|
<div className="text-warning mt-2"> |
|
|
|
<FormattedMessage id="editor.title1.message4" /> |
|
|
|
<FormattedMessage id="editor.title1.message4" /> |
|
|
@ -670,7 +670,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
// add context menu items
|
|
|
|
// add context menu items
|
|
|
|
const zoominAction = { |
|
|
|
const zoominAction = { |
|
|
|
id: 'zoomIn', |
|
|
|
id: 'zoomIn', |
|
|
|
label: intl.formatMessage({id: 'editor.zoomIn'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.zoomIn' }), |
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuGroupId: 'zooming', // create a new grouping
|
|
|
|
contextMenuGroupId: 'zooming', // create a new grouping
|
|
|
|
keybindings: [ |
|
|
|
keybindings: [ |
|
|
@ -683,7 +683,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
const zoomOutAction = { |
|
|
|
const zoomOutAction = { |
|
|
|
id: 'zoomOut', |
|
|
|
id: 'zoomOut', |
|
|
|
label: intl.formatMessage({id: 'editor.zoomOut'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.zoomOut' }), |
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuGroupId: 'zooming', // create a new grouping
|
|
|
|
contextMenuGroupId: 'zooming', // create a new grouping
|
|
|
|
keybindings: [ |
|
|
|
keybindings: [ |
|
|
@ -696,7 +696,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
const formatAction = { |
|
|
|
const formatAction = { |
|
|
|
id: 'autoFormat', |
|
|
|
id: 'autoFormat', |
|
|
|
label: intl.formatMessage({id: 'editor.formatCode'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.formatCode' }), |
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuGroupId: 'formatting', // create a new grouping
|
|
|
|
contextMenuGroupId: 'formatting', // create a new grouping
|
|
|
|
keybindings: [ |
|
|
|
keybindings: [ |
|
|
@ -712,14 +712,14 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
let gptGenerateDocumentationAction |
|
|
|
let gptGenerateDocumentationAction |
|
|
|
const executeGptGenerateDocumentationAction = { |
|
|
|
const executeGptGenerateDocumentationAction = { |
|
|
|
id: 'generateDocumentation', |
|
|
|
id: 'generateDocumentation', |
|
|
|
label: intl.formatMessage({id: 'editor.generateDocumentation'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.generateDocumentation' }), |
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuGroupId: 'gtp', // create a new grouping
|
|
|
|
contextMenuGroupId: 'gtp', // create a new grouping
|
|
|
|
keybindings: [], |
|
|
|
keybindings: [], |
|
|
|
run: async () => { |
|
|
|
run: async () => { |
|
|
|
const file = await props.plugin.call('fileManager', 'getCurrentFile') |
|
|
|
const file = await props.plugin.call('fileManager', 'getCurrentFile') |
|
|
|
const content = await props.plugin.call('fileManager', 'readFile', file) |
|
|
|
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) |
|
|
|
await props.plugin.call('openaigpt', 'message', message) |
|
|
|
_paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation']) |
|
|
|
_paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation']) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -728,14 +728,14 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
let gptExplainFunctionAction |
|
|
|
let gptExplainFunctionAction |
|
|
|
const executegptExplainFunctionAction = { |
|
|
|
const executegptExplainFunctionAction = { |
|
|
|
id: 'explainFunction', |
|
|
|
id: 'explainFunction', |
|
|
|
label: intl.formatMessage({id: 'editor.explainFunction'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.explainFunction' }), |
|
|
|
contextMenuOrder: 1, // choose the order
|
|
|
|
contextMenuOrder: 1, // choose the order
|
|
|
|
contextMenuGroupId: 'gtp', // create a new grouping
|
|
|
|
contextMenuGroupId: 'gtp', // create a new grouping
|
|
|
|
keybindings: [], |
|
|
|
keybindings: [], |
|
|
|
run: async () => { |
|
|
|
run: async () => { |
|
|
|
const file = await props.plugin.call('fileManager', 'getCurrentFile') |
|
|
|
const file = await props.plugin.call('fileManager', 'getCurrentFile') |
|
|
|
const content = await props.plugin.call('fileManager', 'readFile', file) |
|
|
|
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) |
|
|
|
await props.plugin.call('openaigpt', 'message', message) |
|
|
|
_paq.push(['trackEvent', 'ai', 'openai', 'explainFunction']) |
|
|
|
_paq.push(['trackEvent', 'ai', 'openai', 'explainFunction']) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -744,7 +744,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
let solgptExplainFunctionAction |
|
|
|
let solgptExplainFunctionAction |
|
|
|
const executeSolgptExplainFunctionAction = { |
|
|
|
const executeSolgptExplainFunctionAction = { |
|
|
|
id: 'solExplainFunction', |
|
|
|
id: 'solExplainFunction', |
|
|
|
label: intl.formatMessage({id: 'editor.explainFunctionSol'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.explainFunctionSol' }), |
|
|
|
contextMenuOrder: 1, // choose the order
|
|
|
|
contextMenuOrder: 1, // choose the order
|
|
|
|
contextMenuGroupId: 'sol-gtp', // create a new grouping
|
|
|
|
contextMenuGroupId: 'sol-gtp', // create a new grouping
|
|
|
|
keybindings: [], |
|
|
|
keybindings: [], |
|
|
@ -758,12 +758,11 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const freeFunctionCondition = editor.createContextKey('freeFunctionCondition', false) |
|
|
|
const freeFunctionCondition = editor.createContextKey('freeFunctionCondition', false) |
|
|
|
let freeFunctionAction |
|
|
|
let freeFunctionAction |
|
|
|
const executeFreeFunctionAction = { |
|
|
|
const executeFreeFunctionAction = { |
|
|
|
id: 'executeFreeFunction', |
|
|
|
id: 'executeFreeFunction', |
|
|
|
label: intl.formatMessage({id: 'editor.executeFreeFunction'}), |
|
|
|
label: intl.formatMessage({ id: 'editor.executeFreeFunction' }), |
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuOrder: 0, // choose the order
|
|
|
|
contextMenuGroupId: 'execute', // create a new grouping
|
|
|
|
contextMenuGroupId: 'execute', // create a new grouping
|
|
|
|
precondition: 'freeFunctionCondition', |
|
|
|
precondition: 'freeFunctionCondition', |
|
|
@ -780,10 +779,10 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
const file = await props.plugin.call('fileManager', 'getCurrentFile') |
|
|
|
const file = await props.plugin.call('fileManager', 'getCurrentFile') |
|
|
|
props.plugin.call('solidity-script', 'execute', file, freeFunctionNode.name) |
|
|
|
props.plugin.call('solidity-script', 'execute', file, freeFunctionNode.name) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
props.plugin.call('notification', 'toast', intl.formatMessage({id: 'editor.toastText1'})) |
|
|
|
props.plugin.call('notification', 'toast', intl.formatMessage({ id: 'editor.toastText1' })) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
props.plugin.call('notification', 'toast', intl.formatMessage({id: 'editor.toastText2'})) |
|
|
|
props.plugin.call('notification', 'toast', intl.formatMessage({ id: 'editor.toastText2' })) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
@ -824,27 +823,26 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { nodesAtPosition } = await retrieveNodesAtPosition(props.editorAPI, props.plugin) |
|
|
|
const { nodesAtPosition } = await retrieveNodesAtPosition(props.editorAPI, props.plugin) |
|
|
|
const freeFunctionNode = nodesAtPosition.find((node) => node.kind === 'freeFunction') |
|
|
|
const freeFunctionNode = nodesAtPosition.find((node) => node.kind === 'freeFunction') |
|
|
|
if (freeFunctionNode) { |
|
|
|
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) |
|
|
|
freeFunctionAction = editor.addAction(executeFreeFunctionAction) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const functionImpl = nodesAtPosition.find((node) => node.kind === 'function') |
|
|
|
const functionImpl = nodesAtPosition.find((node) => node.kind === 'function') |
|
|
|
if (functionImpl) { |
|
|
|
if (functionImpl) { |
|
|
|
currentFunction.current = functionImpl.name |
|
|
|
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) |
|
|
|
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) |
|
|
|
gptExplainFunctionAction = editor.addAction(executegptExplainFunctionAction) |
|
|
|
executeSolgptExplainFunctionAction.label = intl.formatMessage({id: 'editor.explainFunctionSol'}) |
|
|
|
executeSolgptExplainFunctionAction.label = intl.formatMessage({ id: 'editor.explainFunctionSol' }) |
|
|
|
solgptExplainFunctionAction = editor.addAction(executeSolgptExplainFunctionAction) |
|
|
|
solgptExplainFunctionAction = editor.addAction(executeSolgptExplainFunctionAction) |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// do not allow single character explaining
|
|
|
|
// do not allow single character explaining
|
|
|
|
if (editor.getModel().getValueInRange(editor.getSelection()).length <=1){ return} |
|
|
|
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) |
|
|
|
solgptExplainFunctionAction = editor.addAction(executeSolgptExplainFunctionAction) |
|
|
|
} |
|
|
|
} |
|
|
|
freeFunctionCondition.set(!!freeFunctionNode) |
|
|
|
freeFunctionCondition.set(!!freeFunctionNode) |
|
|
@ -892,7 +890,7 @@ export const EditorUI = (props: EditorUIProps) => { |
|
|
|
monacoRef.current.languages.register({ id: 'remix-circom' }) |
|
|
|
monacoRef.current.languages.register({ id: 'remix-circom' }) |
|
|
|
|
|
|
|
|
|
|
|
// Allow JSON schema requests
|
|
|
|
// 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
|
|
|
|
// Register a tokens provider for the language
|
|
|
|
monacoRef.current.languages.setMonarchTokensProvider('remix-solidity', solidityTokensProvider as any) |
|
|
|
monacoRef.current.languages.setMonarchTokensProvider('remix-solidity', solidityTokensProvider as any) |
|
|
|