logseq / plugins

Documentation site of Logseq plugins
https://plugins-doc.logseq.com/
21 stars 4 forks source link

🧩 logseq.App.registerUIItem #25

Open utterances-bot opened 4 months ago

utterances-bot commented 4 months ago

https://plugins-doc.logseq.com/logseq/App/registerUIItem

YU000jp commented 4 months ago

Kit for making a toolbar button


const keyButton =  "UniqueKeyHere"  // Creating a unique key for the button

// Create a button
logseq.App.registerUIItem('toolbar', {
  key: keyButton,
  template: `
<div>
  <a class="button icon" data-on-click="${keyButton}" id="${keyButton}" style="font-size: 16px" title="Tooltip comment here">🏳️‍🌈</a>
</div>
    `,
})

// Event
logseq.provideModel({
  [keyButton]: () => eventA(),
})

const eventA = () => {
  //Process when button is pressed here

}