fix(editor): let live preview resolve link targets through the host app#560
Conversation
|
@jian45154 is attempting to deploy a commit to the murongg's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
murongg
left a comment
There was a problem hiding this comment.
Thanks for the fix — local attachment links now render correctly in the regular live preview. There is one remaining rendering path that needs the same resolver before this is complete.
Visual table cells use the separate renderInlineMarkdown path. That renderer still hardcodes resolveSafeLinkTarget, while renderVisualTableCell only forwards the image resolver. As a result, the same link still loses its anchor semantics inside a visual table:
| Attachment |
| --- |
| [Reference.pdf](FILE:///mock-files/Reference.pdf) |I reproduced this with a focused table test using tablePreviewPlugin({ links: { resolveTarget } }): expected A, received SPAN.
Please pass the link resolver through InlineMarkdownRenderOptions and the table rendering path, including the current editor state/view context, and add a regression test for a custom-resolved link inside a visual table cell.
Non-blocking: the global asyncUtilTimeout / testTimeout increase is unrelated to the link fix and would be easier to evaluate as a separate PR (or can be dropped here).
77365d7 to
fe313cb
Compare
Live preview and visual table cells hardcoded resolveSafeLinkTarget when deciding whether a link renders as an anchor, so local attachment links (FILE://) imported via Import Local Files lost their href after the CodeMirror migration. - Add an optional resolveLinkTarget hook to LivePreviewConfig, mirroring linksPlugin.resolveTarget and imagePreviewPlugin.resolveSource, and pass the existing app resolver from CodeMirrorPaperSurface. - Add resolveLinkTarget to InlineMarkdownRenderOptions and forward the tablePreviewPlugin links resolver with editor state/view context from renderVisualTableCell, matching the image resolver plumbing. - Align the image source editing app test with the CodeMirror widget UX; its old expectations described removed Milkdown behavior. - Test infra: raise asyncUtilTimeout/testTimeout in @markra/app and clear the shared jsdom selection between tests, fixing order-dependent selection collapses and slow-machine timeout flakes. Fixes markrahq#559 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fe313cb to
e8aed0c
Compare
Fixes #559
What
Local attachment links (
FILE://) lost their<a href>rendering in live preview after the Milkdown → CodeMirror migration:buildDecorationsinpreview.tshardcodedresolveSafeLinkTarget, so onlyhttp/https/mailto/teland scheme-less targets could render as anchors, with no way for the host app to allow its local-attachment scheme.resolveLinkTargethook toLivePreviewConfig(mirrorslinksPlugin.resolveTargetandimagePreviewPlugin.resolveSource, including the try/catch + trim semantics ofresolvedLinkSource). Default behavior is unchanged when the hook is not provided.CodeMirrorPaperSurfaceso imported attachments render as anchors again.clears finalized image source editingapp test with the current CodeMirror widget UX (preview stays visible, inline source row opens); its old expectations described removed Milkdown behavior and always failed.asyncUtilTimeoutto 5s andtestTimeoutto 15s in@markra/app— on slower machines the 1s/5s defaults produced rotating timeout flakes across the suite. Feel free to drop this commit if you prefer.Why it went unnoticed
ci.ymlonly triggers onmain, so pushes tov2never ran the frontend suite. TwoApp.test.tsxtests covering this behavior fail deterministically onv2:imports local attachments into an unsaved document when external files are not copiedclears finalized image source editing when document search opens(The pre-existing
typecheck:testfailure inpackages/editor/src/codemirror/ai-preview.test.tsonv2is unrelated and left untouched.)Verification
@markra/editortests: 245 passed (adds 2 focused tests for the new hook: resolver-allowed target renders an anchor, resolver-rejected target renders a plain span).@markra/apptests: 1357 passed, including the two previously failing tests.pnpm buildpasses.🤖 Generated with Claude Code