Skip to content
Discussion options

You must be logged in to vote

If you want to include a note in trilium using javascript it's pretty simple (but it's not explained in the API) :

First, you must get a CKEditor instance of your texte note :

const editor = await api.getActiveContextTextEditor()

Then you can use this code to insert the box automatically. Obviously, you have to determine the id of the note to be inserted beforehand, but it is quite easy.

 editor.model.change(writer => {
                const includedNote = writer.createElement('includeNote', {
                noteId: noteToInsertId,
                boxSize: "medium"
            })
            editor.model.insertContent(includedNote);
            })
            }

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sigaloid
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

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