How to remove UI element & onClick attribute is missing

Hi there,

I have a need to have password protected pages on Logseq desktop app. I do know that those actual page files can be accessed directly from the filesystem and this feature is not really much of a protection layer against the data in the file.

This is useful for me so that when I’m doing a screensharing or showing something to some on my machine, those pages will be locked and the content would not be showing if I accidentally clicked it or something.

That brought me to developing a plugin and need some help:

  1. I can inject UI element by using logseq.provideStyle and logseq.provideUI, however is there a way to remove them? I found a hack:
  key: key,
  path: path,
  template: ``,

Providing an empty template will remove the element. Just checking if there is any ‘ideal’ way of remove an DOM element? It feels like I’m doing something stupid here, lol.

  1. Using logseq.provideUI, I’m trying to include onClick attribute:
            key: key,
            path: path,
            template: `
              <button onClick="myFunction()" style="bla bla bla">
                <i class="gg-lock"></i>

When I load the page with the button element, for some reason onClick="myFunction()" is not being included. Am I missing out on something here?

Thank you very much in advance! :heart:

For your 2nd question, you need to define your function in provideModel, and use data-on-click attribute to bind your function.

Check out ILSPluginUser | @logseq/libs

1 Like

Thanks, I will try that! :slight_smile: