@@ -84,25 +84,26 @@ type CreateNoteBase = {
8484 * Serves as a base for "into", "before", and "after" variants,
8585 * sharing common URL-related fields.
8686 */
87- export type CreateNoteWithUrlOpts =
87+ export type CreateNoteWithLinkOpts =
8888 | ( CreateNoteBase & {
8989 target : "into" ;
90- parentNoteUrl ?: string ;
90+ parentNoteLink ?: string ;
9191 // No branch ID needed for "into"
9292 } )
9393 | ( CreateNoteBase & {
9494 target : "before" | "after" ;
95- parentNoteUrl ?: string ;
95+ // Either an Url or a Path
96+ parentNoteLink ?: string ;
9697 // Required for "before"/"after"
9798 targetBranchId : string ;
9899 } ) ;
99100
100101export type CreateNoteIntoDefaultOpts = CreateNoteBase & {
101102 target : "default" ;
102- parentNoteUrl ?: never ;
103+ parentNoteLink ?: never ;
103104} ;
104105
105- export type CreateNoteOpts = CreateNoteWithUrlOpts | CreateNoteIntoDefaultOpts ;
106+ export type CreateNoteOpts = CreateNoteWithLinkOpts | CreateNoteIntoDefaultOpts ;
106107
107108interface Response {
108109 // TODO: Deduplicate with server once we have client/server architecture.
@@ -139,7 +140,7 @@ async function createNote(
139140 case "into" :
140141 case "before" :
141142 case "after" :
142- return createNoteWithUrl ( resolvedOptions ) ;
143+ return createNoteWithLink ( resolvedOptions ) ;
143144 }
144145}
145146
@@ -148,7 +149,7 @@ async function createNoteFromAction(
148149 action : CreateNoteAction ,
149150 promptForType : boolean ,
150151 title : string | undefined ,
151- parentNoteUrl : string | undefined ,
152+ parentNoteLink : string | undefined ,
152153) : Promise < { note : FNote | null ; branch : FBranch | undefined } > {
153154 switch ( action ) {
154155 case CreateNoteAction . CreateNote : {
@@ -174,15 +175,15 @@ async function createNoteFromAction(
174175 return resp ;
175176 }
176177 case CreateNoteAction . CreateChildNote : {
177- if ( ! parentNoteUrl ) {
178+ if ( ! parentNoteLink ) {
178179 console . warn ( "Missing parentNotePath in createNoteFromCkEditor()" ) ;
179180 return { note : null , branch : undefined } ;
180181 }
181182
182183 const resp = await createNote (
183184 {
184185 target : "into" ,
185- parentNoteUrl ,
186+ parentNoteLink ,
186187 title,
187188 activate : true ,
188189 promptForType : true ,
@@ -191,14 +192,14 @@ async function createNoteFromAction(
191192 return resp
192193 }
193194 case CreateNoteAction . CreateAndLinkChildNote : {
194- if ( ! parentNoteUrl ) {
195+ if ( ! parentNoteLink ) {
195196 console . warn ( "Missing parentNotePath in createNoteFromCkEditor()" ) ;
196197 return { note : null , branch : undefined } ;
197198 }
198199 const resp = await createNote (
199200 {
200201 target : "into" ,
201- parentNoteUrl : parentNoteUrl ,
202+ parentNoteLink : parentNoteLink ,
202203 title,
203204 activate : false ,
204205 promptForType : promptForType ,
@@ -233,7 +234,7 @@ async function promptForType(
233234 resolvedOptions = {
234235 ...resolvedOptions ,
235236 target : "into" ,
236- parentNoteUrl : notePath ,
237+ parentNoteLink : notePath ,
237238 } ;
238239 }
239240
@@ -247,8 +248,8 @@ async function promptForType(
247248 * @param options - Note creation options
248249 * @returns A promise resolving with the created note and its branch.
249250 */
250- async function createNoteWithUrl (
251- options : CreateNoteWithUrlOpts
251+ async function createNoteWithLink (
252+ options : CreateNoteWithLinkOpts
252253) : Promise < { note : FNote | null ; branch : FBranch | undefined } > {
253254 options = Object . assign (
254255 {
@@ -273,8 +274,8 @@ async function createNoteWithUrl(
273274 [ options . title , options . content ] = parseSelectedHtml ( options . textEditor . getSelectedHtml ( ) ) ;
274275 }
275276
276- const parentNoteUrl = options . parentNoteUrl ;
277- const parentNoteId = treeService . getNoteIdFromUrl ( parentNoteUrl ) ;
277+ const parentNoteLink = options . parentNoteLink ;
278+ const parentNoteId = treeService . getNoteIdFromLink ( parentNoteLink ) ;
278279
279280 if ( options . type === "mermaid" && ! options . content && ! options . templateNoteId ) {
280281 options . content = `graph TD;
@@ -348,11 +349,11 @@ async function createNoteIntoDefaultLocation(
348349 inboxNote . isProtected && protectedSessionHolder . isProtectedSessionAvailable ( ) ;
349350 }
350351
351- const result = await createNoteWithUrl (
352+ const result = await createNoteWithLink (
352353 {
353354 ...options ,
354355 target : "into" ,
355- parentNoteUrl : inboxNote . noteId ,
356+ parentNoteLink : inboxNote . noteId ,
356357 }
357358 ) ;
358359
@@ -385,7 +386,7 @@ function parseSelectedHtml(selectedHtml: string) {
385386}
386387
387388async function duplicateSubtree ( noteId : string , parentNotePath : string ) {
388- const parentNoteId = treeService . getNoteIdFromUrl ( parentNotePath ) ;
389+ const parentNoteId = treeService . getNoteIdFromLink ( parentNotePath ) ;
389390 const { note } = await server . post < DuplicateResponse > ( `notes/${ noteId } /duplicate/${ parentNoteId } ` ) ;
390391
391392 await ws . waitForMaxKnownEntityChangeId ( ) ;
0 commit comments