merge editor plugin

pull/1/head
yann300 5 years ago
parent c64a11caf8
commit 1119c5bb59
  1. 2
      src/app.js
  2. 17
      src/app/editor/SourceHighlighters.js
  3. 23
      src/app/editor/editor.js
  4. 1
      src/app/tabs/test-tab.js

@ -247,7 +247,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
appManager.register([
contentImport,
themeModule,
editor.sourceHighlighters,
editor,
fileManager,
compilerMetadataGenerator,
compilersArtefacts,

@ -4,26 +4,16 @@ const SourceHighlighter = require('./sourceHighlighter')
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../package.json'
const profile = {
displayName: 'Editor',
name: 'editor',
description: 'service - highlight source code',
version: packageJson.version,
methods: ['highlight', 'discardHighlight']
}
// EditorApi:
// - methods: ['highlight', 'discardHighlight'],
class SourceHighlighters extends Plugin {
class SourceHighlighters {
constructor () {
super(profile)
this.highlighters = {}
}
highlight (position, filePath, hexColor) {
const { from } = this.currentRequest
highlight (position, filePath, hexColor, from) {
try {
if (!this.highlighters[from]) this.highlighters[from] = new SourceHighlighter()
this.highlighters[from].currentSourceLocation(null)
@ -33,8 +23,7 @@ class SourceHighlighters extends Plugin {
}
}
discardHighlight () {
const { from } = this.currentRequest
discardHighlight (from) {
if (this.highlighters[from]) this.highlighters[from].currentSourceLocation(null)
}
}

@ -3,6 +3,8 @@ const EventManager = require('../../lib/events')
const yo = require('yo-yo')
const csjs = require('csjs-inject')
const ace = require('brace')
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../package.json'
const globalRegistry = require('../../global/registry')
const SourceHighlighters = require('./SourceHighlighters')
@ -37,9 +39,18 @@ document.head.appendChild(yo`
</style>
`)
class Editor {
const profile = {
displayName: 'Editor',
name: 'editor',
description: 'service - editor',
version: packageJson.version,
methods: ['highlight', 'discardHighlight', 'clearAnnotations', 'addAnnotation']
}
class Editor extends Plugin {
constructor (opts = {}, themeModule) {
super(profile)
// Dependancies
this._components = {}
this._components.registry = globalRegistry
@ -177,6 +188,16 @@ class Editor {
})
}
highlight (position, filePath, hexColor) {
const { from } = this.currentRequest
this.sourceHighlighters.highlight(position, filePath, hexColor, from)
}
discardHighlight () {
const { from } = this.currentRequest
this.sourceHighlighters.discardHighlight(from)
}
setTheme (type) {
this.editor.setTheme('ace/theme/' + this._themes[type])
}

@ -178,6 +178,7 @@ module.exports = class TestTab extends ViewPlugin {
}
runTests () {
this.call('editor', 'clearAnnotations')
this.testsOutput.innerHTML = ''
this.testsSummary.innerHTML = ''
var tests = this.data.selectedTests

Loading…
Cancel
Save