Repository navigation
feat(mobile): open documents linked from a preview, with a back stack - #825
Merged
Merged
Conversation
A local-file link inside a previewed document was answered with "view it in
the desktop app", even though the phone can already open a local file from a
chat bubble. The refusal was deliberate once ("file previews never nest
previews"), but the machinery was already there: the same link in the chat
opens the target in place.
- `MarkdownText` resolves a link from a previewed document against that
document, reusing the resolver its images already use, and hands the
resolved path to the caller's preview flow. The notice stays for the one
case that genuinely cannot be resolved: a document opened from this phone's
own storage.
- Previews become a stack. The document that linked here stays mounted below
the top one, so the back control (and Android's hardware back) returns to
the same place in the same document. Layers are keyed by document per
visit, so A → B → A does not reuse B's rows.
- The overflow menu moves to the stack owner: a download, a stack change, or
a native dismissal all have to close it, and none of those reaches into a
layer.
- A link whose target needs an external reader closes the stack first, the
way the preview's own menu actions do: the action sheet is a second Modal
and iOS will not present it over the preview.
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.
What
A local-file link inside a previewed Markdown document was answered with "Markdown 预览中的本地文件链接请在桌面端查看。" (the alert in the screenshot). Now it opens, and the document that linked to it stays open underneath with a back control.
Why it was refused, and why that no longer holds
MarkdownText'smode="file-preview"branch blocked local links deliberately ("file previews never nest previews", #299). Everything needed to open the target already exists: the same link in a chat bubble goes throughopenFileLink, which handles the 10 MB limit, the type routing (image/markdown/text/JSON preview vs open/save/share), the progress Modal and the byte cache. What was missing was resolution and a place to come back to.Changes
markdownImagePath→resolveMarkdownPath). The old notice survives for the one unresolvable case: a document opened from this phone's own storage, where a relative path names nothing the desktop can read. That message is reworded to say so.useFileDownloadholdspreviews: PreviewState[];previewis the top.openFileLink(chat) replaces the stack,openLinkedFile(a link inside a document) pushes.popPreviewleaves one document;closePreviewleaves the reader.PreviewModalrenders every open document as its own absolutely-filled layer, top one interactive, the ones below mounted and untouched so their scroll position survives. Keys are per document per visit, so A → B → A gives the new A its own layer instead of reusing B's rows.Out of scope
The 10 MB and unknown-MIME limits are unchanged,
#anchorlinks stay inert, and desktop keeps rendering local links as inert text.Verification
npm run typecheck,npm run lint, and the full mobile Jest suite (125 suites / 1921 tests) in the worktree. New coverage: link resolution from inside a document (including the phone-local refusal), stack push/pop/replace, hardware back leaving one document at a time, layer key identity, and the menu rules.Not verified on a device or in the screenshot harness — no visual/gesture check of the new back control.