Merged
Conversation
Add isRelativePath() utility to detect relative URLs and click event delegation on preview pane to intercept relative link clicks, resolve them against the current file's parent path, and open via MarkEdit.openFile(). Includes 13 new tests for isRelativePath(). Agent-Logs-Url: https://github.com/MarkEdit-app/MarkEdit-preview/sessions/d166ad61-577f-4c71-a7e5-d62f97cab8f6 Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix handling of relative links outside root in preview mode
Handle relative links in preview mode via native file API
Mar 29, 2026
Contributor
|
@copilot I haven't yet checked the details, can you make sure your change only applies to links start with "../". |
Per maintainer feedback, restrict the click interception to links starting with "../" only. Remove the now-unnecessary isRelativePath() utility and its test file. Agent-Logs-Url: https://github.com/MarkEdit-app/MarkEdit-preview/sessions/bf2367cc-cfbf-4aab-8991-df30b8f2a973 Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Contributor
Author
Copilot
AI
changed the title
Handle relative links in preview mode via native file API
Handle Mar 29, 2026
../ relative links in preview mode via native file API
cyanzhong
reviewed
Mar 29, 2026
src/view.ts
Outdated
Agent-Logs-Url: https://github.com/MarkEdit-app/MarkEdit-preview/sessions/f529384f-2def-40e2-a1bb-bc5bdfde21d0 Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
cyanzhong
reviewed
Mar 29, 2026
Agent-Logs-Url: https://github.com/MarkEdit-app/MarkEdit-preview/sessions/fd3c45a9-39c8-4dcd-995d-78325ff7b444 Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
gpolitis
reviewed
Mar 29, 2026
Co-authored-by: George Politis <georgios.politis@icloud.com>
../ relative links in preview mode via native file API
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts preview-mode link handling so relative links that start with ../ open the corresponding file via MarkEdit’s native file APIs instead of being resolved against http://localhost/.
Changes:
- Import
joinPathsand add preview-pane click delegation for../links insetUp(). - Add
handleExternalFiles()to resolve../hrefs againstMarkEdit.getFileInfo().parentPathand open viaMarkEdit.openFile().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
24a8b65 to
27d658d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
27d658d to
b9fd3ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Links starting with
../like[Title](../assets/image.png)resolve againsthttp://localhost/in preview mode, so..segments are silently dropped and clicks become no-ops.src/view.ts: Click event delegation on the preview pane intercepts<a>clicks whosehrefstarts with../, resolves againstMarkEdit.getFileInfo().parentPath, and opens viaMarkEdit.openFile()The handler uses
getAttribute('href')(not.href) to preserve the raw relative path, and only callspreventDefault()andstopPropagation()after confirming a valid parent path is available — so the browser default still applies when the native API isn't present or returns no valid path. The scope is intentionally limited to../links only.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.