Skip to content

Commit 03b8ab5

Browse files
committed
Merge branch 'develop'
2 parents a4b1138 + 82813e3 commit 03b8ab5

26 files changed

Lines changed: 23233 additions & 13235 deletions

.github/workflows/buildAndTest.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build and test
2+
on: [push, pull_request]
3+
jobs:
4+
buildAndTest:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- uses: actions/setup-node@v2
9+
with:
10+
node-version: "16"
11+
- name: Install dependencies
12+
run: npm install
13+
- name: Build
14+
run: npm run dist
15+
- name: Run test
16+
run: npm test

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## not released
44

5+
## v1.1.1 (2024-01-11)
6+
7+
- Add: Screenshots / icon for [https://joplinapp.org/plugins/](https://joplinapp.org/plugins/)
8+
59
## v1.1.0 (2023-06-10)
610

711
- Fix: #24 mixed case file extentions in `Add as text` setting

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Joplin Hotfolder Plugin
1+
# Joplin Hotfolder Plugin <img src="img/icon_32.png">
22

33
A plugin to Monitor a locale folder and import the files as a new note.
44

5-
<img src="img/main.jpg">
5+
<img src="img/main.png">
66

77
## Installation
88

api/Joplin.d.ts

Lines changed: 7 additions & 2 deletions
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;
@@ -52,7 +57,6 @@ export default class Joplin {
5257
get views(): JoplinViews;
5358
get interop(): JoplinInterop;
5459
get settings(): JoplinSettings;
55-
get versionInfo(): any;
5660
/**
5761
* It is not possible to bundle native packages with a plugin, because they
5862
* need to work cross-platforms. Instead access to certain useful native
@@ -66,4 +70,5 @@ export default class Joplin {
6670
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/nativeModule)
6771
*/
6872
require(_path: string): any;
73+
versionInfo(): Promise<import("./types").VersionInfo>;
6974
}

api/JoplinData.d.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ModelType } from '../../../BaseModel';
2+
import Plugin from '../Plugin';
23
import { Path } from './types';
34
/**
4-
* This module provides access to the Joplin data API: https://joplinapp.org/api/references/rest_api/
5+
* This module provides access to the Joplin data API: https://joplinapp.org/help/api/references/rest_api
56
* This is the main way to retrieve data, such as notes, notebooks, tags, etc.
67
* or to update them or delete them.
78
*
@@ -17,7 +18,7 @@ import { Path } from './types';
1718
* * `data`: (Optional) Applies to PUT and POST calls only. The request body contains the data you want to create or modify, for example the content of a note or folder.
1819
* * `files`: (Optional) Used to create new resources and associate them with files.
1920
*
20-
* Please refer to the [Joplin API documentation](https://joplinapp.org/api/references/rest_api/) for complete details about each call. As the plugin runs within the Joplin application **you do not need an authorisation token** to use this API.
21+
* Please refer to the [Joplin API documentation](https://joplinapp.org/help/api/references/rest_api) for complete details about each call. As the plugin runs within the Joplin application **you do not need an authorisation token** to use this API.
2122
*
2223
* For example:
2324
*
@@ -39,6 +40,8 @@ import { Path } from './types';
3940
export default class JoplinData {
4041
private api_;
4142
private pathSegmentRegex_;
43+
private plugin;
44+
constructor(plugin: Plugin);
4245
private serializeApiBody;
4346
private pathToString;
4447
get(path: Path, query?: any): Promise<any>;
@@ -47,4 +50,24 @@ export default class JoplinData {
4750
delete(path: Path, query?: any): Promise<any>;
4851
itemType(itemId: string): Promise<ModelType>;
4952
resourcePath(resourceId: string): Promise<string>;
53+
/**
54+
* Gets an item user data. User data are key/value pairs. The `key` can be any
55+
* arbitrary string, while the `value` can be of any type supported by
56+
* [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)
57+
*
58+
* User data is synchronised across devices, and each value wil be merged based on their timestamp:
59+
*
60+
* - If value is modified by client 1, then modified by client 2, it will take the value from client 2
61+
* - If value is modified by client 1, then deleted by client 2, the value will be deleted after merge
62+
* - If value is deleted by client 1, then updated by client 2, the value will be restored and set to the value from client 2 after merge
63+
*/
64+
userDataGet<T>(itemType: ModelType, itemId: string, key: string): Promise<T>;
65+
/**
66+
* Sets a note user data. See {@link JoplinData.userDataGet} for more details.
67+
*/
68+
userDataSet<T>(itemType: ModelType, itemId: string, key: string, value: T): Promise<void>;
69+
/**
70+
* Deletes a note user data. See {@link JoplinData.userDataGet} for more details.
71+
*/
72+
userDataDelete(itemType: ModelType, itemId: string, key: string): Promise<void>;
5073
}

api/JoplinImaging.d.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Rectangle } from './types';
2+
export interface Implementation {
3+
nativeImage: any;
4+
}
5+
export interface CreateFromBufferOptions {
6+
width?: number;
7+
height?: number;
8+
scaleFactor?: number;
9+
}
10+
export interface ResizeOptions {
11+
width?: number;
12+
height?: number;
13+
quality?: 'good' | 'better' | 'best';
14+
}
15+
export type Handle = string;
16+
/**
17+
* Provides imaging functions to resize or process images. You create an image
18+
* using one of the `createFrom` functions, then use the other functions to
19+
* process the image.
20+
*
21+
* Images are associated with a handle which is what will be available to the
22+
* plugin. Once you are done with an image, free it using the `free()` function.
23+
*
24+
* [View the
25+
* example](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/imaging/src/index.ts)
26+
*
27+
*/
28+
export default class JoplinImaging {
29+
private implementation_;
30+
private images_;
31+
constructor(implementation: Implementation);
32+
private createImageHandle;
33+
private imageByHandle;
34+
private cacheImage;
35+
createFromPath(filePath: string): Promise<Handle>;
36+
createFromResource(resourceId: string): Promise<Handle>;
37+
getSize(handle: Handle): Promise<any>;
38+
resize(handle: Handle, options?: ResizeOptions): Promise<string>;
39+
crop(handle: Handle, rectange: Rectangle): Promise<string>;
40+
toPngFile(handle: Handle, filePath: string): Promise<void>;
41+
/**
42+
* Quality is between 0 and 100
43+
*/
44+
toJpgFile(handle: Handle, filePath: string, quality?: number): Promise<void>;
45+
private tempFilePath;
46+
/**
47+
* Creates a new Joplin resource from the image data. The image will be
48+
* first converted to a JPEG.
49+
*/
50+
toJpgResource(handle: Handle, resourceProps: any, quality?: number): Promise<import("../../database/types").ResourceEntity>;
51+
/**
52+
* Creates a new Joplin resource from the image data. The image will be
53+
* first converted to a PNG.
54+
*/
55+
toPngResource(handle: Handle, resourceProps: any): Promise<import("../../database/types").ResourceEntity>;
56+
/**
57+
* Image data is not automatically deleted by Joplin so make sure you call
58+
* this method on the handle once you are done.
59+
*/
60+
free(handle: Handle): Promise<void>;
61+
}

api/JoplinInterop.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ExportModule, ImportModule } from './types';
99
*
1010
* See the documentation of the [[ExportModule]] and [[ImportModule]] for more information.
1111
*
12-
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
12+
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/help/api/references/rest_api
1313
*/
1414
export default class JoplinInterop {
1515
registerExportModule(module: ExportModule): Promise<void>;

api/JoplinSettings.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export interface ChangeEvent {
66
*/
77
keys: string[];
88
}
9-
export declare type ChangeHandler = (event: ChangeEvent) => void;
9+
export type ChangeHandler = (event: ChangeEvent) => void;
10+
export declare const namespacedKey: (pluginId: string, key: string) => string;
1011
/**
1112
* This API allows registering new settings and setting sections, as well as getting and setting settings. Once a setting has been registered it will appear in the config screen and be editable by the user.
1213
*
@@ -19,8 +20,6 @@ export declare type ChangeHandler = (event: ChangeEvent) => void;
1920
export default class JoplinSettings {
2021
private plugin_;
2122
constructor(plugin: Plugin);
22-
private get keyPrefix();
23-
private namespacedKey;
2423
/**
2524
* Registers new settings.
2625
* Note that registering a setting item is dynamic and will be gone next time Joplin starts.

api/JoplinViews.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import JoplinViewsMenuItems from './JoplinViewsMenuItems';
44
import JoplinViewsMenus from './JoplinViewsMenus';
55
import JoplinViewsToolbarButtons from './JoplinViewsToolbarButtons';
66
import JoplinViewsPanels from './JoplinViewsPanels';
7+
import JoplinViewsNoteList from './JoplinViewsNoteList';
78
/**
89
* This namespace provides access to view-related services.
910
*
@@ -13,16 +14,18 @@ import JoplinViewsPanels from './JoplinViewsPanels';
1314
export default class JoplinViews {
1415
private store;
1516
private plugin;
16-
private dialogs_;
1717
private panels_;
1818
private menuItems_;
1919
private menus_;
2020
private toolbarButtons_;
21+
private dialogs_;
22+
private noteList_;
2123
private implementation_;
2224
constructor(implementation: any, plugin: Plugin, store: any);
2325
get dialogs(): JoplinViewsDialogs;
2426
get panels(): JoplinViewsPanels;
2527
get menuItems(): JoplinViewsMenuItems;
2628
get menus(): JoplinViewsMenus;
2729
get toolbarButtons(): JoplinViewsToolbarButtons;
30+
get noteList(): JoplinViewsNoteList;
2831
}

0 commit comments

Comments
 (0)