diff --git a/journal-entry/info.json b/journal-entry/info.json index 0b0c83b..e7a4c2d 100644 --- a/journal-entry/info.json +++ b/journal-entry/info.json @@ -2,8 +2,8 @@ "name": "Journal entry", "identifier": "journal-entry", "script": "journal-entry.qml", - "version": "0.0.2", + "version": "1.0.0", "minAppVersion": "17.05.6", - "authors": ["@pbek"], + "authors": ["@pbek", "@sanderboom"], "description" : "This script creates a menu item and a button to create or jump to the current date's journal entry." } diff --git a/journal-entry/journal-entry.qml b/journal-entry/journal-entry.qml index f3ed48e..b871547 100644 --- a/journal-entry/journal-entry.qml +++ b/journal-entry/journal-entry.qml @@ -5,6 +5,18 @@ import com.qownnotes.noteapi 1.0 * This script creates a menu item and a button to create or jump to the current date's journal entry */ QtObject { + property string defaultTags; + + property variant settingsVariables: [ + { + "identifier": "defaultTags", + "name": "Auto-tagging", + "description": "One or more default tags (separated by commas) to assign to a newly created journal note. Leave blank to disable auto-tagging.", + "type": "string", + "default": "journal", + }, + ]; + /** * Initializes the custom action */ @@ -15,7 +27,7 @@ QtObject { /** * This function is invoked when a custom action is triggered * in the menu or via button - * + * * @param identifier string the identifier defined in registerCustomAction */ function customActionInvoked(identifier) { @@ -29,7 +41,7 @@ QtObject { var fileName = headline + ".md"; var note = script.fetchNoteByFileName(fileName); - + // check if note was found if (note.id > 0) { // jump to the note if it was found @@ -40,6 +52,17 @@ QtObject { // keep in mind that the note will not be created instantly on the disk script.log("creating new journal entry: " + headline); script.createNote(headline + "\n================\n\n"); + + // Auto-tagging. + if (defaultTags && defaultTags !== '') { + defaultTags + // Split on 0..* ws, 1..* commas, 0..* ws. + .split(/\s*,+\s*/) + .forEach(function(i) { + script.log('Auto-tag new journal entry with: ' + i); + script.tagCurrentNote(i); + }); + } } } }