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

Convert launching preview commands to a single unified command #224

Open
Myriad-Dreamin opened this issue Jan 16, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@Myriad-Dreamin
Copy link
Collaborator

Myriad-Dreamin commented Jan 16, 2024

Background: In my project, I can provide sys.inputs.at("target") to control the target of a document. When a target is set to "webpage", it is compiled and suitable for viewing in website. When a target is set to "ebook", it is compiled as a e-book PDF and suitable for viewing in online or offline pdf viewer.

To edit styles for document targeting to "webpage", I want to launch preview with sys.inputs arguments.


Currently there are four commands to launch preview.

  • open
  • open in browser
  • open with slide mode
  • open in browser with slide mode

As feature increased (e.g. sys.inputs), the matrix becomes larger and unmaintainable. So I want to convert the "open/launch" action into a single command. And create four corresponding auto-detected tasks to replace these commands. The final effect should look like this:

image

We will have these auto detected tasks (also as a start-up task template):

  • open
  • open in browser
  • open with slide mode
  • open in browser with slide mode

And we can invoke a typst-preview.launch command in task:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "preview",
      "command": "${command:typst-preview.launch}",
      "args": {
        "openIn": "webview", // v.s. in browser
        "mode": "document", // v.s. slide mode
        "inputs": {
          "target": "webpage",
          "theme-setting": "themes/ayu.toml"
        }
      }
    }
  ]
}

All of arguments in typst-preview.launch are optional so we can also have a default command to launch without configuration or interactively.

And we can disable auto detected tasks as user preferences.

https://github.com/microsoft/vscode/blob/c7ea84b4f5e779a98e93bd1f48502d83403f16c3/extensions/gulp/src/main.ts#L140-L150

@Enter-tainer
Copy link
Owner

I think it is ok to have to add custom sys.inputs. For existing ones, I prefer keeping them instead of replacing them with tasks

@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

2 participants