-
Notifications
You must be signed in to change notification settings - Fork 88
New script #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New script #268
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5a814bb
New script text2linq
Glin76 9f89282
Delete text2link/text2linq.qml
Glin76 34dcaa1
Add files via upload
Glin76 eccdf4f
Update info.json
Glin76 0e72fab
Update info.json
Glin76 b0e480b
Delete text2link/text2linq.qml
Glin76 e159cc8
Add files via upload
Glin76 f745240
Update info.json
Glin76 8dc681a
Update text2link.qml
Glin76 c466dc5
Adding a MessageBox showing stats
Glin76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "Text2link", | ||
| "identifier": "text2link", | ||
| "script": "text2link.qml", | ||
| "authors": [ | ||
| "@Glin76" | ||
| ], | ||
| "platforms": [ | ||
| "linux", | ||
| "macos", | ||
| "windows" | ||
| ], | ||
| "version": "0.0.1", | ||
| "minAppVersion": "25.05.3", | ||
| "description": "This script creates links to all notes containing the selected text at the end of the current note. Caution ! This script doesn't work with note-subfolders." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import QtQml 2.0 | ||
|
|
||
| /** | ||
| * This script creates links to all notes containing the selected text at the end of the current note. Caution ! This script doesn't work with note-subfolders. | ||
| */ | ||
| QtObject { | ||
|
|
||
| function init() { | ||
| // create the menu entry | ||
| script.registerCustomAction("Text2link", "Create links for all notes containing selected text", "Text 2 link", "bookmark-new", true, false, true); | ||
| } | ||
|
|
||
| function customActionInvoked(identifier) { | ||
| switch (identifier) { | ||
| case "Text2link": | ||
|
|
||
| var text = script.noteTextEditSelectedText(); | ||
| if (text == "") {break;} | ||
| var foundedNotes = -1; // Current note will not be counted | ||
| var addedLinks = 0; | ||
| var oldLinks = 0; | ||
| // loop for all notes containing the raw text | ||
| script.fetchNoteIdsByNoteTextPart(text).forEach(function (noteId) { | ||
| var note = script.fetchNoteById(noteId); | ||
| // first condition : text should be a complete word in the note | ||
| var reTest = RegExp("\\b"+text+"\\b","gi").exec(note.noteText); | ||
| // second condition : the note should not be already linked in this note | ||
| var link = "("+note.fileName+")"; | ||
| while (link.search(" ") > -1) { // need to loop for each space because .replace() only works once | ||
| link = link.replace(" ","%20") | ||
| } | ||
| var alreadyLinked = script.currentNote().noteText.search(link) | ||
| // third condition : the note should not be self | ||
| if (reTest != null & alreadyLinked == -1 & script.currentNote().id != noteId) { | ||
| script.noteTextEditSetCursorPosition(-1); // end of the this note | ||
| script.noteTextEditWrite("\n\n"+"["+note.name+"]"+link); // add a blank line and the link | ||
| addedLinks += 1; | ||
| } | ||
| if (reTest != null) { foundedNotes += 1;} | ||
| if (alreadyLinked > 0) { oldLinks += 1;} | ||
| }); | ||
| script.informationMessageBox(foundedNotes+" note(s) containing '"+text+"'\n"+oldLinks+" already linked\n"+addedLinks+" added", "Results"); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.