mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	feat(note_tooltip): display tooltip of footnote reference
This commit is contained in:
		
							parent
							
								
									ab9769c93b
								
							
						
					
					
						commit
						3f65fb83cb
					
				| @ -58,10 +58,15 @@ async function mouseEnterHandler(this: HTMLElement) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     const note = await froca.getNote(noteId); | ||||
|     let renderPromise; | ||||
|     if (url?.startsWith("#fn")) { | ||||
|         renderPromise = renderFootnote($link, url); | ||||
|     } else { | ||||
|         renderPromise = renderTooltip(await froca.getNote(noteId)) | ||||
|     } | ||||
| 
 | ||||
|     const [content] = await Promise.all([ | ||||
|         renderTooltip(note), | ||||
|         renderPromise, | ||||
|         // to reduce flicker due to accidental mouseover, cursor must stay for a bit over the link for tooltip to appear
 | ||||
|         new Promise(res => setTimeout(res, 500)) | ||||
|     ]); | ||||
| @ -147,6 +152,19 @@ async function renderTooltip(note: FNote | null) { | ||||
|     return content; | ||||
| } | ||||
| 
 | ||||
| function renderFootnote($link: JQuery<HTMLElement>, url: string) { | ||||
|     // A footnote text reference
 | ||||
|     const footnoteRef = url.substring(3); | ||||
|     const $footnoteContent = $link | ||||
|         .closest(".ck-content")           // find the parent CK content
 | ||||
|         .find("> .footnote-section")                // find the footnote section
 | ||||
|         .find(`a[href="#fnref${footnoteRef}"]`)     // find the footnote link
 | ||||
|         .closest(".footnote-item")        // find the parent container of the footnote
 | ||||
|         .find(".footnote-content");                 // find the actual text content of the footnote
 | ||||
| 
 | ||||
|     return $footnoteContent.html() || ""; | ||||
| } | ||||
| 
 | ||||
| export default { | ||||
|     setupGlobalTooltip, | ||||
|     setupElementTooltip | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran