import QtQml 2.0 import QOwnNotesTypes 1.0 /** * This script is a generic example of some functions that will be called by QOwnNotes */ QtObject { /** * This is called when the script is loaded by QOwnNotes */ function init() { script.log("Script init"); } /** * This function is called when a note gets stored to disk * You cannot modify stored notes, that would be a mess since * you are most likely editing them by hand at the same time * * @param {Note} note - the note object of the stored note */ function onNoteStored(note) { script.log("fileName was stored!"); script.log(note.id); script.log(note.name); script.log(note.fileName); // tagNames() returns a list of all tag names var tagNameList = note.tagNames(); script.log(tagNameList); } /** * This function is called when a note gets stored to disk if * "Allow note file name to be different from headline" is enabled * in the settings * * It allows you to modify the name of the note file * Return an empty string if the file name of the note should * not be modified * * @param {Note} note - the note object of the stored note * @return {string} the file name of the note */ function handleNoteTextFileNameHook(note) { script.log(note.id); script.log(note.name); script.log(note.fileName); // tagNames() returns a list of all tag names var tagNameList = note.tagNames(); script.log(tagNameList); // don't actually change anything return ""; } /** * This function is called when the note name is determined for a note * * It allows you to modify the name of the note that is viewed * * Return an empty string if the name of the note should not be modified * * @param {NoteApi} note - the note object of the stored note * @return {string} the name of the note */ function handleNoteNameHook(note) { return note.name + " some text"; } /** * This function is called when the markdown html of a note is generated * * It allows you to modify this html * This is for example called before by the note preview * * @param {Note} note - the note object * @param {string} html - the html that is about to being rendered * @param {string} forExport - true if the html is used for an export, false for the preview * @return {string} the modified html or an empty string if nothing should be modified */ function noteToMarkdownHtmlHook(note, html, forExport) { script.log("noteToMarkdownHtmlHook was called"); // show a custom headline and a horizontal ruler on top of the preview return html.replace("body>", "body>