Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead

Home Page:https://Enter-tainer.github.io/typst-preview/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Links to local files do not open properly in slide mode

ntjess opened this issue · comments

Describe the bug
#link("./path/to/file")[text] should provide a hyperlink to a local resource. This works in PDF and SVG outputs. However, slide mode previews just open a new copy of the slide deck instead of the linked resource

To Reproduce

  1. Add a relative link to a local file (a mp4 video in my case)
  2. Specify "preview in browser and slide mode"
  3. Click the link
  4. You will be redirected to a new browser tab showing the slide deck, not your local resource

I just confirm this. This is because the target of the link is ./path/to/file, so the browser jumps to 127.0.0.1:some_port/path/to/file. And we jump to / for all unknown path, so another preview tab is opened.

// jump to /

But i think this can be hard to fix. And links in official typst-cli's svg is not clickable.

The webview is likely to never have access to the filesystem, because the browser disallows you to do that. We can forward file resources with authorization from preview server, tho.

It may still beyond the design of typst, which is probably broken by future typst. Regard to that, should we discuss it in scope of typst instead of in scope of typst-preview?

To avoid webview indirectly accessing to filesystem, you can embed the video by reading content by read first.

#let video = read("./video.mp4");
#let svg-to-embed = embed-video(video);

A note to future readers, you will need to specify encoding: none and ensure the video is very short. Even a 1MB will cause the extension to hang for a long time (at least in my case)