add editor getCurrent, get, set

pull/3094/head
yann300 6 years ago
parent 6df9e6a3b1
commit c450e4dbf3
  1. 2
      src/app/panels/righthand-panel.js
  2. 32
      src/app/plugin/pluginAPI.js
  3. 3
      src/app/plugin/pluginManager.js

@ -36,6 +36,7 @@ module.exports = class RighthandPanel {
self._deps = {
fileProviders: self._components.registry.get('fileproviders').api,
fileManager: self._components.registry.get('fileManager').api,
compiler: self._components.registry.get('compiler').api,
udapp: self._components.registry.get('udapp').api,
app: self._components.registry.get('app').api,
@ -49,6 +50,7 @@ module.exports = class RighthandPanel {
self._deps.compiler,
self._deps.txlistener,
self._deps.fileProviders,
self._deps.fileManager,
self._deps.udapp
)

@ -4,7 +4,7 @@ var executionContext = require('../../execution-context')
/*
Defines available API. `key` / `type`
*/
module.exports = (pluginManager, fileProviders, compiler, udapp) => {
module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => {
return {
app: {
getExecutionContextProvider: (mod, cb) => {
@ -63,6 +63,36 @@ module.exports = (pluginManager, fileProviders, compiler, udapp) => {
cb(error, address)
})
}
},
editor: {
getCurrentFile: (mod, cb) => {
var path = fileManager.currentPath()
if (!path) {
cb('no file selected')
} else {
this.getFile(mod, path, cb)
}
},
getFile: (mod, path, cb) => {
var provider = fileManager.fileProviderOf(path)
if (provider) {
provider.get(mod + '/' + path, (error, content) => {
cb(error, content)
})
} else {
cb(path + 'not available')
}
},
setFile: (mod, path, content, cb) => {
var provider = fileManager.fileProviderOf(path)
if (provider) {
provider.set(mod + '/' + path, content, (error) => {
cb(error)
})
} else {
cb(path + 'not available')
}
}
}
}
}

@ -78,11 +78,12 @@ const PluginAPI = require('./pluginAPI')
*
*/
module.exports = class PluginManager {
constructor (app, compiler, txlistener, fileProviders, udapp) {
constructor (app, compiler, txlistener, fileProviders, fileManager, udapp) {
const self = this
var pluginAPI = new PluginAPI(
this,
fileProviders,
fileManager,
compiler,
udapp
)

Loading…
Cancel
Save