It works great! (once I started to get the hang of it ) Thank you for the awesome work!
The only thing I find a bit inconvenient is that every macro needs itās own page. If I understand it right, they cannot even have their own namespace (like kits/macro1), because the entry function needs to have the same name as the page name, right? That means a lot of extra pages on my graph if I want many small macros.
Or maybe I am missing something, or understanding something wrong?
Thank you again for the great work!
Also thanks to @adxsoft for the demo graph (super helpful!) and to @dannylin108 for the question below which saved me quite a bit of headache )
1 Like
I will try it out. Thanks again!
Iāve noticed that from time to time, the buttons I have defined using your suggested code stop working. This seems to happen more often on my iPhone than on my Mac, but it does happen on both.
It only happens in an already-running Logseq instance, usually after itās been running for awhile, and after Iāve been doing other things on the device. Restarting Logseq always fixes the problem. Any idea what may be causing this, or how to diagnose and/or fix it?
I need something reproducible.
- What about re-running the macro?
- editing the block
- reopening the page
- Do you use multiple identical buttons?
- Do you have multiple buttons in the same block?
- Do you have buttons on the sidebar?
- Generally, anything suspicious that could lead to something reproducible.
Thanks. I was about to update my question, because I realized that Iām having two separate issues.
On the Mac, itās this one, specifically related to an updated version of my query and your MassDelete script. My other button continues to always work on the Mac.
So the issue with buttons in general stopping working is so far limited to the iPhone.
Iāll check this next time it happens on the iPhone
Not in the same page.
No
No (now that weāre just talking about the iPhone)
Iāll keep my eye out for anything reportable. Thereās no way I know of to access the console on the iPhone, so options are limited.
Is there a way to embed one of these macro buttons within HTML and have it run the JS on another page when clicked or create a slash command that can run the JS on another page?
When I paste this button tag within LogSeq, it runs when the button is rendered but not when I click on it. Is there a way to have it run only when clicked?
<button class='kit run' data-kit='JS/Hello World'>Click Me</button>
Edit: The below button setup only runs when clicked.
<button class='kit run' data-kit='runpage' data-page-name='JS/Hello World'>Hello World</button>
Iām still curious if thereās a way to run a page using a slash command instead of needing to click a button
1 Like
To run page JS/Hello World
:
- with a button, the provided way is
{{runpage JS/Hello World}}
- on demand without a button, consider using the console for something that calls
logseq.Module.Kits.runPageByName("JS/Hello World")
Using {{runpage JS/Hello World}} is a decent solution for what Iāve been doing. Many times, it requires accessing the ācurrent blockā, so using the console isnāt ideal - console also isnāt supported on mobile.
I was curious if there was a way to register a slash command through logseqās native API (which is different from the plugin API) to run a JS page. Having a slash command reduces the steps from adding the button and clicking on it to running the slash command.
Consider implementing a keyboard listener (e.g. like this one) that makes the above call, potentially reading any arguments (e.g. page name) from the textarea.
Thatās a neat idea on how to add a customizable keyboard shortcut; Iāll have to look into it.
Thanks for sharing!
I really like working with this paradigm, it allows me to be extensible with logseq in a very useful way. A quick question/suggestion I had was would it be possible to have the functionality that {{evalparent}}
has (in terms of displaying outputs and images) to the other macros
?
I made a quick expense tracker within logseq itself using basic queries, and used this to generate a graph through python. The code runs with all the options, but only {{evalparent}}
can display the outputs. Since the code is somewhat long, I wanted to move it to another file and run it using {{runpage mypage}}
setup, which runs the page, but the output is not passed on to where the button is. What is a good way to go about this?
Iāve come up with a few options (Iāve not implemented any, and I donāt know the full structure of the code yet, and Iām not sure what would be in line with the structure used here):
- Write the output to a file and link it under the
{{runpage ...}}
button in logseq
- Have someway to pipe the output of the code and implement the same thing
{{evalparent}}
has to other options
- Use the logseq api to write the image to a specific block
This works, its absolutely great! Thank you so much!