diff --git a/package.json b/package.json index 90e937e818..570831afab 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "remix-lib": "0.4.1", "remix-plugin": "latest", "remix-solidity": "0.3.1", + "remix-tabs": "^1.0.0", "remix-tests": "0.1.1", "remixd": "0.1.8-alpha.6", "request": "^2.83.0", diff --git a/src/app/panels/tab-proxy.js b/src/app/panels/tab-proxy.js index fdcb1eb0fd..dad1234045 100644 --- a/src/app/panels/tab-proxy.js +++ b/src/app/panels/tab-proxy.js @@ -2,6 +2,8 @@ var yo = require('yo-yo') var $ = require('jquery') const EventEmitter = require('events') +require('remix-tabs') + var styles = require('./styles/editor-panel-styles') var css = styles.css @@ -11,7 +13,6 @@ export class TabProxy { this.fileManager = fileManager this.appManager = appManager this.editor = editor - this.activeEntity this.entities = {} this.data = {} this._view = {} @@ -26,27 +27,26 @@ export class TabProxy { }) fileManager.event.register('currentFileChanged', (file) => { - const filesEl = document.querySelector('#files') - if (!filesEl.querySelector(`li[path="${file}"]`)) { - this.addTab(file, () => { - this.fileManager.switchFile(file) - this.event.emit('switchFile', file) - }, - () => { - this.fileManager.closeFile(file) - this.event.emit('closeFile', file) - }) - } - this.active(file) // this put the css class "active" + this.addTab(file, () => { + this.fileManager.switchFile(file) + this.event.emit('switchFile', file) + }, + () => { + this.fileManager.closeFile(file) + this.event.emit('closeFile', file) + }) }) fileManager.event.register('fileRenamed', (oldName, newName) => { - const filesEl = document.querySelector('#files') - var file = filesEl.querySelector(`li[path="${oldName}"]`) - if (file) { - filesEl.setAttribute('path', file) - file.querySelector(`.name`).innerHTML = newName - } + this.removeTab(oldName) + this.addTab(newName, () => { + this.fileManager.switchFile(newName) + this.event.emit('switchFile', newName) + }, + () => { + this.fileManager.closeFile(newName) + this.event.emit('closeFile', newName) + }) }) appStore.event.on('activate', (name) => { @@ -67,31 +67,20 @@ export class TabProxy { } addTab (name, switchTo, close, kind) { - const filesEl = document.querySelector('#files') - filesEl.appendChild(yo`