allow one highlighter per plugin

pull/1/head
yann300 6 years ago
parent fdb869e12f
commit d3e112ed77
  1. 9
      src/app/plugin/pluginAPI.js
  2. 2
      src/app/plugin/pluginManager.js

@ -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]
}

Loading…
Cancel
Save