After reviewing the documentation and relevant materials, I found that there is no specific API for notifications. The closest option is joplin.views.dialogs
, which focuses on user interaction. Therefore, I believe there is a lack of notification-related APIs in the existing framework.
Notifications aim to convey information to the user without requiring interaction or disrupting the user experience. Typically, external libraries or custom notification designs could be considered, but these have the following drawbacks:1. Cross-platform development will be hindered, forcing developers to create more tests to focus on differences across platforms, thereby hindering the creation of truly useful content.
2. Inconsistent implementation leads to fragmented user experiences, much like the outdated Control Panel in Windows 11.
I noticed that a notification is displayed when deleting a note. I believe it could be integrated into the API.
The suggested convention is as follows:
joplin.views.notifications.showMessage(content: string, level: string = 'info', timeout: number = 1000*3)
for example:
await joplin.views.notifications.showMessage("This is notifications!")
await joplin.views.notifications.showMessage("This is notifications!", 'info')
await joplin.views.notifications.showMessage("This is notifications!", 'warning', 1000 * 5)
This will display a non-blocking notification content.