Skip to content

fix(markdown): preview local/relative images in .md files - #292

Merged
Menghuan1918 merged 2 commits into
omdsh-dev:mainfrom
huzilin:fix/markdown-preview-local-images
Aug 23, 2026
Merged

fix(markdown): preview local/relative images in .md files#292
Menghuan1918 merged 2 commits into
omdsh-dev:mainfrom
huzilin:fix/markdown-preview-local-images

Conversation

@huzilin

@huzilin huzilin commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

The shared MarkdownText only renders absolute http(s) images (relative links are disabled for chat security), so a local image referenced by a previewed markdown file - alt, an absolute /cwd/img.png, or a reference definition - showed only its alt text.

Rewrite such destinations into absolute /sidebar/file media URLs (with the GUI origin prefix) so MarkdownText accepts them and the host media route serves the bytes (still restricted to the session cwd). The rewriter is a dependency-free pure helper (markdown-images.ts) with a focused unit spec; TextEditor passes the rewritten preview text to both the plain MarkdownText and the mermaid-lazy preview.

huzilin and others added 2 commits August 21, 2026 13:40
The shared MarkdownText only renders absolute http(s) images (relative
links are disabled for chat security), so a local image referenced by a
previewed markdown file - ![alt](./img.png), an absolute /cwd/img.png,
or a reference definition - showed only its alt text.

Rewrite such destinations into absolute /sidebar/file media URLs (with
the GUI origin prefix) so MarkdownText accepts them and the host media
route serves the bytes (still restricted to the session cwd). The
rewriter is a dependency-free pure helper (markdown-images.ts) with a
focused unit spec; TextEditor passes the rewritten preview text to both
the plain MarkdownText and the mermaid-lazy preview.
@HuanLinOTO HuanLinOTO added bug Something isn't working P2 中:一般功能/优化 area/editor File editor + preview (markdown / HTML / code / mermaid) labels Aug 23, 2026
@Menghuan1918
Menghuan1918 merged commit 8f4d58d into omdsh-dev:main Aug 23, 2026
Menghuan1918 added a commit that referenced this pull request Aug 24, 2026
- README / README_EN: add v0.16.0 changelog (free windows #354, model-driven
  sidebar opens #353, Markdown inline HTML + TOC #360, 19-language overlays
  #339, multi-repo git + linked worktrees #326/#285, browser loopback
  allowlist, Vue + 28 legacy languages #202, preview refresh trio #215/#228,
  local Markdown images #292, ego-browser catalog #340; fixes: market/cordis
  #338, ctx.get() reads #357, workspace boundary #345, panel-host layering
  #330/#278, layout-push hardening #310/#130/#180, width sharing #36, terminal
  cleanup #130, fs-search noise dirs #342, mermaid #341, Nerd Font #190,
  UTF-8 HTML #193, trust-fence #182, reveal-in-explorer #94, PowerShell #47,
  GET probe fallback #69, unrun devDep #336) and move v0.15.2 into history
- feature tour: free windows + Markdown inline HTML/TOC (EN), feature list
- plugin ecosystem: add ego-browser (24 tab plugins), install pin ^0.16.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/editor File editor + preview (markdown / HTML / code / mermaid) bug Something isn't working P2 中:一般功能/优化

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants