1- import { DockviewComponent , DockviewGroupPanel , getGridLocation , getRelativeLocation , DockviewEmitter } from "./dockview-core.esm.js"
1+ import { DockviewComponent , DockviewGroupPanel , DockviewGroupPanelModel , getGridLocation , getRelativeLocation , DockviewEmitter } from "./dockview-core.esm.js"
22import { getConfigFromStorage , saveConfig } from "./dockview-config.js"
33import { disposeGroup , removeDrawerBtn } from "./dockview-group.js"
44
5- DockviewComponent . prototype . on = function ( eventType , callback ) {
5+ DockviewComponent . prototype . on = function ( eventType , callback ) {
66 this [ '_' + eventType ] = new DockviewEmitter ( ) ;
77 this [ '_' + eventType ] . event ( callback )
88}
99
1010const dispose = DockviewComponent . prototype . dispose ;
11- DockviewComponent . prototype . dispose = function ( ) {
11+ DockviewComponent . prototype . dispose = function ( ) {
1212 this . params . observer ?. disconnect ( ) ;
1313 this . groups . forEach ( group => {
1414 if ( group . mutationObserver ) {
@@ -20,28 +20,29 @@ DockviewComponent.prototype.dispose = function () {
2020}
2121
2222const groupDispose = DockviewGroupPanel . prototype . dispose
23- DockviewGroupPanel . prototype . dispose = function ( ) {
23+ DockviewGroupPanel . prototype . dispose = function ( ) {
2424 disposeGroup ( this )
2525 groupDispose . call ( this )
2626}
27- DockviewGroupPanel . prototype . getParams = function ( ) {
27+ DockviewGroupPanel . prototype . getParams = function ( ) {
2828 return this . activePanel ?. params || { }
2929}
3030
31- DockviewGroupPanel . prototype . setParams = function ( data ) {
31+ DockviewGroupPanel . prototype . setParams = function ( data ) {
32+ console . log ( 'setParameter' , data ) ;
3233 Object . keys ( data ) . forEach ( key => {
3334 this . panels . forEach ( panel => panel . params [ key ] = data [ key ] )
3435 } )
3536}
3637
37- DockviewGroupPanel . prototype . removePropsOfParams = function ( keys ) {
38+ DockviewGroupPanel . prototype . removePropsOfParams = function ( keys ) {
3839 return ( keys instanceof Array )
3940 ? keys . map ( key => this . panels . forEach ( panel => delete panel . params [ key ] ) )
4041 : typeof keys == 'string' ? this . panels . forEach ( panel => delete panel . params [ keys ] ) : false
4142}
4243
4344const removeGroup = DockviewComponent . prototype . removeGroup
44- DockviewComponent . prototype . removeGroup = function ( ...args ) {
45+ DockviewComponent . prototype . removeGroup = function ( ...args ) {
4546 if ( this . isClearing ) {
4647 return removeGroup . apply ( this , args )
4748 }
@@ -70,29 +71,31 @@ DockviewComponent.prototype.removeGroup = function (...args) {
7071 }
7172}
7273
73- const removePanel = DockviewComponent . prototype . removePanel
74- DockviewComponent . prototype . removePanel = function ( ... args ) {
75- const panel = args [ 0 ] , moveToTemplate = args [ 1 ]
74+ const closePanel = DockviewGroupPanelModel . prototype . closePanel ;
75+ DockviewGroupPanelModel . prototype . closePanel = function ( panel ) {
76+ console . log ( panel ) ;
7677 if ( ! panel . group . locked ) {
77- removePanel . apply ( this , args )
78- if ( ! this . isClearing ) {
79- this . _panelVisibleChanged ?. fire ( { key : panel . params . key , status : false } ) ;
78+ closePanel . call ( this , panel ) ;
79+ if ( ! this . accessor . isClearing ) {
80+ this . accessor . _panelVisibleChanged ?. fire ( { key : panel . params . key , status : false } ) ;
8081 }
8182 }
83+
84+ const moveToTemplate = ! this . accessor . firstLoad ;
8285 if ( moveToTemplate ) {
8386 if ( panel . view . content . element ) {
8487 if ( panel . titleMenuEle ) {
8588 panel . view . content . element . append ( panel . titleMenuEle )
8689 }
87- if ( this . params . template ) {
88- this . params . template . append ( panel . view . content . element )
90+ if ( this . accessor . params . template ) {
91+ this . accessor . params . template . append ( panel . view . content . element )
8992 }
9093 }
9194 }
9295}
9396
9497const setVisible = DockviewComponent . prototype . setVisible
95- DockviewComponent . prototype . setVisible = function ( ...args ) {
98+ DockviewComponent . prototype . setVisible = function ( ...args ) {
9699 setVisible . apply ( this , args )
97100 const branch = getBranchByGroup ( args [ 0 ] )
98101 const { orientation, splitview : { sashes } } = branch
0 commit comments