Skip to content

Fix Link Navigation Behavior (External + Internal Links) #184

Description

@ZFordDev

Summary

SnapDock currently handles link navigation incorrectly due to default Electron behaviors.
This affects both external URLs and local file links inside the Markdown preview.

This issue is not related to markdown-it-link-attributes wiring (verified working).
The problem exists in SnapDock’s navigation policy, split between the main process and renderer.


Problems Identified

1. External links open in a new SnapDock Electron window

Example:

https://google.com

Expected:

  • Open in the system browser

Actual:

  • Electron opens a new BrowserWindow
  • Window loads SnapDock’s HTML (logo)
  • User sees a blank SnapDock window instead of the website

Cause:
Electron intercepts target="_blank" and creates a new BrowserWindow unless overridden.


2. Local file links open a blank SnapDock window

Example:

./README.md
./src/modules/markdown.js

Expected:

  • Open the file in a new SnapDock tab
  • Load file content into the editor

Actual:

  • Electron opens a new BrowserWindow
  • Window is blank
  • No file is loaded

Cause:
Electron treats relative paths as navigation requests and opens a new window.


3. Attribute blocks render literally (expected)

Example:

[Google](https://google.com){target="_blank"}

This is correct behavior — SnapDock does not support attribute block syntax.


Goal

Implement a proper link‑navigation policy so SnapDock behaves like a modern editor:

  • External links → open in system browser
  • Internal file links → open file in a new tab
  • No new Electron windows created by link clicks
  • Markdown preview remains sandboxed and safe

Deliverables

A. Main Process Fix (External Links)

Add navigation interception:

  • Intercept new-window
  • Intercept will-navigate
  • Detect external URLs
  • Redirect using shell.openExternal(url)
  • Prevent Electron from creating new windows

B. Renderer Fix (Internal Links)

Add click handler for <a> tags:

  • Detect relative paths
  • Prevent default navigation
  • IPC → open file in new tab
  • Ensure editor loads file content correctly

C. No changes to markdown-it

Link attributes are already wired and functioning.


Testing Requirements

Use the Markdown test file to verify:

  • External links open system browser
  • Internal links open new SnapDock tabs
  • No blank windows
  • No navigation errors
  • No regressions in markdown rendering

Closing Condition

This issue is complete when:

  • External URLs never open inside Electron
  • Internal file links always open in a new tab
  • No new BrowserWindows are created from link clicks
  • Behavior matches expected UX for SnapDock v3.2.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions