Skip to content

What is the correct way of adding a menu without having separate .ts files? #165

Answered by yuanqing
lorenzwoehr asked this question in Q&A
Discussion options

You must be logged in to vote

add several commands to the plugin menu, which call different functions in main.ts

Instead of only using the default export for all the commands, you can specify a particular named export for each command instead. For example:

"menu": [
  {
    "name": "Command 1",
    "main": {
      "src": "src/main.ts",
      "handler": "commandOne"
    },
    "ui": "src/ui.tsx"
  },
  "-",
  {
    "name": "Command 2",
    "main": {
      "src": "src/main.ts",
      "handler": "commandTwo"
    },
    "ui": "src/ui.tsx"
  }
]

Your src/main.ts can then be something like:

export function commandOne () {
  // ...
}

export function commandTwo () {
  // ...
}

When I'm trying to add the following directly…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yuanqing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants