silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Plug idea: Side page

Open zefhemel opened this issue 3 years ago • 9 comments

Allow an arbitrary page to be used in the left, or right hand side that persists when navigating through your space. Effectively allowing you to create a content menu.

Basically this can do exactly what the markdown preview RHS does right now, except it shouldn't update based on the currently open page. And probably should default to the left-hand side panel.

Page should be configurable, eg. Via a sidePage setting.

zefhemel avatar Dec 28 '22 10:12 zefhemel

Is this by any chance still open? I'm interested in taking a crack at it; I might need some guidance on how to integrate a sidePage setting but I have a decent idea as to how to start with the rest.

arekouzounian avatar Jan 08 '23 07:01 arekouzounian

Yep, go ahead!

zefhemel avatar Jan 08 '23 07:01 zefhemel

Here's an example of how to read a setting from the SETTINGS page: https://github.com/silverbulletmd/silverbullet-mattermost/blob/7e5f9069fdd2194bd98eae30eb973a758c92d118/util.ts#L52

zefhemel avatar Jan 08 '23 07:01 zefhemel

This is neat. An ideal might be like Obsidian's side panes, where you can have table of contents, file list, and other panes as well as just displaying files as you suggest, with a way to select which one or ones you want displayed at once. I know that's a lot bigger than you were suggesting here, though.

ryanwwest avatar Jun 17 '23 06:06 ryanwwest

I'm taking a crack at this, fixed a half-implemented previewOnRHS setting in the meantime: Maarrk/silverbullet@dac7432f341ea6d41cdef24f6331bf820e755b64

Maarrk avatar Feb 16 '24 14:02 Maarrk

I tried reusing the Markdown preview code for a page defined in SETTINGS, instead of the current one. Seemed the simplest way to get something into rhs or lhs in layout. My thoughts on it:

  • It's just ugly, since the fonts and other elements don't match. Especially hr with --- was doing strange things
  • Impressively, buttons and links work as they should
  • ~~Queries don't refresh until you visit the side page, would be nice to have the refresh button here~~ EDIT: Seems to update when I navigate to any other page, I'm not sure about this one

Do you think that putting a read only editor there (like silverbullet.md) that can't have cursor moving through it (unlike silverbullet.md) would be a nice solution? That way everything looks familiar, but I don't know how feasible that'd be.

obraz

obraz

Maarrk avatar Feb 17 '24 12:02 Maarrk

In a previous version of live queries and templates I managed to style the iframe that it used then (that's no longer in use) very similarly to the rest of the editor. Let me find that commit and point you to it. I think you can hack this to reasonable level with just HTML and CSS.

zefhemel avatar Feb 17 '24 20:02 zefhemel

Ok found it: https://github.com/silverbulletmd/silverbullet/blob/a205178ff0a09f79aaa5cc2461a5bc324f2fc1c7/plugs/markdown/markdown_content_widget.ts

This is the old implementation of markdown widgets as iframes. They live inline, but effectively it's the same thing as using them in lhs or rhs panels. They were visually hard to distinguish from the code editor itself, so I think that makes sense to use here too.

They are styled with https://github.com/silverbulletmd/silverbullet/blob/a205178ff0a09f79aaa5cc2461a5bc324f2fc1c7/plugs/markdown/assets/markdown_widget.css and behaviors were mimicked with https://github.com/silverbulletmd/silverbullet/blob/a205178ff0a09f79aaa5cc2461a5bc324f2fc1c7/plugs/markdown/assets/markdown_widget.js

I hope that helps

zefhemel avatar Feb 17 '24 20:02 zefhemel

Ah. That's not immediately obvious here, but in addition to this custom CSS. You also need to load SB's own main css file in the iframe: /.client/main.css

zefhemel avatar Feb 17 '24 20:02 zefhemel