(event)
| 300 | initHighlighting(); |
| 301 | |
| 302 | async function onContentClick(event) { |
| 303 | const link = event.target.closest("a[href]"); |
| 304 | if (!link) return; |
| 305 | |
| 306 | const originalHref = link.getAttribute("href") || ""; |
| 307 | const resolvedHref = |
| 308 | link.getAttribute("data-resolved-href") || |
| 309 | resolveMarkdownTarget( |
| 310 | originalHref, |
| 311 | getMarkdownBaseUri(previewState.file), |
| 312 | ); |
| 313 | event.preventDefault(); |
| 314 | event.stopPropagation(); |
| 315 | |
| 316 | if (originalHref.startsWith("#")) { |
| 317 | scrollToHash(originalHref.slice(1)); |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | if (isExternalLink(originalHref)) { |
| 322 | system.openInBrowser(originalHref); |
| 323 | return; |
| 324 | } |
| 325 | |
| 326 | const hashIndex = resolvedHref.indexOf("#"); |
| 327 | const targetPath = |
| 328 | hashIndex === -1 ? resolvedHref : resolvedHref.slice(0, hashIndex); |
| 329 | const targetHash = |
| 330 | hashIndex === -1 ? "" : resolvedHref.slice(hashIndex + 1); |
| 331 | |
| 332 | if (!targetPath && targetHash) { |
| 333 | scrollToHash(targetHash); |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | if (isMarkdownPath(resolvedHref)) { |
| 338 | await openFile(targetPath, { render: true }); |
| 339 | const nextFile = |
| 340 | editorManager.getFile(targetPath, "uri") || editorManager.activeFile; |
| 341 | if (nextFile) { |
| 342 | await bind(nextFile, targetHash); |
| 343 | } |
| 344 | return; |
| 345 | } |
| 346 | |
| 347 | $page.hide(); |
| 348 | await openFile(targetPath, { render: true }); |
| 349 | } |
| 350 | |
| 351 | function scrollToHash(targetId) { |
| 352 | const target = getTargetElement(previewState.content, targetId); |
nothing calls this directly
no test coverage detected