@@ -237,8 +237,8 @@ export class ButtonActionRunner {
237237 await new Promise ( resolve => setTimeout ( resolve , action . ms ) ) ;
238238 }
239239
240- async runTemplaterCreateNoteAction ( _action : TemplaterCreateNoteButtonAction ) : Promise < void > {
241- throw new Error ( 'Not supported' ) ;
240+ async runTemplaterCreateNoteAction ( action : TemplaterCreateNoteButtonAction ) : Promise < void > {
241+ await this . plugin . internal . createNoteWithTemplater ( action . templateFile , action . folderPath , action . fileName ) ;
242242 }
243243
244244 async runUpdateMetadataAction ( action : UpdateMetadataButtonAction , filePath : string ) : Promise < void > {
@@ -259,13 +259,17 @@ export class ButtonActionRunner {
259259 }
260260
261261 async runReplaceInNoteAction ( action : ReplaceInNoteButtonAction , filePath : string ) : Promise < void > {
262+ const replacement = action . templater
263+ ? await this . plugin . internal . evaluateTemplaterTemplate ( action . replacement , filePath )
264+ : action . replacement ;
265+
262266 const content = await this . plugin . internal . readFilePath ( filePath ) ;
263267
264268 let splitContent = content . split ( '\n' ) ;
265269
266270 splitContent = [
267271 ...splitContent . slice ( 0 , action . fromLine - 1 ) ,
268- action . replacement ,
272+ replacement ,
269273 ...splitContent . slice ( action . toLine ) ,
270274 ] ;
271275
@@ -286,13 +290,17 @@ export class ButtonActionRunner {
286290 throw new Error ( 'Position of the button in the note is unknown' ) ;
287291 }
288292
293+ const replacement = action . templater
294+ ? await this . plugin . internal . evaluateTemplaterTemplate ( action . replacement , filePath )
295+ : action . replacement ;
296+
289297 const content = await this . plugin . internal . readFilePath ( filePath ) ;
290298
291299 let splitContent = content . split ( '\n' ) ;
292300
293301 splitContent = [
294302 ...splitContent . slice ( 0 , position . lineStart ) ,
295- action . replacement ,
303+ replacement ,
296304 ...splitContent . slice ( position . lineEnd + 1 ) ,
297305 ] ;
298306
@@ -316,11 +324,11 @@ export class ButtonActionRunner {
316324
317325 let splitContent = content . split ( '\n' ) ;
318326
319- splitContent = [
320- ... splitContent . slice ( 0 , action . line - 1 ) ,
321- action . value ,
322- ... splitContent . slice ( action . line - 1 ) ,
323- ] ;
327+ const replacement = action . templater
328+ ? await this . plugin . internal . evaluateTemplaterTemplate ( action . value , filePath )
329+ : action . value ;
330+
331+ splitContent = [ ... splitContent . slice ( 0 , action . line - 1 ) , replacement , ... splitContent . slice ( action . line - 1 ) ] ;
324332
325333 await this . plugin . internal . writeFilePath ( filePath , splitContent . join ( '\n' ) ) ;
326334 }
0 commit comments