1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-30 23:44:55 +02:00

Plugins: Added joplin.workspace.selectedFolder()

This commit is contained in:
Laurent Cozic
2021-01-04 16:49:59 +00:00
parent 794fb6a122
commit b5fc206202
2 changed files with 41 additions and 0 deletions

View File

@ -1,5 +1,7 @@
import { ModelType } from '../../../BaseModel';
import eventManager from '../../../eventManager';
import Setting from '../../../models/Setting';
import { FolderEntity } from '../../database/types';
import makeListener from '../utils/makeListener';
import { Disposable } from './types';
@ -8,6 +10,11 @@ import { Disposable } from './types';
*/
const Note = require('../../../models/Note');
/**
* @ignore
*/
const Folder = require('../../../models/Folder');
enum ItemChangeEventType {
Create = 1,
Update = 2,
@ -114,6 +121,17 @@ export default class JoplinWorkspace {
return Note.load(noteIds[0]);
}
/**
* Gets the currently selected folder. In some cases, for example during
* search or when viewing a tag, no folder is actually selected in the user
* interface. In that case, that function would return the last selected
* folder.
*/
public async selectedFolder(): Promise<FolderEntity> {
const folderId = Setting.value('activeFolderId');
return folderId ? await Folder.load(folderId) : null;
}
/**
* Gets the IDs of the selected notes (can be zero, one, or many). Use the data API to retrieve information about these notes.
*/