From 13feb30f3ff9b913670a5fe7c8a9c1907d2c1740 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Fri, 4 Jul 2025 12:03:11 -0500 Subject: Initial commit --- api/JoplinWorkspace.d.ts | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 api/JoplinWorkspace.d.ts (limited to 'api/JoplinWorkspace.d.ts') diff --git a/api/JoplinWorkspace.d.ts b/api/JoplinWorkspace.d.ts new file mode 100644 index 0000000..e13a96f --- /dev/null +++ b/api/JoplinWorkspace.d.ts @@ -0,0 +1,97 @@ +import Plugin from '../Plugin'; +import { FolderEntity } from '../../database/types'; +import { Disposable, EditContextMenuFilterObject, FilterHandler } from './types'; +declare enum ItemChangeEventType { + Create = 1, + Update = 2, + Delete = 3 +} +interface ItemChangeEvent { + id: string; + event: ItemChangeEventType; +} +interface ResourceChangeEvent { + id: string; +} +interface NoteContentChangeEvent { + note: any; +} +interface NoteSelectionChangeEvent { + value: string[]; +} +interface NoteAlarmTriggerEvent { + noteId: string; +} +interface SyncCompleteEvent { + withErrors: boolean; +} +type WorkspaceEventHandler = (event: EventType) => void; +type ItemChangeHandler = WorkspaceEventHandler; +type SyncStartHandler = () => void; +type ResourceChangeHandler = WorkspaceEventHandler; +/** + * The workspace service provides access to all the parts of Joplin that + * are being worked on - i.e. the currently selected notes or notebooks as + * well as various related events, such as when a new note is selected, or + * when the note content changes. + * + * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins) + */ +export default class JoplinWorkspace { + private store; + private plugin; + constructor(plugin: Plugin, store: any); + /** + * Called when a new note or notes are selected. + */ + onNoteSelectionChange(callback: WorkspaceEventHandler): Promise; + /** + * Called when the content of a note changes. + * @deprecated Use `onNoteChange()` instead, which is reliably triggered whenever the note content, or any note property changes. + */ + onNoteContentChange(callback: WorkspaceEventHandler): Promise; + /** + * Called when the content of the current note changes. + */ + onNoteChange(handler: ItemChangeHandler): Promise; + /** + * Called when a resource is changed. Currently this handled will not be + * called when a resource is added or deleted. + */ + onResourceChange(handler: ResourceChangeHandler): Promise; + /** + * Called when an alarm associated with a to-do is triggered. + */ + onNoteAlarmTrigger(handler: WorkspaceEventHandler): Promise; + /** + * Called when the synchronisation process is starting. + */ + onSyncStart(handler: SyncStartHandler): Promise; + /** + * Called when the synchronisation process has finished. + */ + onSyncComplete(callback: WorkspaceEventHandler): Promise; + /** + * Called just before the editor context menu is about to open. Allows + * adding items to it. + * + * desktop + */ + filterEditorContextMenu(handler: FilterHandler): void; + /** + * Gets the currently selected note. Will be `null` if no note is selected. + */ + selectedNote(): Promise; + /** + * 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. + */ + selectedFolder(): Promise; + /** + * Gets the IDs of the selected notes (can be zero, one, or many). Use the data API to retrieve information about these notes. + */ + selectedNoteIds(): Promise; +} +export {}; -- cgit v1.2.3