File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ export async function generate(app: App,
1818 try {
1919 console . debug ( "Started generation" ) ;
2020 let div : HTMLElement ;
21- // if (app.vault.getAbstractFileByPath(".thumbnail")) {
22- // await app.vault.createFolder(".thumbnail");
23- // };
21+ if ( ! app . vault . getAbstractFileByPath ( `${ plugin . settings . folder } ` ) ) {
22+ await app . vault . createFolder ( `${ plugin . settings . folder } ` ) ;
23+ }
24+
2425 const width = 1080 ;
2526 const height = Math . round ( width * ( rHeight / rWidth ) ) ;
2627
@@ -109,13 +110,16 @@ async function renderCM(
109110 width : number ,
110111) {
111112 try {
113+ const prevLeaf = app . workspace . getMostRecentLeaf ( ) ;
112114 console . debug ( "Rendering via CodeMirror" ) ;
113- const leaf : WorkspaceLeaf = app . workspace . getLeaf ( true ) ;
115+ const leaf : WorkspaceLeaf = app . workspace . getLeaf ( "tab" ) ;
114116 await leaf . openFile ( file , { active : false } ) ;
115117 const view : MarkdownView = leaf . view as MarkdownView ;
116118 const state = view . getState ( ) as { mode : string } ;
117119 const container = document . body . createDiv ( ) ;
118120
121+ app . workspace . setActiveLeaf ( prevLeaf , { focus : true } ) ;
122+
119123 if ( state . mode != "preview" ) {
120124 await view . setState ( { mode : "preview" } , { history : false } ) ;
121125 }
You can’t perform that action at this time.
0 commit comments