@@ -26,7 +26,7 @@ type ModifyNodeSubmitParams = {
2626
2727const createModifyNodeModalSubmitHandler = (
2828 plugin : DiscourseGraphPlugin ,
29- editor : Editor ,
29+ editor ? : Editor ,
3030) : ( ( params : ModifyNodeSubmitParams ) => Promise < void > ) => {
3131 return async ( {
3232 nodeType,
@@ -36,7 +36,9 @@ const createModifyNodeModalSubmitHandler = (
3636 relationshipTargetFile,
3737 } : ModifyNodeSubmitParams ) => {
3838 if ( selectedExistingNode ) {
39- editor . replaceSelection ( `[[${ selectedExistingNode . basename } ]]` ) ;
39+ if ( editor ) {
40+ editor . replaceSelection ( `[[${ selectedExistingNode . basename } ]]` ) ;
41+ }
4042 await addRelationIfRequested ( plugin , selectedExistingNode , {
4143 relationshipId,
4244 relationshipTargetFile,
@@ -66,7 +68,7 @@ export const registerCommands = (plugin: DiscourseGraphPlugin) => {
6668 const hasSelection = ! ! editor . getSelection ( ) ;
6769
6870 if ( hasSelection ) {
69- new NodeTypeModal ( plugin , ( nodeType ) => {
71+ new NodeTypeModal ( plugin , ( nodeType : DiscourseNode ) => {
7072 void createDiscourseNode ( {
7173 plugin,
7274 editor,
@@ -91,10 +93,12 @@ export const registerCommands = (plugin: DiscourseGraphPlugin) => {
9193 plugin . addCommand ( {
9294 id : "create-discourse-node" ,
9395 name : "Create discourse node" ,
94- editorCallback : ( editor : Editor ) => {
96+ callback : ( ) => {
9597 const currentFile =
9698 plugin . app . workspace . getActiveViewOfType ( MarkdownView ) ?. file ||
9799 undefined ;
100+ const editor =
101+ plugin . app . workspace . getActiveViewOfType ( MarkdownView ) ?. editor ;
98102 new ModifyNodeModal ( plugin . app , {
99103 nodeTypes : plugin . settings . nodeTypes ,
100104 plugin,
0 commit comments