Skip to content

Commit f0f3d78

Browse files
authored
Add script text2tag (#267)
* Add files via upload * new JSON file * Delete text2tag/text2tag.json * Delete text2tag/text2tag.qml * correction of text2tag.qml
1 parent df7c2e2 commit f0f3d78

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

text2tag/info.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "Text2tag",
3+
"identifier": "text2tag",
4+
"script": "text2tag.qml",
5+
"authors": [
6+
"@Glin76"
7+
],
8+
"platforms": [
9+
"linux",
10+
"macos",
11+
"windows"
12+
],
13+
"version": "0.0.1",
14+
"minAppVersion": "25.05.3",
15+
"description": "This script creates a menu item and a button that adds a tag with the selected text to the current note."
16+
}

text2tag/text2tag.qml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import QtQml 2.0
2+
3+
/**
4+
* This script creates a menu item and a button that adds a tag with the selected text to the current note
5+
*/
6+
QtObject {
7+
8+
function init() {
9+
// create the menu entry
10+
script.registerCustomAction("Text2tag", "Create tag with selected text", "Text 2 tag", "bookmark-new", true, false, true);
11+
}
12+
13+
function customActionInvoked(identifier) {
14+
switch (identifier) {
15+
case "Text2tag":
16+
var tag = script.getTagByNameBreadcrumbList(script.noteTextEditSelectedText());
17+
var AlreadyTagged = false;
18+
for (var idx in tag.notes) {
19+
if (tag.notes[idx].id == script.currentNote().id) {
20+
AlreadyTagged = true;
21+
}
22+
}
23+
if (!AlreadyTagged) {
24+
script.tagCurrentNote(script.noteTextEditSelectedText());
25+
}
26+
break;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)