Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions autocomplete-note-names/autocomplete-note-names.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import QtQml 2.0
import QOwnNotesTypes 1.0

Script {
function autocompletionHook() {
// get the current word plus non-word-characters before the word to also get the "[<"-character
var word = script.noteTextEditCurrentWord(true);

var noteSubFolderQmlObj = Qt.createQmlObject("import QOwnNotesTypes 1.0; NoteSubFolder{}", mainWindow, "noteSubFolder");
var noteSubFolder = noteSubFolderQmlObj.activeNoteSubFolder();

if (!word.startsWith("[<") || !noteSubFolder || !noteSubFolder.notes) {
return [];
}
// cut the "[>]" off of the string and do a substring search for notes
var searchString = word.slice(2,-1).trim();

// array holds the matching names
var matchedNotes = [];

for(var i in noteSubFolder.notes){
var note = noteSubFolder.notes[i];
if(note.name.toLowerCase().startsWith(searchString.toLowerCase())){
matchedNotes.push(note.name);
}
}
return matchedNotes;
}

}
10 changes: 10 additions & 0 deletions autocomplete-note-names/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Autocomplete Note Names",
"identifier": "autocomplete-note-names",
"script": "autocomplete-note-names.qml",
"authors": ["@pi55man"],
"platforms": ["linux", "macos", "windows"],
"version": "1.0.0",
"minAppVersion": "17.06.2",
"description" : "This script provides autocompletion for note names in QOwnNotes."
}
Loading