Commit f6644221 authored by gxkai's avatar gxkai

Merge branch '2.5.0_dev' into 2.5.0

parents d4465a73 645ea255
......@@ -167,6 +167,10 @@ export class TabProxy extends Plugin {
}
}
clearTab () {
this.tabsApi.activateTab('')
}
switchNextTab () {
const active = this.tabsApi.active()
if (active && this._handlers[active]) {
......@@ -270,8 +274,19 @@ export class TabProxy extends Plugin {
}
removeTab (name) {
delete this._handlers[name]
this.switchToActiveTab()
const i = this.loadedTabs.findIndex(tab => tab.name === name)
if (name === this.tabsApi.active()) {
if (i > 0) {
this.switchPreviousTab()
} else if (i === 0 && this.loadedTabs.length > 1) {
this.switchNextTab()
} else {
this.clearTab()
}
delete this._handlers[name]
} else {
this.switchToActiveTab()
}
this.loadedTabs = this.loadedTabs.filter(tab => tab.name !== name)
this.renderComponent()
this.updateImgStyles()
......@@ -294,6 +309,10 @@ export class TabProxy extends Plugin {
if (this.loadedTabs[index]) {
const name = this.loadedTabs[index].name
if (this._handlers[name]) this._handlers[name].close()
if (index - 1 >= 0) {
onSelect(index - 1)
return
}
this.event.emit('tabCountChanged', this.loadedTabs.length)
}
}
......@@ -302,7 +321,6 @@ export class TabProxy extends Plugin {
const onZoomOut = () => this.editor.editorFontSize(-1)
const onReady = (api) => { this.tabsApi = api }
ReactDOM.render(
<TabsUI tabs={this.loadedTabs} onSelect={onSelect} onClose={onClose} onZoomIn={onZoomIn} onZoomOut={onZoomOut} onReady={onReady} />
, this.el)
......
......@@ -294,7 +294,6 @@ export const createNewFolder = async (path: string, rootDir: string) => {
export const deletePath = async (path: string[]) => {
const fileManager = plugin.fileManager
for (const p of path) {
try {
await fileManager.remove(p)
......
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