Commit 854c2d0 anpigon
committed
1 parent 520920f commit 854c2d0 Copy full SHA for 854c2d0
File tree 2 files changed +18
-27
lines changed
2 files changed +18
-27
lines changed Original file line number Diff line number Diff line change @@ -123,34 +123,28 @@ export default class BookSearchPlugin extends Plugin {
123
123
// if use Templater plugin
124
124
await useTemplaterPluginInFile ( this . app , targetFile ) ;
125
125
this . openNewBookNote ( targetFile ) ;
126
-
127
126
} catch ( err ) {
128
127
console . warn ( err ) ;
129
128
this . showNotice ( err ) ;
130
129
}
131
130
}
132
131
133
-
134
132
async openNewBookNote ( targetFile : TFile ) {
135
- if ( ! this . settings . openPageOnCompletion )
136
- return ;
133
+ if ( ! this . settings . openPageOnCompletion ) return ;
137
134
135
+ // open file
136
+ const activeLeaf = this . app . workspace . getLeaf ( ) ;
137
+ if ( ! activeLeaf ) {
138
+ console . warn ( 'No active leaf' ) ;
139
+ return ;
140
+ }
138
141
139
- // open file
140
- const activeLeaf = this . app . workspace . getLeaf ( ) ;
141
- if ( ! activeLeaf ) {
142
- console . warn ( 'No active leaf' ) ;
143
- return ;
144
- }
145
-
146
- await activeLeaf . openFile ( targetFile , { state : { mode : 'source' } } ) ;
147
- activeLeaf . setEphemeralState ( { rename : 'all' } ) ;
148
- // cursor focus
149
- await new CursorJumper ( this . app ) . jumpToNextCursorLocation ( ) ;
142
+ await activeLeaf . openFile ( targetFile , { state : { mode : 'source' } } ) ;
143
+ activeLeaf . setEphemeralState ( { rename : 'all' } ) ;
144
+ // cursor focus
145
+ await new CursorJumper ( this . app ) . jumpToNextCursorLocation ( ) ;
150
146
}
151
147
152
-
153
-
154
148
async openBookSearchModal ( query = '' ) : Promise < Book [ ] > {
155
149
return new Promise ( ( resolve , reject ) => {
156
150
return new BookSearchModal ( this , query , ( error , results ) => {
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export const DEFAULT_SETTINGS: BookSearchPluginSettings = {
42
42
naverClientId : '' ,
43
43
naverClientSecret : '' ,
44
44
localePreference : 'default' ,
45
- openPageOnCompletion : true
45
+ openPageOnCompletion : true ,
46
46
} ;
47
47
48
48
export class BookSearchSettingTab extends PluginSettingTab {
@@ -209,18 +209,15 @@ export class BookSearchSettingTab extends PluginSettingTab {
209
209
} ) ;
210
210
211
211
new Setting ( containerEl )
212
- . setName ( " Open New Book Note" )
213
- . setDesc ( " Enable or disable the automatic opening of the note on creation." )
212
+ . setName ( ' Open New Book Note' )
213
+ . setDesc ( ' Enable or disable the automatic opening of the note on creation.' )
214
214
. addToggle ( toggle =>
215
- toggle
216
- . setValue ( this . plugin . settings . openPageOnCompletion )
217
- . onChange ( async value => {
218
- this . plugin . settings . openPageOnCompletion = value ;
219
- await this . plugin . saveSettings ( ) ;
220
- } )
215
+ toggle . setValue ( this . plugin . settings . openPageOnCompletion ) . onChange ( async value => {
216
+ this . plugin . settings . openPageOnCompletion = value ;
217
+ await this . plugin . saveSettings ( ) ;
218
+ } ) ,
221
219
) ;
222
220
223
-
224
221
// Frontmatter Settings
225
222
const formatterSettingsChildren : Setting [ ] = [ ] ;
226
223
createFoldingHeader ( containerEl , 'Frontmatter Settings' , formatterSettingsChildren ) ;
You can’t perform that action at this time.
0 commit comments