@@ -58,6 +58,8 @@ import {OscdPluginManager} from "./plugin-manager/plugin-manager.js";
58
58
import "./plugin-manager/plugin-manager.js" ;
59
59
import { OscdCustomPluginDialog } from "./plugin-manager/custom-plugin-dialog.js" ;
60
60
import "./plugin-manager/custom-plugin-dialog.js" ;
61
+ import "./menu-tabs/menu-tabs.js" ;
62
+ import { TabActivatedEvent } from "./menu-tabs/menu-tabs.js" ;
61
63
62
64
63
65
@customElement ( 'oscd-layout' )
@@ -82,6 +84,7 @@ export class OscdLayout extends LitElement {
82
84
83
85
@state ( ) validated : Promise < void > = Promise . resolve ( ) ;
84
86
@state ( ) shouldValidate = false ;
87
+ @state ( ) activeEditor : Plugin | undefined = this . calcActiveEditors ( ) [ 0 ] ;
85
88
86
89
@query ( '#menu' ) menuUI ! : Drawer ;
87
90
@query ( '#pluginManager' ) pluginUI ! : OscdPluginManager ;
@@ -462,17 +465,17 @@ export class OscdLayout extends LitElement {
462
465
if ( ! hasActiveEditors ) { return html `` ; }
463
466
464
467
return html `
465
- <mwc- tab- bar
466
- @MDCTabBar : activated= ${ this . handleActivatedEditorTabByUser }
467
- activeIndex= ${ this . activeTab }
468
+ <oscd- menu- tabs
469
+ .editors = ${ this . calcActiveEditors ( ) }
470
+ .activeEditor = ${ this . activeEditor }
471
+ @oscd-editor-tab-activated = ${ this . handleEditorTabActivated }
468
472
>
469
- ${ activeEditors }
470
- </ mwc- tab- bar>
471
- ${ renderEditorContent ( this . editors , this . activeTab , this . doc ) }
473
+ </ oscd- menu- tabs>
474
+ ${ renderEditorContent ( this . doc , this . activeEditor , ) }
472
475
` ;
473
476
474
- function renderEditorContent ( editors : Plugin [ ] , activeTab : number , doc : XMLDocument | null ) {
475
- const editor = editors [ activeTab ] ;
477
+ function renderEditorContent ( doc : XMLDocument | null , activeEditor ?: Plugin ) {
478
+ const editor = activeEditor ;
476
479
const requireDoc = editor ?. requireDoc
477
480
if ( requireDoc && ! doc ) { return html `` }
478
481
@@ -483,6 +486,10 @@ export class OscdLayout extends LitElement {
483
486
}
484
487
}
485
488
489
+ private handleEditorTabActivated ( e : TabActivatedEvent ) {
490
+ this . activeEditor = e . detail . editor
491
+ }
492
+
486
493
private handleActivatedEditorTabByUser ( e : CustomEvent ) : void {
487
494
const tabIndex = e . detail . index ;
488
495
this . activateTab ( tabIndex ) ;
0 commit comments