allow running script from the file explorer

pull/5370/head
yann300 4 years ago
parent c6f4562f72
commit 796a5bf18c
  1. 10
      apps/remix-ide/src/app/files/file-explorer.js
  2. 2
      apps/remix-ide/src/app/panels/file-panel.js

@ -16,7 +16,7 @@ const globalRegistry = require('../../global/registry')
const queryParams = new QueryParams()
let MENU_HANDLE
function fileExplorer (localRegistry, files, menuItems) {
function fileExplorer (localRegistry, files, menuItems, plugin) {
var self = this
this.events = new EventManager()
// file provider backend
@ -292,6 +292,14 @@ function fileExplorer (localRegistry, files, menuItems) {
() => {}
)
}
if (key.endsWith('.js')) {
actions['Run Script'] = async () => {
provider.get(key, (error, content) => {
if (error) return console.log(error)
plugin.call('scriptRunner', 'execute', content)
})
}
}
}
MENU_HANDLE = contextMenu(event, actions)
})

@ -54,7 +54,7 @@ module.exports = class Filepanel extends ViewPlugin {
}
function createProvider (key, menuItems) {
return new FileExplorer(self._components.registry, self._deps.fileProviders[key], menuItems)
return new FileExplorer(self._components.registry, self._deps.fileProviders[key], menuItems, self)
}
var fileExplorer = createProvider('browser', ['createNewFile', 'publishToGist', canUpload ? 'uploadFile' : ''])

Loading…
Cancel
Save