1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Desktop: Added Goto Anything dialog and implemented basic plugin system

This commit is contained in:
Laurent Cozic
2019-04-01 19:43:13 +00:00
parent db04906416
commit 6b2910c3c7
14 changed files with 1018 additions and 90 deletions

View File

@@ -7,7 +7,7 @@ const { Database } = require('lib/database.js');
const { _ } = require('lib/locale.js');
const moment = require('moment');
const BaseItem = require('lib/models/BaseItem.js');
const lodash = require('lodash');
const { substrWithEllipsis } = require('lib/string-utils.js');
class Folder extends BaseItem {
@@ -217,6 +217,34 @@ class Folder extends BaseItem {
return getNestedChildren(all, '');
}
static folderPath(folders, folderId) {
const idToFolders = {};
for (let i = 0; i < folders.length; i++) {
idToFolders[folders[i].id] = folders[i];
}
const path = [];
while (folderId) {
const folder = idToFolders[folderId];
if (!folder) break; // Shouldn't happen
path.push(folder);
folderId = folder.parent_id;
}
path.reverse();
return path;
}
static folderPathString(folders, folderId) {
const path = this.folderPath(folders, folderId);
const output = [];
for (let i = 0; i < path.length; i++) {
output.push(substrWithEllipsis(path[i].title, 0, 16));
}
return output.join(' / ');
}
static buildTree(folders) {
const idToFolders = {};
for (let i = 0; i < folders.length; i++) {

View File

@@ -90,9 +90,19 @@ class Tag extends BaseItem {
return !!r;
}
static tagsWithNotesSql_() {
return 'select distinct tags.id from tags left join note_tags nt on nt.tag_id = tags.id left join notes on notes.id = nt.note_id where notes.id IS NOT NULL';
}
static async allWithNotes() {
const tagIdSql = 'select distinct tags.id from tags left join note_tags nt on nt.tag_id = tags.id left join notes on notes.id = nt.note_id where notes.id IS NOT NULL';
return await Tag.modelSelectAll('SELECT * FROM tags WHERE id IN (' + tagIdSql + ')');
return await Tag.modelSelectAll('SELECT * FROM tags WHERE id IN (' + this.tagsWithNotesSql_() + ')');
}
static async searchAllWithNotes(options) {
if (!options) options = {};
if (!options.conditions) options.conditions = [];
options.conditions.push('id IN (' + this.tagsWithNotesSql_() + ')');
return this.search(options);
}
static async tagsByNoteId(noteId) {