sawhney17 / logseq-smartblocks

MIT License
171 stars 12 forks source link

Created button doesn't do anything #31

Closed MrPip914 closed 1 year ago

MrPip914 commented 1 year ago

I just downloaded the smartblocks plugin (version 3.4.1) to try it out. After creating a smartblock button using the Create SmartBlock Button command, the created button doesn't do anything. I filled out the Insert Smarkblock modal: image which resulted in the block {{renderer :smartblock, undefined, TestButton, false}}. I'm guessing that the "undefined" value is supposed to be my template. I tired manually entering the template and did see some green popups in the upper right of logseq after clicking the button (suggesting that it did something) but I still don't get my template. Also, a minute or so after seeing these green popups, my logseq threw an error telling me I needed to reindex.

sawhney17 commented 1 year ago

Try change replace undefined with testTemplate. What does your template look like?

MrPip914 commented 1 year ago

Thanks for the response!

Before testing again, I updated the plugin to version 3.4.4. Now when I create the smartblock button (without making any other changes from the previous test) I get the following text: {{renderer :smartblock, TestTemplate, TestButton, false}}. So it appears that an update has had some effect on the behavior. Now when I click the button using the same template as before I see the green popups but still nothing under the button.

My original template was a single block with multiple lines:

        - This is a test block
          template:: TestTemplate
          second line
          Some other content

When I use the template command with this template I get the following:

- This is a test block
  second line
  Some other content

I just tried playing around with other templates and have had some success. Specifically, if I create a template that includes child blocks the smartblock button will populate the child blocks. For example, using the button {{renderer :smartblock, TestTemplate2, TestButton, false}} works with the below template:

        - TestTemplate2
          template:: TestTemplate2
            - This is a block
            - This is a second block
            - This is a third block

This results in the below text (note - I've included the button text just for clarity on where the text appeared relative to the button)

- {{renderer :smartblock, TestTemplate2, TestButton, false}}
    - This is a block
    - This is a second block
    - This is a third block

Note that the button did not include the parent block. However, if I use the same template using the built-in template command I get the following:

- TestTemplate2
    - This is a block
    - This is a second block
    - This is a third block

I hope this helps in future improvements. Now that I understand the button is working and simply ignoring the parent block I'm sure I can figure out how to bring it into my workflows. I was just thrown off by the button not working the same as the template command and the 'undefined' attribute when first created. Thank you for your work on the plugin - I'm looking forward to using it now that I understand how it works!