Skip to content

Commit f44b2df

Browse files
committed
Initial commit with first commands
1 parent 970bf7d commit f44b2df

29 files changed

+6511
-30
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
node_modules/
3+
*.tgz
4+
*.zip

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
> Requires Joplin v1.3.9!
11+
1012
* Initial Release
1113

1214
## [1.0.0] - yyyy-mm-dd

README.md

+75-30
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,108 @@
1-
# Note extensions
1+
# Joplin Note Extensions
22

3-
_note-extensions_ is a plugin to extend the UX and UI of [Joplin](https://joplinapp.org/)'s desktop application.
3+
_joplin-note-ext_ is a plugin to extend the UX [Joplin](https://joplinapp.org/)'s desktop application.
44

5-
It provides a collection of [commands](#commands) and [UI enhancements](#ui-enhancements) for working with notes and to-dos.
5+
It provides a collection of [new commands](#new-commands) and adapts some [existing commands](#mapped-commands) to enhance working with notes and to-dos.
66

77
> **NOTE** - This plugin requires at least Joplin v1.3.9!
88
99
## Table of contents
1010

11-
* [Features](#features)
12-
* [Commands](#commands)
13-
* [UI enhancements](#ui-enhancements)
14-
* [User options](#user-options)
15-
* [Installation](#installation)
16-
* [UI tweaks](#ui-tweaks)
17-
* [Support](#support)
18-
* [License](#license)
11+
- [Features](#features)
12+
- [New commands](#commands)
13+
- [Mapped commands](#mapped-commands)
14+
- [User options](#user-options)
15+
- [Installation](#installation)
16+
- [Uninstallation](#uninstallation)
17+
- [UI tweaks](#ui-tweaks)
18+
- [Support](#support)
19+
- [Changes](#changes)
20+
- [License](#license)
1921

2022
## Features
2123

22-
### Commands
24+
TODO
2325

24-
> TODO - describe new commands (if available). For example:
26+
- new commands
27+
- mapped commands
28+
- new commands user options
2529

26-
- Add new Note (`addNewNote`)
27-
- Adds a new note to the list
30+
## New Commands
2831

29-
### UI enhancements
32+
> **NOTE** - Default keyboard shortcuts can be changed in user options.
33+
> Navigate to `Tools > Options > Keyboard Shortcuts` and search for the command label to be changed.
3034
31-
> TODO - describe additions to the UI (with images, if available)\
32-
> New panels, views, dialogs, ... in sub-chapters
35+
### Toggle to-do state
3336

34-
- Adds context menu entry: `Add new Note`
37+
| Command | Command ID | Default Key |
38+
| ----------------- | ----------------- | ----------------------- |
39+
| Touch to-do state | `toggleTodoState` | `CmdOrCtrl+Shift+Space` |
3540

36-
To get the best result, check out the [UI tweaks](#ui-tweaks).
41+
TODO describe more detailed...
3742

38-
### User options
43+
### Touch note
3944

40-
> TODO - describe added User options (if available)
45+
| Command | Command ID | Default Key |
46+
| ---------- | ----------- | ----------- |
47+
| Touch note | `touchNote` | - |
4148

42-
## Installation
49+
TODO describe more detailed...
50+
51+
### Set URL
52+
53+
| Command | Command ID | Default Key |
54+
| ------- | ---------- | ----------- |
55+
| Set URL | `editURL` | - |
56+
57+
TODO describe more detailed...
58+
59+
### Move notes
60+
61+
| Command | Command ID | Default Key |
62+
| ------------------- | ------------------ | ---------------------- |
63+
| Move note to top | `moveNoteToTop` | `CmdOrCtrl+Alt+Up` |
64+
| Move note up | `moveNoteUp` | `CmdOrCtrl+Shift+Up` |
65+
| Move note down | `moveNoteDown` | `CmdOrCtrl+Shift+Down` |
66+
| Move note to bottom | `moveNoteToBottom` | `CmdOrCtrl+Alt+Down` |
67+
68+
TODO describe more detailed...
69+
70+
> **NOTE** TODO works only in custom order mode
4371
44-
> TODO - steps to install the plugin
72+
## Mapped commands
4573

46-
## UI tweaks
74+
## User options
4775

48-
> TODO - describe how to change `webview.css` or `userchrome.css` (if available)
76+
This plugin adds the following user options which can be accessed via `Tools > Options > Note Extensions`.
4977

50-
### General styles
78+
> **NOTE** - TODO changing requires restart
5179
52-
E.g. to not show something which is displayed elsewhere via the new plugin).
80+
- Show [Toggle to-do state](#toggle-to-do-state) button on note toolbar:\
81+
_Select whether an button for the command shall be shown on the note toolbar (next to note title) or not_
82+
83+
> TODO - Add user options here...
84+
85+
### UI enhancements
86+
87+
This plugin adds the following elements to the UI.
88+
89+
To get the best result, check out the [UI tweaks](#ui-tweaks) also.
90+
91+
> TODO - describe additions to the UI (with screenshots, if available)
92+
> New panels, views, dialogs, ... in sub-chapters
93+
> Otherwise remove chapters
94+
95+
## Installation
5396

54-
### Rendered Markdown
97+
> TODO - Add steps to install the plugin here...
5598
99+
## Uninstallation
56100

101+
> TODO - Add steps to uninstall the plugin here...
57102
58103
## Support
59104

60-
If you need help or found a bug, open an issue on [GitHub](https://github.com/benji300-joplin-extensions/note-extensions/issues).
105+
If you need help or found a bug, open an issue on [GitHub](https://github.com/benji300/joplin-note-ext/issues).
61106

62107
## Changes
63108

api/Global.d.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Plugin from '../Plugin';
2+
import Joplin from './Joplin';
3+
import Logger from 'lib/Logger';
4+
/**
5+
* @ignore
6+
*/
7+
export default class Global {
8+
private joplin_;
9+
private requireWhiteList_;
10+
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any);
11+
get joplin(): Joplin;
12+
private requireWhiteList;
13+
require(filePath: string): any;
14+
get process(): any;
15+
}

api/Joplin.d.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Plugin from '../Plugin';
2+
import JoplinData from './JoplinData';
3+
import JoplinPlugins from './JoplinPlugins';
4+
import JoplinWorkspace from './JoplinWorkspace';
5+
import JoplinFilters from './JoplinFilters';
6+
import JoplinCommands from './JoplinCommands';
7+
import JoplinViews from './JoplinViews';
8+
import JoplinInterop from './JoplinInterop';
9+
import JoplinSettings from './JoplinSettings';
10+
import Logger from 'lib/Logger';
11+
/**
12+
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
13+
*/
14+
export default class Joplin {
15+
private data_;
16+
private plugins_;
17+
private workspace_;
18+
private filters_;
19+
private commands_;
20+
private views_;
21+
private interop_;
22+
private settings_;
23+
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any);
24+
get data(): JoplinData;
25+
get plugins(): JoplinPlugins;
26+
get workspace(): JoplinWorkspace;
27+
/**
28+
* @ignore
29+
*
30+
* Not sure if it's the best way to hook into the app
31+
* so for now disable filters.
32+
*/
33+
get filters(): JoplinFilters;
34+
get commands(): JoplinCommands;
35+
get views(): JoplinViews;
36+
get interop(): JoplinInterop;
37+
get settings(): JoplinSettings;
38+
}

api/JoplinCommands.d.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Command } from './types';
2+
/**
3+
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with
4+
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}.
5+
*
6+
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command)
7+
*
8+
* ## Executing Joplin's internal commands
9+
*
10+
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented.
11+
* You can find the list directly on GitHub though at the following locations:
12+
*
13+
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands
14+
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands
15+
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts
16+
*
17+
* To view what arguments are supported, you can open any of these files and look at the `execute()` command.
18+
*/
19+
export default class JoplinCommands {
20+
/**
21+
* <span class="platform-desktop">desktop</span> Executes the given command.
22+
* The `props` are the arguments passed to the command, and they vary based on the command
23+
*
24+
* ```typescript
25+
* // Create a new note in the current notebook:
26+
* await joplin.commands.execute('newNote');
27+
*
28+
* // Create a new sub-notebook under the provided notebook
29+
* // Note: internally, notebooks are called "folders".
30+
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
31+
* ```
32+
*/
33+
execute(commandName: string, ...args: any[]): Promise<any | void>;
34+
/**
35+
* <span class="platform-desktop">desktop</span> Registers a new command.
36+
*
37+
* ```typescript
38+
* // Register a new commmand called "testCommand1"
39+
*
40+
* await joplin.commands.register({
41+
* name: 'testCommand1',
42+
* label: 'My Test Command 1',
43+
* iconName: 'fas fa-music',
44+
* execute: () => {
45+
* alert('Testing plugin command 1');
46+
* },
47+
* });
48+
* ```
49+
*/
50+
register(command: Command): Promise<void>;
51+
}

api/JoplinData.d.ts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Path } from './types';
2+
/**
3+
* This module provides access to the Joplin data API: https://joplinapp.org/api/references/rest_api/
4+
* This is the main way to retrieve data, such as notes, notebooks, tags, etc.
5+
* or to update them or delete them.
6+
*
7+
* This is also what you would use to search notes, via the `search` endpoint.
8+
*
9+
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple)
10+
*
11+
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
12+
* And each method takes these parameters:
13+
*
14+
* * `path`: This is an array that represents the path to the resource in the form `["resouceName", "resourceId", "resourceLink"]` (eg. ["tags", ":id", "notes"]). The "resources" segment is the name of the resources you want to access (eg. "notes", "folders", etc.). If not followed by anything, it will refer to all the resources in that collection. The optional "resourceId" points to a particular resources within the collection. Finally, an optional "link" can be present, which links the resource to a collection of resources. This can be used in the API for example to retrieve all the notes associated with a tag.
15+
* * `query`: (Optional) The query parameters. In a URL, this is the part after the question mark "?". In this case, it should be an object with key/value pairs.
16+
* * `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.
17+
* * `files`: (Optional) Used to create new resources and associate them with files.
18+
*
19+
* 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.
20+
*
21+
* For example:
22+
*
23+
* ```typescript
24+
* // Get a note ID, title and body
25+
* const noteId = 'some_note_id';
26+
* const note = await joplin.data.get(['notes', noteId], { fields: ['id', 'title', 'body'] });
27+
*
28+
* // Get all folders
29+
* const folders = await joplin.data.get(['folders']);
30+
*
31+
* // Set the note body
32+
* await joplin.data.put(['notes', noteId], null, { body: "New note body" });
33+
*
34+
* // Create a new note under one of the folders
35+
* await joplin.data.post(['notes'], null, { body: "my new note", title: "some title", parent_id: folders[0].id });
36+
* ```
37+
*/
38+
export default class JoplinData {
39+
private api_;
40+
private pathSegmentRegex_;
41+
private serializeApiBody;
42+
private pathToString;
43+
get(path: Path, query?: any): Promise<any>;
44+
post(path: Path, query?: any, body?: any, files?: any[]): Promise<any>;
45+
put(path: Path, query?: any, body?: any, files?: any[]): Promise<any>;
46+
delete(path: Path, query?: any): Promise<any>;
47+
}

api/JoplinFilters.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @ignore
3+
*
4+
* Not sure if it's the best way to hook into the app
5+
* so for now disable filters.
6+
*/
7+
export default class JoplinFilters {
8+
on(name: string, callback: Function): Promise<void>;
9+
off(name: string, callback: Function): Promise<void>;
10+
}

api/JoplinInterop.d.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ExportModule, ImportModule } from './types';
2+
/**
3+
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
4+
*
5+
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export)
6+
*
7+
* To implement an import or export module, you would simply define an object with various event handlers that are called
8+
* by the application during the import/export process.
9+
*
10+
* See the documentation of the [[ExportModule]] and [[ImportModule]] for more information.
11+
*
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/
13+
*/
14+
export default class JoplinInterop {
15+
registerExportModule(module: ExportModule): Promise<void>;
16+
registerImportModule(module: ImportModule): Promise<void>;
17+
}

api/JoplinPlugins.d.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Plugin from '../Plugin';
2+
import Logger from 'lib/Logger';
3+
import { ContentScriptType, Script } from './types';
4+
/**
5+
* This class provides access to plugin-related features.
6+
*/
7+
export default class JoplinPlugins {
8+
private logger;
9+
private plugin;
10+
constructor(logger: Logger, plugin: Plugin);
11+
/**
12+
* Registers a new plugin. This is the entry point when creating a plugin. You should pass a simple object with an `onStart` method to it.
13+
* That `onStart` method will be executed as soon as the plugin is loaded.
14+
*
15+
* ```typescript
16+
* joplin.plugins.register({
17+
* onStart: async function() {
18+
* // Run your plugin code here
19+
* }
20+
* });
21+
* ```
22+
*/
23+
register(script: Script): Promise<void>;
24+
/**
25+
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
26+
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
27+
*
28+
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
29+
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
30+
*
31+
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script)
32+
*
33+
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
34+
* @param id A unique ID for the content script.
35+
* @param scriptPath Must be a path relative to the plugin main script. For example, if your file content_script.js is next to your index.ts file, you would set `scriptPath` to `"./content_script.js`.
36+
*/
37+
registerContentScript(type: ContentScriptType, id: string, scriptPath: string): Promise<void>;
38+
}

0 commit comments

Comments
 (0)