Pass in custom config for mermaid component to allow callback / click support #1906
Replies: 4 comments 4 replies
-
Sounds cool. Would you like to create a pull request? |
Beta Was this translation helpful? Give feedback.
-
It looks like my first PR was quite naive and flawed. On further investigation things are more complex than they at first seemed. The So: In order to insert the initialize before the first render, it appears that another parameter needs to be passed to the The first option "feels" incorrect - the Third option: I'm on completely on the wrong track... Any offers of help/info will be gratefully exploited. :) Ian B. |
Beta Was this translation helpful? Give feedback.
-
Hi Falko
It's probably me that's not understanding the architecture of nicegui -
hence my description doesn't make sense!
I clearly don't understand the interface between mermaid,py & mermaid.js
correctly.
My issue is that we need to call initialize before any content is rendered.
The content render is triggered in the __init__ of ContentElement with a
call to handle_content_change()
ContentElement only passes 'content' to the _handle_content_change()
function. Hence it appears to me that
we cannot pass a config dict as well.
However - it may be that I am missing the point & this;
> the config dictionary passed to initialize() could be configured via a
new parameter for ui.mermaid and a corresponding prop.
might be the point that I am missing ...
I'll have a look at this and see if I can get my head around it ...
rgds
Ian B
…On Sun, 2 Jun 2024 at 15:06, Falko Schindler ***@***.***> wrote:
Hm, I don't quite understand. The Vue component is only rendered after the
whole Python object has been instantiated, added to its parent container,
converted into JSON and sent to the client. Independent of the class
hierarchy in Python, the Vue component is only mounted once and I think we
can call initialize() within mounted() { ... }. And the config dictionary
passed to initialize() could be configured via a new parameter for
ui.mermaid and a corresponding prop.
—
Reply to this email directly, view it on GitHub
<#1906 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABULB5MDSMEI6E6LTGGUO43ZFMRFJAVCNFSM6AAAAAA6TKZFMOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TMMZYGM4TG>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
OK - After 3 more coffees, I think I see how the whole thing hangs
together.
I've created a (hopefully) much better PR - with some tests that ... test!
Listening out for feedback ...
Ian B
…On Sun, 2 Jun 2024 at 15:52, Ian Bottomley ***@***.***> wrote:
Hi Falko
It's probably me that's not understanding the architecture of nicegui -
hence my description doesn't make sense!
I clearly don't understand the interface between mermaid,py & mermaid.js
correctly.
My issue is that we need to call initialize before any content is rendered.
The content render is triggered in the __init__ of ContentElement with a
call to handle_content_change()
ContentElement only passes 'content' to the _handle_content_change()
function. Hence it appears to me that
we cannot pass a config dict as well.
However - it may be that I am missing the point & this;
>> the config dictionary passed to initialize() could be configured via a
new parameter for ui.mermaid and a corresponding prop.
might be the point that I am missing ...
I'll have a look at this and see if I can get my head around it ...
rgds
Ian B
On Sun, 2 Jun 2024 at 15:06, Falko Schindler ***@***.***>
wrote:
> Hm, I don't quite understand. The Vue component is only rendered after
> the whole Python object has been instantiated, added to its parent
> container, converted into JSON and sent to the client. Independent of the
> class hierarchy in Python, the Vue component is only mounted once and I
> think we can call initialize() within mounted() { ... }. And the config
> dictionary passed to initialize() could be configured via a new
> parameter for ui.mermaid and a corresponding prop.
>
> —
> Reply to this email directly, view it on GitHub
> <#1906 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABULB5MDSMEI6E6LTGGUO43ZFMRFJAVCNFSM6AAAAAA6TKZFMOVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TMMZYGM4TG>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It's possible in mermaid to define callback to enable rich user interaction with charts. This needs a config option passed in when mermaid is first initialized / run. NiceGui does not currently support passing in this (or any custom config) here.
Mermaid line that would need to change:
await mermaid.run({ nodes: [queue.shift()] });
This line would need to pass
securityLevel: loose
option.Security level config docs here.
Note it's possible to override most other config in in the diagram syntax alone, but no the security settings.
Beta Was this translation helpful? Give feedback.
All reactions