kayvanbree / contexr

Stop redundantly defining your shortcuts in your shortcut library and your context menu. Start using Contexr!
MIT License
4 stars 0 forks source link

Passing arguments #7

Closed kayvanbree closed 5 years ago

kayvanbree commented 5 years ago

We should be able to pass arguments to a function somehow.

Maybe like this:

const context = [
  {
    text: 'Yellow square',
    context: ['item'],
    action: (itemNr: number, message: string) => {
      console.log(`Item nr ${itemNr} says: ${message}`);
    },
    hotkey: 'y'
  }
];

Then in the html we can loop through stuff and add ctx-args:

<ul>
   <li ctx="item" ctx-args="{itemNr: 1, message: 'Hello!'}">Item 1</li>
   <li ctx="item" ctx-args="{itemNr: 2, message: 'Good morning!'}">Item 1</li>
</ul>