Skip to content

Code reuse in Trilium! #4266

Answered by zerebos
sottey asked this question in General
Discussion options

You must be logged in to vote

There's several different ways you could go about something like this. Some other easy alternatives:

  • Creating a script with the src having the pattern api/notes/{noteId}/open which will "remotely" link that script
  • Exposing an api on the window object from a central script and just calling specific functions in the local script
  • Similarly, use custom events on the window so one script listens for window.addEventListener("my-event") and another triggers window.dispatchEvent("my-event")
  • Similar to what you've already done, but use the note ids to read the script contents and eval them (or more preferably an indirect eval)

And something that takes a little more setup but is my personal prefe…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sottey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants