@@ -2,7 +2,7 @@ import joplin from "api";
22import { SettingItemType } from "api/types" ;
33import { Parser } from "./parser" ;
44import { DateAndTimeUtils } from "./utils/dateAndTime" ;
5- import { doesFolderExist } from "./utils/folders" ;
5+ import { doesFolderExist , Note } from "./utils/folders" ;
66import { getTemplateFromId , getUserTemplateSelection } from "./utils/templates" ;
77import { setDefaultTemplatesView } from "./views/defaultTemplates" ;
88import { JoplinCommand } from "./types" ;
@@ -50,15 +50,15 @@ joplin.plugins.register({
5050
5151
5252 // Utility Functions
53- const executeCommandWithParsedTemplate = async ( command : JoplinCommand , template : string | null ) => {
53+ const executeCommandWithParsedTemplate = async ( command : JoplinCommand , template : Note | null ) => {
5454 const parsedTemplate = await parser . parseTemplate ( template ) ;
5555 if ( parsedTemplate ) {
5656 await joplin . commands . execute ( command , parsedTemplate ) ;
5757 }
5858 }
5959
6060 const getTemplateAndExecuteCommand = async ( command : JoplinCommand ) => {
61- const template = await getUserTemplateSelection ( templatesFolderId ) ;
61+ const template : Note = JSON . parse ( await getUserTemplateSelection ( templatesFolderId ) ) ;
6262 await executeCommandWithParsedTemplate ( command , template ) ;
6363 }
6464
@@ -133,7 +133,7 @@ joplin.plugins.register({
133133 execute : async ( ) => {
134134 const template = await getTemplateFromId ( await joplin . settings . value ( "defaultNoteTemplateId" ) ) ;
135135 if ( template ) {
136- return await executeCommandWithParsedTemplate ( JoplinCommand . NewNote , template . body ) ;
136+ return await executeCommandWithParsedTemplate ( JoplinCommand . NewNote , template ) ;
137137 }
138138 await joplin . views . dialogs . showMessageBox ( "No default note template is set." ) ;
139139 }
@@ -145,7 +145,7 @@ joplin.plugins.register({
145145 execute : async ( ) => {
146146 const template = await getTemplateFromId ( await joplin . settings . value ( "defaultTodoTemplateId" ) ) ;
147147 if ( template ) {
148- return await executeCommandWithParsedTemplate ( JoplinCommand . NewTodo , template . body ) ;
148+ return await executeCommandWithParsedTemplate ( JoplinCommand . NewTodo , template ) ;
149149 }
150150 await joplin . views . dialogs . showMessageBox ( "No default to-do template is set." ) ;
151151 }
0 commit comments