Skip to content

Panels - strings to elements - #1819

Merged
zefhemel merged 2 commits into
silverbulletmd:mainfrom
onespaceman:panels
Mar 6, 2026
Merged

Panels - strings to elements#1819
zefhemel merged 2 commits into
silverbulletmd:mainfrom
onespaceman:panels

Conversation

@onespaceman

Copy link
Copy Markdown
Contributor

This does work, but is a breaking change. It returns a shadow dom instead of an iframe, allowing to pass elements with their own attached methods/onclicks.
I tried to make it backwards compatible but wasn't able to.

  1. I could re-implemented the events and listeners for syscalls like in the iframe, but this exposes the syscall function globally.
  2. I tried returning an iframe or shadow dom based on if a string or element was passed. This kind of worked, but opening panels of one kind after the other causes errors. I don't understand react and useRef enough to fix this.

Idk where to go from here. If you or someone more knowledgeable could fix it, that would be great, otherwise feel free to reject this.

A simple example to see it in action:

command.define {
  name = "Test Panel: Open",
  run = function()
    local link = dom.p {
      "Link to Index",
      onclick = function() editor.navigate("index", false, false) end
    }
    local cmd = dom.p {
      "Open Command Palette",
      onclick = function() editor.openCommandPalette() end
    }
  
    local div = dom.div {
      id = "test-panel",
      link,
      cmd,
    }
    
    editor.showPanel("lhs", 0.8, div)
  end
}

@zefhemel

zefhemel commented Feb 8, 2026

Copy link
Copy Markdown
Collaborator

I'd really like to try to keep existing APIs stable and not regress. So how about another angle, what if I ask you to design a new API "from scratch" so without having to worry what's already there. We can have it be available in parallel and slowly deprecate the old one (maybe). What would it look like? Maybe it doesn't rely on iframes at all, for instance? What are the use cases?

@onespaceman

Copy link
Copy Markdown
Contributor Author

After a nice break, was able to come back and fix it! Tested it with the treeview panel and Document explorer and no errors, this time!

@zefhemel

zefhemel commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Ok, so is this still in draft then?

@onespaceman
onespaceman marked this pull request as ready for review March 5, 2026 17:16
@onespaceman

Copy link
Copy Markdown
Contributor Author

oops, forgot I can mark it ready.

@zefhemel
zefhemel merged commit c75f48d into silverbulletmd:main Mar 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants