Skip to content

Commit 7d4f203

Browse files
authored
Merge pull request #36 from joplin/chore/update-dependencies-safety-readme
chore: update dependencies, improve safety checks, and rewrite README
2 parents f59be8d + 39d1da4 commit 7d4f203

30 files changed

Lines changed: 5848 additions & 16737 deletions

.github/workflows/Email-Plugin-CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
node-version: [14.x]
16+
node-version: [24.x]
1717

1818
steps:
1919
- uses: actions/checkout@v3

GENERATOR_DOC.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
# generator-joplin
1+
# Plugin development
22

3-
Scaffolds out a new Joplin plugin
3+
This documentation describes how to create a plugin, and how to work with the plugin builder framework and API.
44

55
## Installation
66

77
First, install [Yeoman](http://yeoman.io) and generator-joplin using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).
88

99
```bash
10-
npm install -g yo
10+
npm install -g yo@4.3.1
1111
npm install -g generator-joplin
1212
```
1313

1414
Then generate your new project:
1515

1616
```bash
17-
yo joplin
17+
yo --node-package-manager npm joplin
1818
```
1919

20-
## Development
21-
22-
To test the generator for development purposes, follow the instructions there: https://yeoman.io/authoring/#running-the-generator
23-
This is a template to create a new Joplin plugin.
24-
2520
## Structure
2621

2722
The main two files you will want to look at are:
@@ -39,6 +34,10 @@ To build the plugin, simply run `npm run dist`.
3934

4035
The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
4136

37+
## Updating the manifest version number
38+
39+
You can run `npm run updateVersion` to bump the patch part of the version number, so for example 1.0.3 will become 1.0.4. This script will update both the package.json and manifest.json version numbers so as to keep them in sync.
40+
4241
## Publishing the plugin
4342

4443
To publish the plugin, add it to npmjs.com by running `npm publish`. Later on, a script will pick up your plugin and add it automatically to the Joplin plugin repository as long as the package satisfies these conditions:
@@ -67,6 +66,13 @@ By default, the compiler (webpack) is going to compile `src/index.ts` only (as w
6766

6867
To get such an external script file to compile, you need to add it to the `extraScripts` array in `plugin.config.json`. The path you add should be relative to /src. For example, if you have a file in "/src/webviews/index.ts", the path should be set to "webviews/index.ts". Once compiled, the file will always be named with a .js extension. So you will get "webviews/index.js" in the plugin package, and that's the path you should use to reference the file.
6968

69+
## More information
70+
71+
- [Joplin Plugin API](https://joplinapp.org/api/references/plugin_api/classes/joplin.html)
72+
- [Joplin Data API](https://joplinapp.org/help/api/references/rest_api)
73+
- [Joplin Plugin Manifest](https://joplinapp.org/api/references/plugin_manifest/)
74+
- Ask for help on the [forum](https://discourse.joplinapp.org/) or our [Discord channel](https://discord.gg/VSj7AFHvpq)
75+
7076
## License
7177

7278
MIT © Laurent Cozic

README.md

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<h1 align = "center" > Email Plugin </h1>
22

3-
This plugin adds the ability to fetch email messages (including attachments) and converts them to Joplin notes in various formats, either by monitoring any `new` or `unread` messages from a specific email address or a specific mailbox, or by uploading downloaded email messages to the plugin without having to be logged in.
3+
This plugin allows you to fetch email messages (including attachments) and convert them into Joplin notes in multiple formats.
4+
5+
Emails can be processed automatically by monitoring `new` or `unread` messages from a specific email address or mailbox, or manually by uploading downloaded email messages in `.eml` format without needing to log in to the plugin.
6+
47

58
***
69

@@ -16,64 +19,96 @@ This plugin adds the ability to fetch email messages (including attachments) and
1619

1720
## Features
1821

19-
- Monitoring and fetching any `new` or `unread` messages from a specific email address.
22+
- Monitor and fetch **new or unread emails** from a specific email address.
2023

21-
- Monitoring and fetching any `new` or `unread` messages from a specific mailbox.
24+
- Monitor and fetch **new or unread emails** from a selected mailbox.
2225

23-
- Send the converted message to specific notebooks and add tags to the note by using `@` or `#` in the email subject or first line of email content and then forward the email to yourself.
26+
- You can control how notes are created using simple syntax in the **email subject** or the **first line of the email body**:
27+
- `@notebook` → save the note to a specific notebook
28+
- `#tag` → add tags to the note
29+
- `!Subject` → create a **Todo** note
2430

25-
- Convert emails (including attachments) to notes without having to be logged into the plugin.
31+
- Convert email messages (including attachments) into notes **without being logged into the plugin**.
2632

27-
- Convert email messages to notes in different formats (`HTML`, `Markdown`, `Text`).
33+
- Convert emails into notes using different output formats:
34+
- `HTML`
35+
- `Markdown`
36+
- `Plain Text`
2837

29-
- Show attachments in different styles, whether they are in the form of a `Table` or `Links`.
38+
- Display attachments in multiple styles, such as:
39+
- `Table`
40+
- `Links`
3041

3142
***
3243

3344
## How to use
3445

35-
- ### Monitoring and fetching from a specific email address
46+
- ### 🔍 Monitoring and Fetching from a Specific Email Address
3647

37-
- Open Email Plugin.
48+
1. Open the **Email Plugin**.
49+
2. Sign in with your email credentials.
50+
3. Enter the email account you want to **monitor for new or unread messages**, then enable **Fetching & Monitoring**.
3851

39-
- Login to the plugin with your email address and password.
52+
#### ✉️ Forwarding Emails to Create Notes
53+
If you enter **your own email address** in the **From** field, you can simply **forward emails to yourself**.
54+
55+
You can control how the note is created using the following syntax:
56+
- **Set note title**
57+
The email subject is used as the note title.
58+
59+
- **Assign to a notebook**
60+
Add `@notebook-name` to send the note to a specific notebook.
4061

41-
- Enter the email account you want to start fetching and monitoring `new` or `unread` messages from and click on the `Fetching & Monitoring` toggle.
62+
- **Add tags**
63+
Add `#tag-name` to attach tags to the note.
4264

43-
- If you enter your email address in the `from` field, simply forward the email message to yourself after adding some easy syntax to the end of the email subject, or add this syntax in a new line at the beginning of the message content, and the plugin will handle the rest.
65+
- **Create a Todo note**
66+
Start the subject with `!` to create a **Todo** instead of a regular note.
4467

45-
- **Set a note title** : Change note title by changing the subject of the email.
46-
- **Add to a notebook** : Add `@notebook` to send it to a specific notebook.
47-
- **Add tags** : Add `#tag` to organize the note with a tag.
4868

49-
> **For example**: Say you want this email located in the **joplin** and **gmail** folders and also want to add **gmail** and **email** as tags to the note. Just edit the email subject or add a new line at the beginning of the message content like this:
50-
>>Email subject: My message @**joplin** @**email** #**gmail** #**email**
51-
52-
https://user-images.githubusercontent.com/58605547/188909511-479bff3b-bb9c-42da-9d48-a29d8b22fd4b.mp4
53-
54-
- Otherwise the email messages will be in the `email messages` folder.
69+
#### 🧩 Example
70+
Suppose you want:
71+
- The note to be saved in the **joplin** and **email** notebooks
72+
- The note to be tagged with **gmail** and **email**
73+
- The note to be created as a **Todo**
74+
75+
Email subject:
76+
`!My message @joplin @email #gmail #email`
5577

56-
***
5778

58-
- ### Monitoring and fetching from a specific mailbox
79+
🎥 Demo:
80+
81+
https://user-images.githubusercontent.com/58605547/188909511-479bff3b-bb9c-42da-9d48-a29d8b22fd4b.mp4
5982

60-
- Open Email Plugin.
83+
#### If no notebook is specified, the note will be placed in the default **Email Messages** folder.
6184

62-
- Login to the plugin with your email address and password.
85+
***
6386

64-
- Select a specific mailbox and notebook in which you want the email messages to be located and click on the `Fetching & Monitoring Mailbox` toggle.
87+
- ### 📂 Monitoring and Fetching from a Specific Mailbox
6588

66-
***
89+
1. Open the **Email Plugin**.
90+
2. Sign in with your email credentials.
91+
3. Select:
92+
- The mailbox you want to monitor
93+
- The notebook where notes should be created
94+
4. Enable **Fetching & Monitoring Mailbox**.
6795

68-
- ### Upload downloaded email messages
96+
All new or unread emails from the selected mailbox will be converted into notes automatically.
6997

70-
- Open Email Plugin.
98+
Notes created from monitored mailboxes will automatically apply the following syntax (`#` for tags, `!` for Todos) without any additional steps.
7199

72-
- Click on the `convert saved messages` button.
73-
74-
- Upload `.eml` format files of email messages that you want to convert to notes.
100+
***
101+
102+
- ### 📥 Uploading Downloaded Email Messages
103+
1. Open the **Email Plugin**.
104+
2. Click **Convert Saved Messages**.
105+
3. Upload email files in `.eml` format.
106+
4. Choose:
107+
- Target notebook
108+
- Tags
109+
- Export options
110+
5. Click **Convert** to create notes from the uploaded emails.
75111

76-
- Select a notebook, enter the tags, select the export options, and click on the `convert` button.
77112

78113
## Important Notes
79114

api/Joplin.d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import JoplinSettings from './JoplinSettings';
1010
import JoplinContentScripts from './JoplinContentScripts';
1111
import JoplinClipboard from './JoplinClipboard';
1212
import JoplinWindow from './JoplinWindow';
13+
import BasePlatformImplementation from '../BasePlatformImplementation';
14+
import JoplinImaging from './JoplinImaging';
1315
/**
1416
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
1517
*
@@ -25,6 +27,7 @@ import JoplinWindow from './JoplinWindow';
2527
export default class Joplin {
2628
private data_;
2729
private plugins_;
30+
private imaging_;
2831
private workspace_;
2932
private filters_;
3033
private commands_;
@@ -34,9 +37,11 @@ export default class Joplin {
3437
private contentScripts_;
3538
private clipboard_;
3639
private window_;
37-
constructor(implementation: any, plugin: Plugin, store: any);
40+
private implementation_;
41+
constructor(implementation: BasePlatformImplementation, plugin: Plugin, store: any);
3842
get data(): JoplinData;
3943
get clipboard(): JoplinClipboard;
44+
get imaging(): JoplinImaging;
4045
get window(): JoplinWindow;
4146
get plugins(): JoplinPlugins;
4247
get workspace(): JoplinWorkspace;
@@ -63,6 +68,13 @@ export default class Joplin {
6368
* - [fs-extra](https://www.npmjs.com/package/fs-extra)
6469
*
6570
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/nativeModule)
71+
*
72+
* <span class="platform-desktop">desktop</span>
6673
*/
6774
require(_path: string): any;
75+
versionInfo(): Promise<import("./types").VersionInfo>;
76+
/**
77+
* Tells whether the current theme is a dark one or not.
78+
*/
79+
shouldUseDarkColors(): Promise<boolean>;
6880
}

api/JoplinClipboard.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1+
import { ClipboardContent } from './types';
12
export default class JoplinClipboard {
23
private electronClipboard_;
34
private electronNativeImage_;
45
constructor(electronClipboard: any, electronNativeImage: any);
56
readText(): Promise<string>;
67
writeText(text: string): Promise<void>;
8+
/** <span class="platform-desktop">desktop</span> */
79
readHtml(): Promise<string>;
10+
/** <span class="platform-desktop">desktop</span> */
811
writeHtml(html: string): Promise<void>;
912
/**
1013
* Returns the image in [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) format.
14+
*
15+
* <span class="platform-desktop">desktop</span>
1116
*/
1217
readImage(): Promise<string>;
1318
/**
1419
* Takes an image in [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) format.
20+
*
21+
* <span class="platform-desktop">desktop</span>
1522
*/
1623
writeImage(dataUrl: string): Promise<void>;
1724
/**
@@ -20,4 +27,19 @@ export default class JoplinClipboard {
2027
* For example [ 'text/plain', 'text/html' ]
2128
*/
2229
availableFormats(): Promise<string[]>;
30+
/**
31+
* Writes multiple formats to the clipboard simultaneously.
32+
* This allows setting both text/plain and text/html at the same time.
33+
*
34+
* <span class="platform-desktop">desktop</span>
35+
*
36+
* @example
37+
* ```typescript
38+
* await joplin.clipboard.write({
39+
* text: 'Plain text version',
40+
* html: '<strong>HTML version</strong>'
41+
* });
42+
* ```
43+
*/
44+
write(content: ClipboardContent): Promise<void>;
2345
}

api/JoplinCommands.d.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Command } from './types';
2+
import Plugin from '../Plugin';
23
/**
34
* This class allows executing or registering new Joplin commands. Commands
45
* can be executed or associated with
@@ -13,13 +14,24 @@ import { Command } from './types';
1314
* now, are not well documented. You can find the list directly on GitHub
1415
* though at the following locations:
1516
*
16-
* * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
17+
* * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/WindowCommandsAndDialogs/commands)
1718
* * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
18-
* * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
19+
* * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.ts)
1920
*
2021
* To view what arguments are supported, you can open any of these files
2122
* and look at the `execute()` command.
2223
*
24+
* Note that many of these commands only work on desktop. The more limited list of mobile
25+
* commands can be found in these places:
26+
*
27+
* * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-mobile/commands)
28+
* * [Note screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-mobile/components/screens/Note/commands)
29+
* * [Editor commands](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/components/NoteEditor/commandDeclarations.ts)
30+
*
31+
* Additionally, certain global commands have the same implementation on both platforms:
32+
*
33+
* * [Shared global commands](https://github.com/laurent22/joplin/tree/dev/packages/lib/commands)
34+
*
2335
* ## Executing editor commands
2436
*
2537
* There might be a situation where you want to invoke editor commands
@@ -49,9 +61,10 @@ import { Command } from './types';
4961
*
5062
*/
5163
export default class JoplinCommands {
64+
private plugin_;
65+
constructor(plugin_: Plugin);
5266
/**
53-
* <span class="platform-desktop">desktop</span> Executes the given
54-
* command.
67+
* Executes the given command.
5568
*
5669
* The command can take any number of arguments, and the supported
5770
* arguments will vary based on the command. For custom commands, this
@@ -70,7 +83,7 @@ export default class JoplinCommands {
7083
*/
7184
execute(commandName: string, ...args: any[]): Promise<any | void>;
7285
/**
73-
* <span class="platform-desktop">desktop</span> Registers a new command.
86+
* Registers a new command.
7487
*
7588
* ```typescript
7689
* // Register a new commmand called "testCommand1"

api/JoplinContentScripts.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default class JoplinContentScripts {
2121
* for more information.
2222
*
2323
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
24-
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
24+
* * [View the editor plugin tutorial](https://joplinapp.org/help/api/tutorials/cm6_plugin)
25+
* * [View the legacy editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
2526
*
2627
* See also the [postMessage demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/post_messages)
2728
*

0 commit comments

Comments
 (0)