Unverified Commit a73e2c4c authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1555 from ethereum/APIImprovement

Plugin API improvement
parents 0f99a72f fb403049
......@@ -83,7 +83,7 @@ module.exports = class RighthandPanel {
})
var tab = new PluginTab(json)
var content = tab.render()
document.querySelector('body').appendChild(modal.render(json.title, content))
document.querySelector('body').appendChild(modal.render(json.title, json.url, content))
self._components.pluginManager.register(json, modal, content)
}
......
......@@ -5,7 +5,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter')
Defines available API. `key` / `type`
*/
module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => {
var highlighter = new SourceHighlighter()
let highlighters = {}
return {
app: {
getExecutionContextProvider: (mod, cb) => {
......@@ -136,12 +136,13 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
} catch (e) {
return cb(e.message)
}
highlighter.currentSourceLocation(null)
highlighter.currentSourceLocationFromfileName(position, filePath, hexColor)
if (!highlighters[mod]) highlighters[mod] = new SourceHighlighter()
highlighters[mod].currentSourceLocation(null)
highlighters[mod].currentSourceLocationFromfileName(position, filePath, hexColor)
cb()
},
discardHighlight: (mod, cb) => {
highlighter.currentSourceLocation(null)
if (highlighters[mod]) highlighters[mod].currentSourceLocation(null)
cb()
}
}
......
......@@ -90,6 +90,7 @@ module.exports = class PluginManager {
compiler,
udapp
)
self._components = { pluginAPI }
self.plugins = {}
self.origins = {}
self.inFocus
......@@ -181,6 +182,7 @@ module.exports = class PluginManager {
}
unregister (desc) {
const self = this
self._components.pluginAPI.editor.discardHighlight(desc.title, () => {})
delete self.plugins[desc.title]
delete self.origins[desc.url]
}
......
......@@ -136,14 +136,15 @@ module.exports = class SettingsTab {
function loadPlugins (plugins, opt) {
for (var k in plugins) {
var plugin = plugins[k]
if (!self._view.plugins[plugin.title]) self._view.plugins[plugin.title] = {}
self._view.plugins[plugin.title].json = plugin
self._view.plugins[plugin.title].el = yo`<div title=${plugin.title} class="${css.pluginLoad}">
<div class="${css.aPlugin}" onclick=${() => { onLoadPlugin(plugin.title) }}>${plugin.title}</div>
${opt.removable ? yo`<span class="${css.removePlugin}" onclick=${() => { onRemovePlugin(plugin.title) }}><i class="fa fa-close"></i></span>` : yo`<span></span>`}
</div>`
self._view.config.plugins.appendChild(self._view.plugins[plugin.title].el)
(function (plugin) {
if (!self._view.plugins[plugin.title]) self._view.plugins[plugin.title] = {}
self._view.plugins[plugin.title].json = plugin
self._view.plugins[plugin.title].el = yo`<div title=${plugin.title} class="${css.pluginLoad}">
<div class="${css.aPlugin}" onclick=${() => { onLoadPlugin(plugin.title) }}>${plugin.title}</div>
${opt.removable ? yo`<span class="${css.removePlugin}" onclick=${() => { onRemovePlugin(plugin.title) }}><i class="fa fa-close"></i></span>` : yo`<span></span>`}
</div>`
self._view.config.plugins.appendChild(self._view.plugins[plugin.title].el)
})(plugins[k])
}
}
......
......@@ -43,12 +43,12 @@ module.exports =
this.closeCb = closeCb
}
render (title, content) {
render (title, url, content) {
this.content = content
var el = yo`
<div class=${css.containerDraggableModal}>
<div>
<div class="${css.headerDraggableModal} title" title=${title}><span>${title}</span>
<div class="${css.headerDraggableModal} title" title=${title}><span title="${title}" >${title}</span><span title="${url}" > - ${url}</span>
<div class=${css.modalActions}>
<i onclick=${() => { this.minimize() }} class="fa fa-window-minimize ${css.modalAction}"></i>
<i onclick=${() => { this.maximise() }} class="fa fa-window-maximize ${css.modalAction}"></i>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment