Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links to local files do not open properly in slide mode #258

Open
ntjess opened this issue Feb 26, 2024 · 4 comments
Open

Links to local files do not open properly in slide mode #258

ntjess opened this issue Feb 26, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@ntjess
Copy link

ntjess commented Feb 26, 2024

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
@Enter-tainer
Copy link
Owner

Enter-tainer commented Feb 26, 2024

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.

@Myriad-Dreamin
Copy link
Collaborator

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?

@Myriad-Dreamin
Copy link
Collaborator

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);

@ntjess
Copy link
Author

ntjess commented Feb 26, 2024

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)

@Myriad-Dreamin Myriad-Dreamin added the enhancement New feature or request label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants