@@ -35,7 +35,7 @@ export class LinkManager {
3535 0x000000 // Black for contrast
3636 ]
3737
38-
38+
3939 currentTagColorIndex = 0 ;
4040 yOffset = 5 ; // To increment the y position for each legend item
4141 xOffset = 20 ;
@@ -55,12 +55,12 @@ export class LinkManager {
5555 generateKey ( sourceId : string , targetId : string ) : string {
5656 return `${ sourceId } -${ targetId } ` ;
5757 }
58-
58+
5959 private detectThemeChange ( ) : void {
6060 let lastTheme = '' ;
6161 let lastStyleSheetHref = '' ;
6262 let debounceTimer : number ;
63-
63+
6464 const themeObserver = new MutationObserver ( ( ) => {
6565 clearTimeout ( debounceTimer ) ;
6666 debounceTimer = window . setTimeout ( ( ) => {
@@ -75,23 +75,23 @@ export class LinkManager {
7575 }
7676 } , 100 ) ; // Debounce delay
7777 } ) ;
78-
78+
7979 themeObserver . observe ( document . body , { attributes : true , attributeFilter : [ 'class' ] } ) ;
8080 themeObserver . observe ( document . head , { childList : true , subtree : true , attributes : true , attributeFilter : [ 'href' ] } ) ;
8181 }
82-
82+
8383 private getComputedColorFromClass ( className : string , cssVariable : string ) : string {
8484 // Create a temporary element
8585 const tempElement = document . createElement ( 'div' ) ;
86-
86+
8787 // Apply the class to the temporary element
8888 tempElement . classList . add ( className ) ;
8989 document . body . appendChild ( tempElement ) ;
90-
90+
9191 // Get the computed style of the temporary element
9292 const style = getComputedStyle ( tempElement ) ;
9393 const colorValue = style . getPropertyValue ( cssVariable ) . trim ( ) ;
94-
94+
9595 // Remove the temporary element
9696 document . body . removeChild ( tempElement ) ;
9797
@@ -132,7 +132,7 @@ export class LinkManager {
132132 const reverseKey = this . generateKey ( link . target . id , link . source . id ) ;
133133
134134 const gltLink = this . linksMap . get ( key ) ;
135-
135+
136136 if ( gltLink && gltLink . pixiText && renderer . px && renderer . px . stage && renderer . px . stage . children && renderer . px . stage . children . includes ( gltLink . pixiText ) ) {
137137 renderer . px . stage . removeChild ( gltLink . pixiText ) ;
138138 gltLink . pixiText . destroy ( ) ;
@@ -247,21 +247,21 @@ export class LinkManager {
247247 } ;
248248 let { nx, ny} = this . calculateNormal ( link . source . x , link . source . y , link . target . x , link . target . y ) ;
249249 let { px, py} = this . calculateParallel ( link . source . x , link . source . y , link . target . x , link . target . y ) ;
250-
250+
251251 nx *= 1.5 * Math . sqrt ( renderer . scale ) ;
252252 ny *= 1.5 * Math . sqrt ( renderer . scale ) ;
253253
254254 px *= 8 * Math . sqrt ( renderer . scale ) ;
255255 py *= 8 * Math . sqrt ( renderer . scale ) ;
256-
256+
257257
258258 let { x :x1 , y :y1 } = this . getLinkToTextCoordinates ( link . source . x , link . source . y , renderer . panX , renderer . panY , renderer . scale ) ;
259259 let { x :x2 , y :y2 } = this . getLinkToTextCoordinates ( link . target . x , link . target . y , renderer . panX , renderer . panY , renderer . scale ) ;
260260 x1 += nx + ( link . source . weight / 36 + 1 ) * px ;
261261 x2 += nx - ( link . target . weight / 36 + 1 ) * px ;
262262 y1 += ny + ( link . source . weight / 36 + 1 ) * py ;
263263 y2 += ny - ( link . target . weight / 36 + 1 ) * py ;
264-
264+
265265
266266 if ( graphics && renderer . px && renderer . px . stage && renderer . px . stage . children && renderer . px . stage . children . includes ( graphics ) ) {
267267 // @ts -ignore
@@ -313,7 +313,7 @@ export class LinkManager {
313313
314314 this . updateLinkText ( renderer , link , false ) ;
315315 renderer . px . stage . addChild ( text ) ;
316-
316+
317317 return text
318318 }
319319
@@ -327,7 +327,7 @@ export class LinkManager {
327327 } //doesn't add if link is null
328328
329329 let color ;
330-
330+
331331 if ( link . source . id === link . target . id ) {
332332 linkString = "" ;
333333 } else {
@@ -369,7 +369,7 @@ export class LinkManager {
369369 this . tagColors . set ( linkString , newLegendGraphic ) ;
370370 } else { // this tag is in the map already
371371 const legendGraphic = this . tagColors . get ( linkString )
372-
372+
373373 if ( legendGraphic ) {
374374 color = legendGraphic ?. color ;
375375 legendGraphic . nUsing += 1 ;
@@ -388,7 +388,7 @@ export class LinkManager {
388388
389389 this . updateLinkGraphics ( renderer , link ) ;
390390
391-
391+
392392 return graphics
393393 }
394394
@@ -417,8 +417,8 @@ export class LinkManager {
417417 // Remove all text nodes from the graph
418418 destroyMap ( renderer : ObsidianRenderer ) : void {
419419 if ( this . linksMap . size > 0 ) {
420- this . linksMap . forEach ( ( gltLink , linkKey ) => {
421- this . removeLink ( renderer , gltLink . obsidianLink )
420+ this . linksMap . forEach ( ( gltLink , linkKey ) => {
421+ this . removeLink ( renderer , gltLink . obsidianLink )
422422 } ) ;
423423 }
424424 }
@@ -429,7 +429,7 @@ export class LinkManager {
429429 if ( ! sourcePage ) return null ;
430430
431431 for ( const [ key , value ] of Object . entries ( sourcePage ) ) {
432- // Skip empty values
432+ // Skip empty values
433433 if ( value === null || value === undefined || value === '' ) {
434434 continue ;
435435 }
@@ -459,8 +459,8 @@ export class LinkManager {
459459 }
460460 break ;
461461 default :
462- //metadata is not a link, return null
463- return null ;
462+ // We will continue to check other DataView properties
463+ break ;
464464 }
465465 }
466466 return null ;
@@ -476,33 +476,33 @@ export class LinkManager {
476476 // Calculate the direction vector D
477477 const dx = targetX - sourceX ;
478478 const dy = targetY - sourceY ;
479-
479+
480480 // Calculate the normal vector N by rotating D by 90 degrees
481481 let nx = - dy ;
482482 let ny = dx ;
483-
483+
484484 // Normalize the normal vector to get a unit vector
485485 const length = Math . sqrt ( nx * nx + ny * ny ) ;
486486 nx /= length ; // Normalize the x component
487487 ny /= length ; // Normalize the y component
488-
488+
489489
490490 return { nx, ny } ;
491491 }
492-
492+
493493 private calculateParallel ( sourceX : number , sourceY : number , targetX : number , targetY : number ) : { px : number ; py : number ; } {
494494 // Calculate the direction vector D from source to target
495495 const dx = targetX - sourceX ;
496496 const dy = targetY - sourceY ;
497-
497+
498498 // No need to rotate the vector for a parallel vector
499-
499+
500500 // Normalize the direction vector to get a unit vector
501501 const length = Math . sqrt ( dx * dx + dy * dy ) ;
502502 const px = dx / length ; // Normalize the x component
503503 const py = dy / length ; // Normalize the y component
504-
504+
505505 return { px, py } ;
506506 }
507-
507+
508508}
0 commit comments