diff --git a/text2tag/info.json b/text2tag/info.json new file mode 100644 index 0000000..d034dfe --- /dev/null +++ b/text2tag/info.json @@ -0,0 +1,16 @@ +{ + "name": "Text2tag", + "identifier": "text2tag", + "script": "text2tag.qml", + "authors": [ + "@Glin76" + ], + "platforms": [ + "linux", + "macos", + "windows" + ], + "version": "0.0.1", + "minAppVersion": "25.05.3", + "description": "This script creates a menu item and a button that adds a tag with the selected text to the current note." +} \ No newline at end of file diff --git a/text2tag/text2tag.qml b/text2tag/text2tag.qml new file mode 100644 index 0000000..25dcf54 --- /dev/null +++ b/text2tag/text2tag.qml @@ -0,0 +1,29 @@ +import QtQml 2.0 + +/** + * This script creates a menu item and a button that adds a tag with the selected text to the current note + */ +QtObject { + + function init() { + // create the menu entry + script.registerCustomAction("Text2tag", "Create tag with selected text", "Text 2 tag", "bookmark-new", true, false, true); + } + + function customActionInvoked(identifier) { + switch (identifier) { + case "Text2tag": + var tag = script.getTagByNameBreadcrumbList(script.noteTextEditSelectedText()); + var AlreadyTagged = false; + for (var idx in tag.notes) { + if (tag.notes[idx].id == script.currentNote().id) { + AlreadyTagged = true; + } + } + if (!AlreadyTagged) { + script.tagCurrentNote(script.noteTextEditSelectedText()); + } + break; + } + } +}