11
22import { ObsidianRenderer , ObsidianLink , LinkPair , GltLink , DataviewLinkType } from 'types' ;
3- import { Page , getAPI } from 'obsidian-dataview' ;
3+ import { getAPI } from 'obsidian-dataview' ;
44import { Text , TextStyle } from 'pixi.js' ;
5+ // @ts -ignore
56import extractLinks from 'markdown-link-extractor' ;
67
78
@@ -156,6 +157,7 @@ export class LinkManager {
156157 // Here, we assume that dark themes have a background color with a low brightness value.
157158 let textColor = '#FF0000' ;
158159 if ( style && style . backgroundColor && style . backgroundColor ) {
160+ // @ts -ignore
159161 const isDarkTheme = style . backgroundColor . match ( / \d + / g) ?. map ( Number ) . slice ( 0 , 3 ) . reduce ( ( a , b ) => a + b , 0 ) < 382.5 ;
160162 isDarkTheme ? textColor = '#FFFFFF' : textColor = '#000000' ; // White text for dark themes, black for light themes)
161163 }
@@ -193,14 +195,15 @@ export class LinkManager {
193195
194196 // Get the metadata key for a link between two pages
195197 private getMetadataKeyForLink ( sourceId : string , targetId : string ) : string | null {
196- const sourcePage : Page | undefined = this . api . page ( sourceId ) ;
198+ const sourcePage : any = this . api . page ( sourceId ) ;
197199 if ( ! sourcePage ) return null ;
198200
199201 for ( const [ key , value ] of Object . entries ( sourcePage ) ) {
200202 const valueType = this . determineDataviewLinkType ( value ) ;
201203
202204 switch ( valueType ) {
203205 case DataviewLinkType . WikiLink :
206+ // @ts -ignore
204207 if ( value . path === targetId ) {
205208 return key ;
206209 }
@@ -211,6 +214,7 @@ export class LinkManager {
211214 }
212215 break ;
213216 case DataviewLinkType . Array :
217+ // @ts -ignore
214218 for ( const item of value ) {
215219 if ( this . determineDataviewLinkType ( item ) === DataviewLinkType . WikiLink && item . path === targetId ) {
216220 return key ;
@@ -220,7 +224,8 @@ export class LinkManager {
220224 }
221225 }
222226 break ;
223- // Handle other cases as needed
227+ default :
228+ console . warn ( "Link type from Obsidian not in recognized format." ) ;
224229 }
225230 }
226231 return null ;
0 commit comments