Replies: 2 comments 8 replies
-
Hi, nice work!
I would recommend you to implement the rendering as a widget instead of "render note", that way you can have both editor and render part visible at the same time (at this point the pane can be only horizontally split though). Check out "word count" widget from demo document which does most things you need: And some docs: https://github.com/zadam/trilium/wiki/Custom-Widget |
Beta Was this translation helpful? Give feedback.
-
One thing I encoutered is that it turned mermaid is not included in Trilium ( I though it was). I might accednetly included it by uploading the mermaid js file before. But after a while I got the error said mermaid is undefined alert. Then I cannot get it work again as I try to upload mermaid js as the subnote of the JS note. But it seems does not work. I try to follow the weight tracker example (which includes chartjs) But the mermiad wasn't loaded anymore. So finally I have to put the <script src="../> in the renderer nodte |
Beta Was this translation helpful? Give feedback.
-
Trilium is really awesome, endless note-taking searching, finally I think it is the end.
Especially for developers so we could easily extend by scripting.
With render note, basically, we could extend any note type by writing our renderer note to render the note in the way we want.
For example, currently, I don't see official support for a mermaid (https://mermaid-js.github.io/) but interesting I found Trilium already embed the mermaid library in the browser's context, which many people ask for it.
To 日chieve this, I start to think we could have a mermaid renderer note (HTML and js implementation) and I put the mermaid markup code to Render Note's text content. In the renderer note, we could use api.originEntity to fetch the mermaid markup and inject it into the renderer's HTML body.
And it is perfectly it works as I thought.
One thing is that I don't know how or it should be a feature request.
The problem now is if I want to update the diagram, I need to switch the note type between "Type: Plain Text" and "Type: Render Note".
I would like to have editor pane and rendered pane at the same time, (very similar to lots of markdown editor, one side is source code and another side is a preview) so It is totally useful the render note will update as I edit the content.
more detail about the template:
I create a template for Mermaid note basically it just set the default attribute " ~renderNote=mermaid renderer" for me:
In the renderer, HTML part just a #here DIV so we could inject the markup later
UPDATE: Turns out mermaid lib not included by default. Quick fix to include it by script tag here:
The script part, to use api.originEntity.getContent() to fetch the mermaid markup and put it into the #here DIV and run mermai API to render the DIV
Beta Was this translation helpful? Give feedback.
All reactions