@@ -4,7 +4,7 @@ import { Parser } from "./parser";
44import { DateAndTimeUtils } from "./utils/dateAndTime" ;
55import { getTemplateFromId , getUserTemplateSelection , Note } from "./utils/templates" ;
66import { setDefaultTemplatesView } from "./views/defaultTemplates" ;
7- import { JoplinCommand } from "./types " ;
7+ import { TemplateAction , performAction } from "./actions " ;
88import { loadLegacyTemplates } from "./legacyTemplates" ;
99import * as open from "open" ;
1010
@@ -44,16 +44,16 @@ joplin.plugins.register({
4444
4545
4646 // Utility Functions
47- const executeCommandWithParsedTemplate = async ( command : JoplinCommand , template : Note | null ) => {
47+ const performActionWithParsedTemplate = async ( action : TemplateAction , template : Note | null ) => {
4848 const parsedTemplate = await parser . parseTemplate ( template ) ;
4949 if ( parsedTemplate ) {
50- await joplin . commands . execute ( command , parsedTemplate ) ;
50+ await performAction ( action , parsedTemplate ) ;
5151 }
5252 }
5353
54- const getTemplateAndExecuteCommand = async ( command : JoplinCommand ) => {
54+ const getTemplateAndPerformAction = async ( action : TemplateAction ) => {
5555 const template : Note = JSON . parse ( await getUserTemplateSelection ( ) ) ;
56- await executeCommandWithParsedTemplate ( command , template ) ;
56+ await performActionWithParsedTemplate ( action , template ) ;
5757 }
5858
5959
@@ -62,23 +62,23 @@ joplin.plugins.register({
6262 name : "createNoteFromTemplate" ,
6363 label : "Create note from template" ,
6464 execute : async ( ) => {
65- await getTemplateAndExecuteCommand ( JoplinCommand . NewNote ) ;
65+ await getTemplateAndPerformAction ( TemplateAction . NewNote ) ;
6666 }
6767 } ) ;
6868
6969 await joplin . commands . register ( {
7070 name : "createTodoFromTemplate" ,
7171 label : "Create to-do from template" ,
7272 execute : async ( ) => {
73- await getTemplateAndExecuteCommand ( JoplinCommand . NewTodo ) ;
73+ await getTemplateAndPerformAction ( TemplateAction . NewTodo ) ;
7474 }
7575 } ) ;
7676
7777 await joplin . commands . register ( {
7878 name : "insertTemplate" ,
7979 label : "Insert template" ,
8080 execute : async ( ) => {
81- await getTemplateAndExecuteCommand ( JoplinCommand . InsertText ) ;
81+ await getTemplateAndPerformAction ( TemplateAction . InsertText ) ;
8282 }
8383 } ) ;
8484
@@ -127,7 +127,7 @@ joplin.plugins.register({
127127 execute : async ( ) => {
128128 const template = await getTemplateFromId ( await joplin . settings . value ( "defaultNoteTemplateId" ) ) ;
129129 if ( template ) {
130- return await executeCommandWithParsedTemplate ( JoplinCommand . NewNote , template ) ;
130+ return await performActionWithParsedTemplate ( TemplateAction . NewNote , template ) ;
131131 }
132132 await joplin . views . dialogs . showMessageBox ( "No default note template is set." ) ;
133133 }
@@ -139,7 +139,7 @@ joplin.plugins.register({
139139 execute : async ( ) => {
140140 const template = await getTemplateFromId ( await joplin . settings . value ( "defaultTodoTemplateId" ) ) ;
141141 if ( template ) {
142- return await executeCommandWithParsedTemplate ( JoplinCommand . NewTodo , template ) ;
142+ return await performActionWithParsedTemplate ( TemplateAction . NewTodo , template ) ;
143143 }
144144 await joplin . views . dialogs . showMessageBox ( "No default to-do template is set." ) ;
145145 }
0 commit comments