File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ export default class DictionaryPlugin extends Plugin {
3939 return new DictionaryView ( leaf , this ) ;
4040 } ) ;
4141
42+ if ( this . app . workspace . getLeavesOfType ( VIEW_TYPE ) . length == 0 ) {
43+ await this . app . workspace . getRightLeaf ( false ) . setViewState ( {
44+ type : VIEW_TYPE ,
45+ } ) ;
46+ }
47+ this . app . workspace . revealLeaf ( this . app . workspace . getLeavesOfType ( VIEW_TYPE ) . first ( ) ) ;
48+
4249 this . addCommand ( {
4350 id : 'dictionary-open-view' ,
4451 name : t ( 'Open Dictionary View' ) ,
@@ -126,6 +133,9 @@ export default class DictionaryPlugin extends Plugin {
126133 onunload ( ) : void {
127134 console . log ( 'unloading dictionary' ) ;
128135 this . app . workspace . off ( 'editor-menu' , this . handleContextMenuHelper )
136+ if ( this . app . workspace . getLeavesOfType ( VIEW_TYPE ) . length ) {
137+ this . app . workspace . getLeavesOfType ( VIEW_TYPE ) [ 0 ] . detach ( ) ;
138+ }
129139 }
130140
131141 handleContextMenuHelper = ( menu : Menu , editor : Editor , _ : MarkdownView ) : void => {
You can’t perform that action at this time.
0 commit comments