@@ -87,7 +87,7 @@ export default function GraphView({
8787 bgColor,
8888 accentColor,
8989} : GraphViewProps ) {
90- const fgRef = useRef < ForceGraphMethods < GraphNode , GraphLink > | undefined > ( undefined )
90+ const fgRef = useRef < ForceGraphMethods < GraphNode , GraphLink > > ( null )
9191
9292 const draggedNodesRef = useRef < Set < string > > ( new Set ( ) )
9393 const graphDataRef = useRef < { nodes : GraphNode [ ] ; links : GraphLink [ ] } > ( { nodes : [ ] , links : [ ] } )
@@ -158,12 +158,12 @@ export default function GraphView({
158158 const nodes : GraphNode [ ] = notes . map ( ( n ) => {
159159 const isAuto = / ^ \d + \. m d $ / . test ( n . id )
160160 let title = n . id . replace ( / \. m d $ / , '' )
161- const folder = n . id . includes ( '/' ) ? n . id . split ( '/' ) [ 0 ] : ''
161+ const folder = n . id . includes ( '/' ) ? n . id . split ( '/' ) [ 0 ] ! : ''
162162
163163 if ( isAuto ) {
164164 title =
165165 n . content
166- . split ( '\n' ) [ 0 ]
166+ . split ( '\n' ) [ 0 ] !
167167 . trim ( )
168168 . replace ( / ^ # + \s * / , '' ) || 'New Note'
169169 }
@@ -180,22 +180,22 @@ export default function GraphView({
180180 const reFile = / \] \( \/ f i l e \s + ( [ ^ ) ] + ) \) / g
181181 let match
182182 while ( ( match = reFile . exec ( note . content ) ) !== null ) {
183- let targetId = match [ 1 ] . trim ( ) . replace ( / \\ / g, '/' )
183+ let targetId = match [ 1 ] ! . trim ( ) . replace ( / \\ / g, '/' )
184184 if ( ! targetId . endsWith ( '.md' ) ) targetId += '.md'
185185 targets . add ( targetId )
186186 }
187187
188188 const reMd = / \] \( ( [ ^ ) ] + \. m d ) \) / g
189189 while ( ( match = reMd . exec ( note . content ) ) !== null ) {
190- let targetId = match [ 1 ] . trim ( ) . replace ( / \\ / g, '/' )
190+ let targetId = match [ 1 ] ! . trim ( ) . replace ( / \\ / g, '/' )
191191 if ( targetId . startsWith ( './' ) ) targetId = targetId . slice ( 2 )
192192 if ( targetId . startsWith ( '/' ) ) targetId = targetId . slice ( 1 )
193193 targets . add ( targetId )
194194 }
195195
196196 const reWiki = / \[ \[ ( [ ^ \] ] + ) \] \] / g
197197 while ( ( match = reWiki . exec ( note . content ) ) !== null ) {
198- let targetId = match [ 1 ] . split ( '|' ) [ 0 ] . trim ( ) . replace ( / \\ / g, '/' )
198+ let targetId = match [ 1 ] ! . split ( '|' ) [ 0 ] ! . trim ( ) . replace ( / \\ / g, '/' )
199199 if ( ! targetId . endsWith ( '.md' ) ) targetId += '.md'
200200 targets . add ( targetId )
201201 }
@@ -299,8 +299,9 @@ export default function GraphView({
299299 } , [ ] )
300300
301301 const nodeThreeObject = useCallback (
302- ( node : GraphNode ) => {
303- const color = node . folder ? getFolderColor ( node . folder ) : accentColor
302+ ( node : object ) => {
303+ const gNode = node as GraphNode
304+ const color = gNode . folder ? getFolderColor ( gNode . folder ) : accentColor
304305 const group = new THREE . Group ( )
305306
306307 const geometry = new THREE . CircleGeometry ( NODE_RADIUS , 32 )
@@ -315,9 +316,9 @@ export default function GraphView({
315316 const ctx = canvas . getContext ( '2d' ) !
316317 ctx . clearRect ( 0 , 0 , 256 , 64 )
317318 const displayName =
318- node . name . length > MAX_NAME_LENGTH
319- ? node . name . slice ( 0 , MAX_NAME_LENGTH - 3 ) + '…'
320- : node . name
319+ gNode . name . length > MAX_NAME_LENGTH
320+ ? gNode . name . slice ( 0 , MAX_NAME_LENGTH - 3 ) + '…'
321+ : gNode . name
321322 ctx . fillStyle = textColor
322323 ctx . font = `bold ${ LABEL_FONT_SIZE } px sans-serif`
323324 ctx . textAlign = 'center'
@@ -510,7 +511,7 @@ export default function GraphView({
510511 }
511512 >
512513 < ForceGraph3D
513- ref = { fgRef }
514+ ref = { fgRef as never }
514515 graphData = { graphData }
515516 numDimensions = { 2 }
516517 nodeLabel = "name"
0 commit comments