Enhancements to clojure code eval-result

Two small enhancements that could make evaluated code blocks more useful:

feat: Enhance sci eval-string and clojure code eval-result by darwis059 · Pull Request #7287 · logseq/logseq · GitHub opens the ability to create buttons that call the Logseq API, which is awesome. It would be even more awesome if:

  1. There was a way to hide the code, so you could create UI elements without having to look at the source code for them. For instance, perhaps the results appear above the code with the option to hide the code by collapsing it.
  2. Support select elements. This would allow creating dynamic queries that can be parameterized using user selections. Currently, a select element created using Hiccup won’t work because clicking on it will enter edit mode for the code block.


^:hiccup [:select [:option "one"] [:option "two"]]

Try interacting with the select and you will instead enter edit mode.

Generally when I want to hide something I add an hashtag to a block lile #hide-something and then I hide some elements with CSS for blocks that contain that hashtags.

Seems like a valid option for hiding the code, I’ll give it a shot.

As a more general issue, it seems that clicking anywhere in the results area enters edit mode for the block. In addition to precluding select elements, this also prevents selecting and copying clojure-eval results and isn’t particularly helpful since there are better ways to enter edit mode for a code fence.

Maybe you could ask Darwis (the author of the patch you linked)? I may be wrong but I remember a discussion about this on Discord.