From 0dd8cf892a2a0f433fd0c8224bff1dfeb48f6950 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Sat, 3 Feb 2018 12:52:17 +0100 Subject: [PATCH] added tag autocompletion --- in-note-text-tagging/in-note-text-tagging.qml | 16 ++++++++++++++++ in-note-text-tagging/info.json | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/in-note-text-tagging/in-note-text-tagging.qml b/in-note-text-tagging/in-note-text-tagging.qml index 765cba8..c2b396d 100644 --- a/in-note-text-tagging/in-note-text-tagging.qml +++ b/in-note-text-tagging/in-note-text-tagging.qml @@ -155,4 +155,20 @@ Script { function escapeRegExp(str) { return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } + + /** + * Hook to feed the autocompletion with tags if the current word starts with the tag marker + */ + function autocompletionHook() { + // get the current word plus non-word-characters before the word to also get the tag marker + var word = script.noteTextEditCurrentWord(true); + + if (!word.startsWith(tagMarker)) { + return []; + } + + // cut the tag marker off of the string and do a substring search for tags + var tags = script.searchTagsByName(word.substr(tagMarker.length)); + return tags; + } } diff --git a/in-note-text-tagging/info.json b/in-note-text-tagging/info.json index bc8526d..f827878 100644 --- a/in-note-text-tagging/info.json +++ b/in-note-text-tagging/info.json @@ -4,7 +4,7 @@ "script": "in-note-text-tagging.qml", "authors": ["@pbek", "@Maboroshy"], "platforms": ["linux", "macos", "windows"], - "version": "0.0.5", + "version": "0.0.6", "minAppVersion": "17.09.9", - "description" : "With this script you can store your tags in your note-text. Use tags like @tag or @tag_one for 'tag one' inside your note-text to tag your notes. You can change '@' to something else in script settings.\n\nYou also are able to use the functionality of the QOwnNotes user-interface to tag with this tags inside your note texts, like for adding a tag to the current note as well as bulk operations for adding and removing tags to your note. If you rename a tag inside QOwnNotes the text-tags in your notes are also updated.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\nIf you install this script you will loose all links between notes and tags and instead your in-note tags will be used!\n\nThis functionality is still experimental!\nPlease report your experiences." + "description" : "With this script you can store your tags in your note-text. Use tags like @tag or @tag_one for 'tag one' inside your note-text to tag your notes. You can change '@' to something else in script settings.\n\nYou also are able to use the functionality of the QOwnNotes user-interface to tag with this tags inside your note texts, like for adding a tag to the current note as well as bulk operations for adding and removing tags to your note. If you rename a tag inside QOwnNotes the text-tags in your notes are also updated.\n\nIf you start writing a tag you can also use the autocompleter to get a list of already existing tags.\n\nYou can also use this script as template for implementing your own, unique tagging mechanism.\n\nIf you install this script you will loose all links between notes and tags and instead your in-note tags will be used!\n\nThis functionality is still experimental!\nPlease report your experiences." }