PlasmoHQ / plasmo

🧩 The Browser Extension Framework
https://www.plasmo.com
MIT License
10.29k stars 356 forks source link

[EXP] Example repo that uses commands #1078

Open ian opened 1 week ago

ian commented 1 week ago

What is the example you wish to see?

Have tried every which way to add commands to my project and nothing seems to work. It looks like the schema has support for it but nothing seems to bind in-app: https://github.com/PlasmoHQ/plasmo/blob/main/core/parcel-transformer-manifest/src/schema.ts#L146

Shouldn't it be as easy as adding commands to package.json manifest and then binding to them in background.ts?

package.json

"manifest": {
    "commands": {
      "open_side_panel_with_shortcut": {
        "suggested_key": {
          "mac": "MacCtrl+Shift+L",
          "windows": "Ctrl+Shift+L",
          "linux": "Ctrl+Shift+L"
        },
        "description": "Open Side Panel"
      }
    }
  }

background.ts

chrome.commands.onCommand.addListener((command) => {
  if (command === "open_side_panel_with_shortcut") {
    alert("open_side_panel_with_shortcut")
  }
})

Is it possible to expand out examples directory to include an example of how to use commands?

Is there any context that might help us understand?

No response

Code of Conduct