You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2026-02-10 08:14:27 +02:00
Compare commits
15 Commits
v1.5.6
...
sidebar_pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af36737d72 | ||
|
|
2cf8b99adc | ||
|
|
70134ce077 | ||
|
|
2586cd8287 | ||
|
|
a1c08adb3e | ||
|
|
18bc9133eb | ||
|
|
5cd9114334 | ||
|
|
65cc6853bd | ||
|
|
dca51cc7de | ||
|
|
bc76e4a918 | ||
|
|
3ed0083e94 | ||
|
|
5cafc8cea5 | ||
|
|
ff5e8ee7aa | ||
|
|
f1bbcea64b | ||
|
|
8e874891c0 |
@@ -48,7 +48,7 @@ const listState = function (editor: Editor, listName, options:any = {}) {
|
||||
// dependent on how the checkbox is styled, so if the style is changed, this might need
|
||||
// to be updated too.
|
||||
// For the styling, see:
|
||||
// packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/checkbox.ts
|
||||
// packages/renderer/MdToHtml/rules/checkbox.ts
|
||||
//
|
||||
// The previous solution was to use "pointer-event: none", which mostly work, however
|
||||
// it means that links are no longer clickable when they are within the checkbox label.
|
||||
|
||||
@@ -102,9 +102,9 @@
|
||||
"./packages/app-mobile/fastlane/Preview.html": true,
|
||||
"./packages/app-mobile/fastlane/report.xml": true,
|
||||
"./packages/app-mobile/fastlane/screenshots": true,
|
||||
"./packages/app-mobile/lib/joplin-renderer/**/.vscode/": true,
|
||||
"./packages/app-mobile/lib/joplin-renderer/**/copyLib.bat": true,
|
||||
"./packages/app-mobile/lib/joplin-renderer/**/node_modules/": true,
|
||||
"./packages/renderer/**/.vscode/": true,
|
||||
"./packages/renderer/**/copyLib.bat": true,
|
||||
"./packages/renderer/**/node_modules/": true,
|
||||
"./packages/app-tools/**/*-kct.*": true,
|
||||
"./packages/app-tools/**/github_username_cache.json": true,
|
||||
"./packages/app-tools/**/patreon_oauth_token.txt": true,
|
||||
@@ -300,13 +300,13 @@
|
||||
"packages/app-mobile/fastlane/screenshots": true,
|
||||
"packages/app-mobile/ios/build/": true,
|
||||
"packages/app-mobile/lib/csstojs/": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/**/.vscode/": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/**/copyLib.bat": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/**/node_modules/": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/checkbox.js": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/fence.js": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.js": true,
|
||||
"packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/sanitize_html.js": true,
|
||||
"packages/renderer/**/.vscode/": true,
|
||||
"packages/renderer/**/copyLib.bat": true,
|
||||
"packages/renderer/**/node_modules/": true,
|
||||
"packages/renderer/MdToHtml/rules/checkbox.js": true,
|
||||
"packages/renderer/MdToHtml/rules/fence.js": true,
|
||||
"packages/renderer/MdToHtml/rules/mermaid.js": true,
|
||||
"packages/renderer/MdToHtml/rules/sanitize_html.js": true,
|
||||
"packages/app-mobile/lib/rnInjectedJs/": true,
|
||||
"packages/app-mobile/lib/sql-extensions/spellfix.so": true,
|
||||
"packages/generator-joplin/generators/app/templates/api/": true,
|
||||
|
||||
@@ -52,7 +52,7 @@ tasks.prepareTestBuild = {
|
||||
|
||||
// await utils.copyDir(`${rootDir}/packages/app-mobile/lib`, `${testBuildDir}/lib`, {
|
||||
// excluded: [
|
||||
// `${rootDir}/packages/app-mobile/lib/joplin-renderer/node_modules`,
|
||||
// `${rootDir}/packages/renderer/node_modules`,
|
||||
// ],
|
||||
// });
|
||||
// await utils.copyDir(`${rootDir}/packages/app-mobile/locales`, `${testBuildDir}/locales`);
|
||||
|
||||
@@ -170,7 +170,9 @@ describe('services_PluginService', function() {
|
||||
const tempDir = await createTempDir();
|
||||
|
||||
const contentScriptPath = `${tempDir}/markdownItTestPlugin.js`;
|
||||
const contentScriptCssPath = `${tempDir}/markdownItTestPlugin.css`;
|
||||
await shim.fsDriver().copy(`${testPluginDir}/content_script/src/markdownItTestPlugin.js`, contentScriptPath);
|
||||
await shim.fsDriver().copy(`${testPluginDir}/content_script/src/markdownItTestPlugin.css`, contentScriptCssPath);
|
||||
|
||||
const service = newPluginService();
|
||||
|
||||
@@ -205,7 +207,7 @@ describe('services_PluginService', function() {
|
||||
|
||||
const mdToHtml = new MdToHtml();
|
||||
const module = require(contentScript.path).default;
|
||||
mdToHtml.loadExtraRendererRule(contentScript.id, module({}));
|
||||
mdToHtml.loadExtraRendererRule(contentScript.id, tempDir, module({}));
|
||||
|
||||
const result = await mdToHtml.render([
|
||||
'```justtesting',
|
||||
@@ -213,6 +215,11 @@ describe('services_PluginService', function() {
|
||||
'```',
|
||||
].join('\n'));
|
||||
|
||||
const asset = result.pluginAssets.find(a => a.name === 'justtesting/markdownItTestPlugin.css');
|
||||
const assetContent: string = await shim.fsDriver().readFile(asset.path, 'utf8');
|
||||
|
||||
expect(assetContent.includes('.just-testing')).toBe(true);
|
||||
expect(assetContent.includes('background-color: red;')).toBe(true);
|
||||
expect(result.html.includes('JUST TESTING: something')).toBe(true);
|
||||
|
||||
await shim.fsDriver().remove(tempDir);
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -3,6 +3,22 @@ import { ContentScriptType } from 'api/types';
|
||||
|
||||
joplin.plugins.register({
|
||||
onStart: async function() {
|
||||
await joplin.commands.register({
|
||||
name: 'testCommand',
|
||||
label: 'My Test Command',
|
||||
execute: async (...args) => {
|
||||
alert('Got command "testCommand" with args: ' + JSON.stringify(args));
|
||||
},
|
||||
});
|
||||
|
||||
await joplin.commands.register({
|
||||
name: 'testCommandNoArgs',
|
||||
label: 'My Test Command (no args)',
|
||||
execute: async () => {
|
||||
alert('Got command "testCommandNoArgs"');
|
||||
},
|
||||
});
|
||||
|
||||
await joplin.plugins.registerContentScript(
|
||||
ContentScriptType.MarkdownItPlugin,
|
||||
'justtesting',
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
.just-testing {
|
||||
background-color: rgb(202, 255, 255);
|
||||
color: rgb(82, 0, 78);
|
||||
}
|
||||
|
||||
.just-testing a {
|
||||
background-color: rgb(202, 255, 255);
|
||||
color: rgb(10, 0, 104);
|
||||
}
|
||||
@@ -6,7 +6,13 @@ function plugin(markdownIt, _options) {
|
||||
markdownIt.renderer.rules.fence = function(tokens, idx, options, env, self) {
|
||||
const token = tokens[idx];
|
||||
if (token.info !== 'justtesting') return defaultRender(tokens, idx, options, env, self);
|
||||
return `JUST TESTING: ${token.content}`;
|
||||
return `
|
||||
<div class="just-testing">
|
||||
<p>JUST TESTING: ${token.content}</p>
|
||||
<p><a href="#" onclick="webviewApi.executeCommand('testCommand', 'one', 'two'); return false;">Click to send "testCommand" to plugin</a></p>
|
||||
<p><a href="#" onclick="webviewApi.executeCommand('testCommandNoArgs'); return false;">Click to send "testCommandNoArgs" to plugin</a></p>
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,6 +20,11 @@ module.exports = {
|
||||
default: function(_context) {
|
||||
return {
|
||||
plugin: plugin,
|
||||
assets: function() {
|
||||
return [
|
||||
{ name: 'markdownItTestPlugin.css' }
|
||||
];
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -35,6 +35,14 @@ joplin.plugins.register({
|
||||
},
|
||||
});
|
||||
|
||||
await joplin.commands.register({
|
||||
name: 'sideBarContextMenuExample',
|
||||
label: 'Menu item from plugin',
|
||||
execute: async (itemType:number, itemId:string) => {
|
||||
console.info('Click on item: ' + JSON.stringify({ itemType, itemId }));
|
||||
},
|
||||
});
|
||||
|
||||
// Commands that return a result and take argument can only be used
|
||||
// programmatically, so it's not necessary to set a label and icon.
|
||||
await joplin.commands.register({
|
||||
@@ -56,6 +64,8 @@ joplin.plugins.register({
|
||||
|
||||
await joplin.views.menuItems.create('contextMenuItem1', 'contextMenuCommandExample', MenuItemLocation.NoteListContextMenu);
|
||||
|
||||
await joplin.views.menuItems.create('sideBarMenuItem1', 'sideBarContextMenuExample', MenuItemLocation.SideBarContextMenu);
|
||||
|
||||
console.info('Running command with arguments...');
|
||||
const result = await joplin.commands.execute('commandWithResult', 'abcd', 123);
|
||||
console.info('Result was: ' + result);
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent) => void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent) => void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function readManifest(manifestPath) {
|
||||
}
|
||||
|
||||
function createPluginArchive(sourceDir, destPath) {
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`)
|
||||
const distFiles = glob.sync(`${sourceDir}/**/*`, { nodir: true })
|
||||
.map(f => f.substr(sourceDir.length + 1));
|
||||
|
||||
if (!distFiles.length) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import versionInfo from '@joplin/lib/versionInfo';
|
||||
import { Module } from '@joplin/lib/services/interop/types';
|
||||
import InteropServiceHelper from '../InteropServiceHelper';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { MenuItem, MenuItemLocation } from '@joplin/lib/services/plugins/api/types';
|
||||
import { isContextMenuItemLocation, MenuItem, MenuItemLocation } from '@joplin/lib/services/plugins/api/types';
|
||||
import SpellCheckerService from '@joplin/lib/services/spellChecker/SpellCheckerService';
|
||||
import menuCommandNames from './menuCommandNames';
|
||||
import stateToWhenClauseContext from '../services/commands/stateToWhenClauseContext';
|
||||
@@ -697,7 +697,7 @@ function useMenu(props: Props) {
|
||||
|
||||
for (const view of props.pluginMenuItems) {
|
||||
const location: MenuItemLocation = view.location;
|
||||
if ([MenuItemLocation.Context, MenuItemLocation.EditorContextMenu, MenuItemLocation.NoteListContextMenu].includes(location)) continue;
|
||||
if (isContextMenuItemLocation(location)) continue;
|
||||
|
||||
const itemParent = rootMenus[location];
|
||||
|
||||
@@ -709,7 +709,7 @@ function useMenu(props: Props) {
|
||||
}
|
||||
|
||||
for (const view of props.pluginMenus) {
|
||||
if ([MenuItemLocation.Context, MenuItemLocation.EditorContextMenu, MenuItemLocation.NoteListContextMenu].includes(view.location)) continue;
|
||||
if (isContextMenuItemLocation(view.location)) continue;
|
||||
const itemParent = rootMenus[view.location];
|
||||
|
||||
if (!itemParent) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { FormNote } from './types';
|
||||
import contextMenu from './contextMenu';
|
||||
import ResourceEditWatcher from '@joplin/lib/services/ResourceEditWatcher/index';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import CommandService from '@joplin/lib/services/CommandService';
|
||||
const BaseItem = require('@joplin/lib/models/BaseItem');
|
||||
const BaseModel = require('@joplin/lib/BaseModel').default;
|
||||
const Resource = require('@joplin/lib/models/Resource.js');
|
||||
@@ -90,6 +91,10 @@ export default function useMessageHandler(scrollWhenReady: any, setScrollWhenRea
|
||||
}
|
||||
} else if (msg.indexOf('#') === 0) {
|
||||
// This is an internal anchor, which is handled by the WebView so skip this case
|
||||
} else if (msg === 'contentScriptExecuteCommand') {
|
||||
const commandName = arg0.name;
|
||||
const commandArgs = arg0.args || [];
|
||||
void CommandService.instance().execute(commandName, ...commandArgs);
|
||||
} else {
|
||||
bridge().showErrorMessageBox(_('Unsupported link or message: %s', msg));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ import Setting from '@joplin/lib/models/Setting';
|
||||
import MenuUtils from '@joplin/lib/services/commands/MenuUtils';
|
||||
import InteropServiceHelper from '../../InteropServiceHelper';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { PluginStates, utils as pluginUtils } from '@joplin/lib/services/plugins/reducer';
|
||||
import { MenuItemLocation } from '@joplin/lib/services/plugins/api/types';
|
||||
import { AppState } from '../../app';
|
||||
import { ModelType } from '@joplin/lib/BaseModel';
|
||||
|
||||
const { connect } = require('react-redux');
|
||||
const shared = require('@joplin/lib/components/shared/side-menu-shared.js');
|
||||
@@ -36,6 +40,7 @@ interface Props {
|
||||
syncReport: any;
|
||||
tags: any[];
|
||||
syncStarted: boolean;
|
||||
plugins: PluginStates;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -101,6 +106,7 @@ class SideBarComponent extends React.Component<Props, State> {
|
||||
private tagItemsOrder_: any[] = [];
|
||||
private rootRef: any = null;
|
||||
private anchorItemRefs: any = {};
|
||||
private pluginsRef:any;
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
@@ -112,6 +118,14 @@ class SideBarComponent extends React.Component<Props, State> {
|
||||
folderHeaderIsExpanded: Setting.value('folderHeaderIsExpanded'),
|
||||
};
|
||||
|
||||
// This whole component is a bit of a mess and rather than passing
|
||||
// a plugins prop around, not knowing how it's going to affect
|
||||
// re-rendering, we just keep a ref to it. Currently that's enough
|
||||
// as plugins are only accessed from context menus. However if want
|
||||
// to do more complex things with plugins in the sidebar, it will
|
||||
// probably have to be refactored using React Hooks first.
|
||||
this.pluginsRef = React.createRef();
|
||||
|
||||
this.onFolderToggleClick_ = this.onFolderToggleClick_.bind(this);
|
||||
this.onKeyDown = this.onKeyDown.bind(this);
|
||||
this.onAllNotesClick_ = this.onAllNotesClick_.bind(this);
|
||||
@@ -294,6 +308,20 @@ class SideBarComponent extends React.Component<Props, State> {
|
||||
));
|
||||
}
|
||||
|
||||
const pluginViews = pluginUtils.viewsByType(this.pluginsRef.current, 'menuItem');
|
||||
|
||||
for (const view of pluginViews) {
|
||||
const location = view.location;
|
||||
|
||||
if (itemType === ModelType.Tag && location === MenuItemLocation.TagContextMenu ||
|
||||
itemType === ModelType.Folder && location === MenuItemLocation.FolderContextMenu
|
||||
) {
|
||||
menu.append(
|
||||
new MenuItem(menuUtils.commandToStatefulMenuItem(view.commandName, itemId))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
menu.popup(bridge().window());
|
||||
}
|
||||
|
||||
@@ -584,6 +612,8 @@ class SideBarComponent extends React.Component<Props, State> {
|
||||
// }
|
||||
|
||||
render() {
|
||||
this.pluginsRef.current = this.props.plugins;
|
||||
|
||||
const theme = themeStyle(this.props.themeId);
|
||||
|
||||
const items = [];
|
||||
@@ -668,7 +698,7 @@ class SideBarComponent extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: any) => {
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
return {
|
||||
folders: state.folders,
|
||||
tags: state.tags,
|
||||
@@ -685,6 +715,7 @@ const mapStateToProps = (state: any) => {
|
||||
collapsedFolderIds: state.collapsedFolderIds,
|
||||
decryptionWorker: state.decryptionWorker,
|
||||
resourceFetcher: state.resourceFetcher,
|
||||
plugins: state.pluginService.plugins,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -49,10 +49,24 @@
|
||||
<script src="./lib.js"></script>
|
||||
|
||||
<script>
|
||||
// This is function used internally to send message from the webview to
|
||||
// the host.
|
||||
const ipcProxySendToHost = (methodName, arg) => {
|
||||
window.postMessage({ target: 'main', name: methodName, args: [ arg ] }, '*');
|
||||
}
|
||||
|
||||
// This function is reserved for plugin, currently only to allow
|
||||
// executing a command, but more features could be added to the object
|
||||
// later on.
|
||||
const webviewApi = {
|
||||
executeCommand: function (commandName, ...args) {
|
||||
return ipcProxySendToHost('contentScriptExecuteCommand', {
|
||||
name: commandName,
|
||||
args: args,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let pluginAssetsAdded_ = {};
|
||||
|
||||
try {
|
||||
|
||||
2
packages/app-desktop/package-lock.json
generated
2
packages/app-desktop/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/app-desktop",
|
||||
"version": "1.5.6",
|
||||
"version": "1.5.7",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@joplin/app-desktop",
|
||||
"version": "1.5.6",
|
||||
"version": "1.5.7",
|
||||
"description": "Joplin for Desktop",
|
||||
"main": "main.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dist": "npm run electronRebuild && node_modules/.bin/electron-builder",
|
||||
"dist": "npm run electronRebuild && npx electron-builder",
|
||||
"build": "gulp build",
|
||||
"postinstall": "npm run build",
|
||||
"electronRebuild": "gulp electronRebuild",
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
# It could be used to develop plugins too.
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
PLUGIN_PATH="$SCRIPT_DIR/../app-cli/tests/support/plugins/editor_context_menu"
|
||||
PLUGIN_PATH="$SCRIPT_DIR/../app-cli/tests/support/plugins/register_command"
|
||||
npm i --prefix="$PLUGIN_PATH" && npm start -- --dev-plugins "$PLUGIN_PATH"
|
||||
@@ -20,14 +20,20 @@ export default class JoplinPlugins {
|
||||
*/
|
||||
register(script: Script): Promise<void>;
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
globalValue(key: string): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { Disposable } from './types';
|
||||
declare enum ItemChangeEventType {
|
||||
Create = 1,
|
||||
Update = 2,
|
||||
Delete = 3,
|
||||
}
|
||||
interface ItemChangeEvent {
|
||||
id: string;
|
||||
event: ItemChangeEventType;
|
||||
}
|
||||
interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
declare type ItemChangeHandler = (event: ItemChangeEvent)=> void;
|
||||
declare type SyncStartHandler = (event: SyncStartEvent)=> void;
|
||||
/**
|
||||
* 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.
|
||||
* 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;
|
||||
constructor(_implementation: any, store: any);
|
||||
constructor(store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
onNoteSelectionChange(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* 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: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteChange(handler: ItemChangeHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
onNoteAlarmTrigger(handler: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process is starting.
|
||||
*/
|
||||
onSyncStart(handler: SyncStartHandler): Promise<Disposable>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
onSyncComplete(callback: Function): Promise<Disposable>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
@@ -32,3 +58,4 @@ export default class JoplinWorkspace {
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -189,6 +189,10 @@ export interface Script {
|
||||
onStart?(event: any): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
@@ -204,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location: MenuItemLocation): boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -318,9 +359,9 @@ export interface SettingSection {
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
* - **[0]**: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* - **[1]**: (Optional) Resource ID.
|
||||
* - **[2]**: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
||||
|
||||
@@ -330,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -346,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -367,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -378,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -388,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
2
packages/generator-joplin/package-lock.json
generated
2
packages/generator-joplin/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-joplin",
|
||||
"version": "1.4.5",
|
||||
"version": "1.5.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -68,15 +68,15 @@ export default class Plugin {
|
||||
return Object.keys(this.viewControllers_).length;
|
||||
}
|
||||
|
||||
on(eventName: string, callback: Function) {
|
||||
public on(eventName: string, callback: Function) {
|
||||
return this.eventEmitter_.on(eventName, callback);
|
||||
}
|
||||
|
||||
off(eventName: string, callback: Function) {
|
||||
public off(eventName: string, callback: Function) {
|
||||
return this.eventEmitter_.removeListener(eventName, callback);
|
||||
}
|
||||
|
||||
emit(eventName: string, event: any = null) {
|
||||
public emit(eventName: string, event: any = null) {
|
||||
return this.eventEmitter_.emit(eventName, event);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ export default class PluginService extends BaseService {
|
||||
}
|
||||
|
||||
for (const pluginPath of pluginPaths) {
|
||||
if (pluginPath.indexOf('_') === 0) {
|
||||
if (filename(pluginPath).indexOf('_') === 0) {
|
||||
logger.info(`Plugin name starts with "_" and has not been loaded: ${pluginPath}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export default class JoplinPlugins {
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
async register(script: Script) {
|
||||
public async register(script: Script) {
|
||||
if (script.onStart) {
|
||||
const startTime = Date.now();
|
||||
|
||||
@@ -51,20 +51,26 @@ export default class JoplinPlugins {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||
* Registers a new content script. Unlike regular plugin code, which
|
||||
* runs in a separate process, content scripts run within the main
|
||||
* process code and thus allow improved performances and more
|
||||
* customisations in specific cases. It can be used for example to load
|
||||
* a Markdown or editor plugin.
|
||||
*
|
||||
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
* Note that registering a content script in itself will do nothing -
|
||||
* it will only be loaded in specific cases by the relevant app modules
|
||||
* (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.
|
||||
*
|
||||
* [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
*
|
||||
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
|
||||
* @param id A unique ID for the content script.
|
||||
* @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`.
|
||||
*/
|
||||
async registerContentScript(type: ContentScriptType, id: string, scriptPath: string) {
|
||||
public async registerContentScript(type: ContentScriptType, id: string, scriptPath: string) {
|
||||
return this.plugin.registerContentScript(type, id, scriptPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export default class JoplinSettings {
|
||||
*
|
||||
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||
* https://github.com/laurent22/joplin/blob/dev/packages/lib/models/Setting.ts#L142
|
||||
*/
|
||||
async globalValue(key: string): Promise<any> {
|
||||
return Setting.value(key);
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface Command {
|
||||
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||
*
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts).
|
||||
*
|
||||
* Note: Commands are enabled by default unless you use this property.
|
||||
*/
|
||||
@@ -208,12 +208,49 @@ export enum MenuItemLocation {
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
|
||||
/**
|
||||
* @deprecated Do not use - same as NoteListContextMenu
|
||||
*/
|
||||
Context = 'context',
|
||||
|
||||
// If adding an item here, don't forget to update isContextMenuItemLocation()
|
||||
|
||||
/**
|
||||
* When a command is called from the note list context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `noteIds:string[]`: IDs of the notes that were right-clicked on.
|
||||
*/
|
||||
NoteListContextMenu = 'noteListContextMenu',
|
||||
|
||||
EditorContextMenu = 'editorContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a folder context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `folderId:string`: ID of the folder that was right-clicked on
|
||||
*/
|
||||
FolderContextMenu = 'folderContextMenu',
|
||||
|
||||
/**
|
||||
* When a command is called from a tag context menu, the
|
||||
* command will receive the following arguments:
|
||||
*
|
||||
* - `tagId:string`: ID of the tag that was right-clicked on
|
||||
*/
|
||||
TagContextMenu = 'tagContextMenu',
|
||||
}
|
||||
|
||||
export function isContextMenuItemLocation(location:MenuItemLocation):boolean {
|
||||
return [
|
||||
MenuItemLocation.Context,
|
||||
MenuItemLocation.NoteListContextMenu,
|
||||
MenuItemLocation.EditorContextMenu,
|
||||
MenuItemLocation.FolderContextMenu,
|
||||
MenuItemLocation.TagContextMenu,
|
||||
].includes(location);
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
@@ -334,7 +371,8 @@ export type Path = string[];
|
||||
|
||||
export enum ContentScriptType {
|
||||
/**
|
||||
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||
* Registers a new Markdown-It plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -350,14 +388,49 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* See [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* for a simple Markdown-it plugin example.
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* ## Exported members
|
||||
*
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - The **required** `plugin` key is the actual Markdown-It plugin -
|
||||
* check the [official
|
||||
* doc](https://github.com/markdown-it/markdown-it) for more
|
||||
* information. The `options` parameter is of type
|
||||
* [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml.ts),
|
||||
* which contains a number of options, mostly useful for Joplin's
|
||||
* internal code.
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||
* - Using the **optional** `assets` key you may specify assets such as
|
||||
* JS or CSS that should be loaded in the rendered HTML document.
|
||||
* Check for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* ## Passing messages from the content script to your plugin
|
||||
*
|
||||
* The application provides the following function to allow executing
|
||||
* commands from the rendered HTML code:
|
||||
*
|
||||
* `webviewApi.executeCommand(commandName, ...args)`
|
||||
*
|
||||
* So you can use this mechanism to pass messages from the note viewer
|
||||
* to your own plugin. To do so you would define a command, using
|
||||
* `joplin.commands.register`, then you would call this command using
|
||||
* the `webviewApi` object. See again [the
|
||||
* demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
|
||||
* to see how this can be done.
|
||||
*
|
||||
* ## Registering an existing Markdown-it plugin
|
||||
*
|
||||
* To include a regular Markdown-It plugin, that doesn't make use of
|
||||
* any Joplin-specific features, you would simply create a file such as
|
||||
* this:
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -371,7 +444,8 @@ export enum ContentScriptType {
|
||||
*/
|
||||
MarkdownItPlugin = 'markdownItPlugin',
|
||||
/**
|
||||
* Registers a new CodeMirror plugin, which should follow the template below.
|
||||
* Registers a new CodeMirror plugin, which should follow the template
|
||||
* below.
|
||||
*
|
||||
* ```javascript
|
||||
* module.exports = {
|
||||
@@ -382,8 +456,8 @@ export enum ContentScriptType {
|
||||
* },
|
||||
* codeMirrorResources: [],
|
||||
* codeMirrorOptions: {
|
||||
* // ...
|
||||
* },
|
||||
* // ...
|
||||
* },
|
||||
* assets: {
|
||||
* // ...
|
||||
* },
|
||||
@@ -392,19 +466,42 @@ export enum ContentScriptType {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
|
||||
* - The `context` argument is currently unused but could be used later
|
||||
* on to provide access to your own plugin so that the content script
|
||||
* and plugin can communicate.
|
||||
*
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
|
||||
* - The `plugin` key is your CodeMirror plugin. This is where you can
|
||||
* register new commands with CodeMirror or interact with the
|
||||
* CodeMirror instance as needed.
|
||||
*
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
* - The `codeMirrorResources` key is an array of CodeMirror resources
|
||||
* that will be loaded and attached to the CodeMirror module. These
|
||||
* are made up of addons, keymaps, and modes. For example, for a
|
||||
* plugin that want's to enable clojure highlighting in code blocks.
|
||||
* `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
|
||||
*
|
||||
* - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
|
||||
* - The `codeMirrorOptions` key contains all the
|
||||
* [CodeMirror](https://codemirror.net/doc/manual.html#config)
|
||||
* options that will be set or changed by this plugin. New options
|
||||
* can alse be declared via
|
||||
* [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption),
|
||||
* and then have their value set here. For example, a plugin that
|
||||
* enables line numbers would set `codeMirrorOptions` to
|
||||
* `{'lineNumbers': true}`.
|
||||
*
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS assets that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||
* - Using the **optional** `assets` key you may specify **only** CSS
|
||||
* assets that should be loaded in the rendered HTML document. Check
|
||||
* for example the Joplin [Mermaid
|
||||
* plugin](https://github.com/laurent22/joplin/blob/dev/packages/renderer/MdToHtml/rules/mermaid.ts)
|
||||
* to see how the data should be structured.
|
||||
*
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
|
||||
* One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions`
|
||||
* keys must be provided for the plugin to be valid. Having multiple or
|
||||
* all provided is also okay.
|
||||
*
|
||||
* See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
|
||||
* See the [demo
|
||||
* plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script)
|
||||
* for an example of all these keys being used in one plugin.
|
||||
*/
|
||||
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ interface RendererRule {
|
||||
install(context: any, ruleOptions: any): any;
|
||||
assets?(theme: any): any;
|
||||
plugin?: any;
|
||||
assetPath?: string;
|
||||
}
|
||||
|
||||
interface RendererRules {
|
||||
@@ -197,7 +198,7 @@ export default class MdToHtml {
|
||||
|
||||
if (options.extraRendererRules) {
|
||||
for (const rule of options.extraRendererRules) {
|
||||
this.loadExtraRendererRule(rule.id, rule.module);
|
||||
this.loadExtraRendererRule(rule.id, rule.assetPath, rule.module);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,15 +233,28 @@ export default class MdToHtml {
|
||||
}
|
||||
|
||||
// `module` is a file that has already been `required()`
|
||||
public loadExtraRendererRule(id: string, module: any) {
|
||||
public loadExtraRendererRule(id: string, assetPath: string, module: any) {
|
||||
if (this.extraRendererRules_[id]) throw new Error(`A renderer rule with this ID has already been loaded: ${id}`);
|
||||
this.extraRendererRules_[id] = module;
|
||||
this.extraRendererRules_[id] = {
|
||||
...module,
|
||||
assetPath,
|
||||
};
|
||||
}
|
||||
|
||||
private ruleByKey(key: string): RendererRule {
|
||||
if (rules[key]) return rules[key];
|
||||
if (this.extraRendererRules_[key]) return this.extraRendererRules_[key];
|
||||
if (key === 'highlight.js') return null;
|
||||
throw new Error(`No such rule: ${key}`);
|
||||
}
|
||||
|
||||
private processPluginAssets(pluginAssets: PluginAssets): RenderResult {
|
||||
const files: RenderResultPluginAsset[] = [];
|
||||
const cssStrings = [];
|
||||
for (const pluginName in pluginAssets) {
|
||||
|
||||
const rule = this.ruleByKey(pluginName);
|
||||
|
||||
for (const asset of pluginAssets[pluginName]) {
|
||||
let mime = asset.mime;
|
||||
|
||||
@@ -263,10 +277,18 @@ export default class MdToHtml {
|
||||
throw new Error(`Unsupported inline mime type: ${mime}`);
|
||||
}
|
||||
} else {
|
||||
// TODO: we should resolve the path using
|
||||
// resolveRelativePathWithinDir() for increased
|
||||
// security, but the shim is not accessible from the
|
||||
// renderer, and React Native doesn't have this
|
||||
// function, so for now use the provided path as-is.
|
||||
|
||||
const name = `${pluginName}/${asset.name}`;
|
||||
const assetPath = rule?.assetPath ? `${rule.assetPath}/${asset.name}` : `pluginAssets/${name}`;
|
||||
|
||||
files.push(Object.assign({}, asset, {
|
||||
name: name,
|
||||
path: `pluginAssets/${name}`,
|
||||
path: assetPath,
|
||||
mime: mime,
|
||||
}));
|
||||
}
|
||||
@@ -282,7 +304,7 @@ export default class MdToHtml {
|
||||
|
||||
// This return all the assets for all the plugins. Since it is called
|
||||
// on each render, the result is cached.
|
||||
private allProcessedAssets(theme: any, codeTheme: string) {
|
||||
private allProcessedAssets(rules: RendererRules, theme: any, codeTheme: string) {
|
||||
const cacheKey: string = theme.cacheKey + codeTheme;
|
||||
|
||||
if (this.allProcessedAssets_[cacheKey]) return this.allProcessedAssets_[cacheKey];
|
||||
@@ -501,7 +523,7 @@ export default class MdToHtml {
|
||||
|
||||
let cssStrings = noteStyle(options.theme);
|
||||
|
||||
let output = { ...this.allProcessedAssets(options.theme, options.codeTheme) };
|
||||
let output = { ...this.allProcessedAssets(allRules, options.theme, options.codeTheme) };
|
||||
cssStrings = cssStrings.concat(output.cssStrings);
|
||||
|
||||
if (options.userCss) cssStrings.push(options.userCss);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@joplin/renderer",
|
||||
"version": "1.0.17",
|
||||
"description": "The Joplin note renderer, used the mobile and desktop application",
|
||||
"repository": "https://github.com/laurent22/joplin/tree/dev/packages/app-mobile/lib/joplin-renderer",
|
||||
"repository": "https://github.com/laurent22/joplin/tree/dev/packages/renderer",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
fn: async function() {
|
||||
const copyOptions = {
|
||||
excluded: [
|
||||
`${rootDir}/packages/app-mobile/lib/joplin-renderer/node_modules`,
|
||||
`${rootDir}/packages/renderer/node_modules`,
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3.1\n"
|
||||
"X-Generator: Poedit 2.0.6\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
|
||||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
|
||||
#: packages/app-desktop/bridge.js:106 packages/app-desktop/bridge.js:110
|
||||
#: packages/app-desktop/bridge.js:126 packages/app-desktop/bridge.js:134
|
||||
@@ -62,16 +64,17 @@ msgstr "Отмена"
|
||||
msgid ""
|
||||
"The app is now going to close. Please relaunch it to complete the process."
|
||||
msgstr ""
|
||||
"Приложение будет закрыто. Пожалуйста, перезапустите его чтобы завершить "
|
||||
"установку."
|
||||
|
||||
#: packages/app-desktop/plugins/GotoAnything.js:431
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Type a note title or part of its content to jump to it. Or type # followed "
|
||||
"by a tag name, or @ followed by a notebook name. Or type : to search for "
|
||||
"commands."
|
||||
msgstr ""
|
||||
"Введите название заметки, чтобы перейти к ней, либо введите #имя_метки или "
|
||||
"@имя_блокнота."
|
||||
"@имя_блокнота, либо введите : для поиска команд."
|
||||
|
||||
#: packages/app-desktop/plugins/GotoAnything.js:456
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:20
|
||||
@@ -81,7 +84,7 @@ msgstr "Перейти к чему-либо…"
|
||||
#: packages/app-desktop/plugins/GotoAnything.js:463
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:28
|
||||
msgid "Command palette"
|
||||
msgstr ""
|
||||
msgstr "Палитра команд"
|
||||
|
||||
#: packages/app-desktop/InteropServiceHelper.js:153
|
||||
#, javascript-format
|
||||
@@ -117,9 +120,8 @@ msgid "New version: %s"
|
||||
msgstr "Новая версия: %s"
|
||||
|
||||
#: packages/app-desktop/checkForUpdates.js:154
|
||||
#, fuzzy
|
||||
msgid "Download"
|
||||
msgstr "Загружено"
|
||||
msgstr "Загрузить"
|
||||
|
||||
#: packages/app-desktop/checkForUpdates.js:154
|
||||
msgid "Full Release Notes"
|
||||
@@ -279,9 +281,8 @@ msgid "strong text"
|
||||
msgstr "полужирный текст"
|
||||
|
||||
#: packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.js:166
|
||||
#, fuzzy
|
||||
msgid "emphasised text"
|
||||
msgstr "выделенный текст"
|
||||
msgstr "курсивный текст"
|
||||
|
||||
#: packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/CodeMirror.js:168
|
||||
msgid "Insert Hyperlink"
|
||||
@@ -415,13 +416,13 @@ msgstr "Создание новой %s..."
|
||||
|
||||
#: packages/app-desktop/gui/NoteEditor/NoteEditor.js:370
|
||||
msgid "The following attachments are being watched for changes:"
|
||||
msgstr ""
|
||||
msgstr "Отслеживаются изменения следующих вложений:"
|
||||
|
||||
#: packages/app-desktop/gui/NoteEditor/NoteEditor.js:373
|
||||
msgid ""
|
||||
"The attachments will no longer be watched when you switch to a different "
|
||||
"note."
|
||||
msgstr ""
|
||||
msgstr "Изменения не будут отслеживаться при переключении на другую заметку."
|
||||
|
||||
#: packages/app-desktop/gui/NoteEditor/NoteEditor.js:378
|
||||
#, javascript-format
|
||||
@@ -530,9 +531,9 @@ msgstr "Свойства заметки"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/KeymapConfigScreen.js:63
|
||||
#: packages/lib/services/KeymapService.js:415
|
||||
#, fuzzy, javascript-format
|
||||
#, javascript-format
|
||||
msgid "Error: %s"
|
||||
msgstr "Ошибка"
|
||||
msgstr "Ошибка: %s"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/KeymapConfigScreen.js:110
|
||||
#: packages/app-desktop/gui/EncryptionConfigScreen.min.js:443
|
||||
@@ -549,12 +550,11 @@ msgstr "Импорт"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/KeymapConfigScreen.js:126
|
||||
msgid "Command"
|
||||
msgstr ""
|
||||
msgstr "Команда"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/KeymapConfigScreen.js:127
|
||||
#, fuzzy
|
||||
msgid "Keyboard Shortcut"
|
||||
msgstr "Режим работы клавиатуры"
|
||||
msgstr "Сочетание клавиш"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:14
|
||||
#: packages/app-desktop/gui/MenuBar.js:148 packages/app-desktop/app.js:338
|
||||
@@ -577,9 +577,8 @@ msgid "Website and documentation"
|
||||
msgstr "Сайт и документация"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:24
|
||||
#, fuzzy
|
||||
msgid "Hide Joplin"
|
||||
msgstr "О Joplin"
|
||||
msgstr "Скрыть Joplin"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:26
|
||||
#: packages/app-desktop/gui/MenuBar.js:400
|
||||
@@ -587,9 +586,8 @@ msgid "Close Window"
|
||||
msgstr "Закрыть окно"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:30
|
||||
#, fuzzy
|
||||
msgid "Preferences"
|
||||
msgstr "Настройки…"
|
||||
msgstr "Настройки"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:30
|
||||
#: packages/app-desktop/gui/MenuBar.js:276 packages/app-desktop/gui/Root.js:100
|
||||
@@ -597,19 +595,20 @@ msgid "Options"
|
||||
msgstr "Настройки"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/utils/getLabel.js:37
|
||||
#, fuzzy
|
||||
msgid "Invalid"
|
||||
msgstr "Неверный ответ: %s"
|
||||
msgstr "Недопустимо"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/ShortcutRecorder.js:49
|
||||
msgid "Press the shortcut"
|
||||
msgstr ""
|
||||
msgstr "Нажмите нужное сочетание клавиш"
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/ShortcutRecorder.js:49
|
||||
msgid ""
|
||||
"Press the shortcut and then press ENTER. Or, press BACKSPACE to clear the "
|
||||
"shortcut."
|
||||
msgstr ""
|
||||
"Нажмите нужное сочетание клавиш и затем нажмите Enter. Для очистки сочетания "
|
||||
"клавиш нажмите Backspace."
|
||||
|
||||
#: packages/app-desktop/gui/KeymapConfig/ShortcutRecorder.js:50
|
||||
#: packages/app-desktop/gui/EncryptionConfigScreen.min.js:96
|
||||
@@ -623,11 +622,13 @@ msgid ""
|
||||
"may take a few minutes to complete and the app needs to be restarted. To "
|
||||
"proceed please click on the link."
|
||||
msgstr ""
|
||||
"Нужно обновить версию базы данных перед синхронизацией. Эта операция может "
|
||||
"потребовать несколько минут для завершения и приложение нужно будет "
|
||||
"перезапустить. Чтобы продолжить нажмите на ссылку."
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/MainScreen.js:404
|
||||
#, fuzzy
|
||||
msgid "Restart and upgrade"
|
||||
msgstr "Мастер-ключи, которые нуждаются в обновлении"
|
||||
msgstr "Перезапустить и обновить"
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/MainScreen.js:408
|
||||
msgid "Some items cannot be synchronised."
|
||||
@@ -670,6 +671,8 @@ msgstr "Дополнительная информация"
|
||||
#: packages/app-desktop/gui/MainScreen/MainScreen.js:527
|
||||
msgid "Use the arrows to move the layout items. Press \"Escape\" to exit."
|
||||
msgstr ""
|
||||
"Используйте стрелки чтобы переместить элементы программы. Нажмите Esc для "
|
||||
"выхода."
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/commands/showNoteContentProperties.js:18
|
||||
msgid "Statistics..."
|
||||
@@ -733,13 +736,12 @@ msgid "Toggle editor layout"
|
||||
msgstr "Переключить вид редактора"
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/commands/toggleEditors.js:18
|
||||
#, fuzzy
|
||||
msgid "Toggle editors"
|
||||
msgstr "Переключить вид редактора"
|
||||
msgstr "Переключить редактор"
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.js:16
|
||||
msgid "Change application layout"
|
||||
msgstr ""
|
||||
msgstr "Изменить расположение элементов"
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/commands/renameTag.js:30
|
||||
msgid "Rename tag:"
|
||||
@@ -756,7 +758,7 @@ msgstr "Название блокнота:"
|
||||
#: packages/app-desktop/gui/MainScreen/commands/showSpellCheckerMenu.js:19
|
||||
#: packages/lib/services/spellChecker/SpellCheckerService.js:180
|
||||
msgid "Spell checker"
|
||||
msgstr ""
|
||||
msgstr "Проверка орфографии"
|
||||
|
||||
#: packages/app-desktop/gui/MainScreen/commands/showShareNoteDialog.js:16
|
||||
msgid "Share note..."
|
||||
@@ -948,7 +950,6 @@ msgid "Templates"
|
||||
msgstr "Шаблоны"
|
||||
|
||||
#: packages/app-desktop/gui/MenuBar.js:369
|
||||
#, fuzzy
|
||||
msgid "Export all"
|
||||
msgstr "Экспорт"
|
||||
|
||||
@@ -981,7 +982,7 @@ msgstr "Отдалить"
|
||||
|
||||
#: packages/app-desktop/gui/MenuBar.js:533
|
||||
msgid "&Go"
|
||||
msgstr ""
|
||||
msgstr "Переход"
|
||||
|
||||
#: packages/app-desktop/gui/MenuBar.js:545
|
||||
msgid "&Note"
|
||||
@@ -1025,7 +1026,7 @@ msgstr "Загрузить сейчас:"
|
||||
msgid ""
|
||||
"New notebook \"%s\" will be created and file \"%s\" will be imported into it"
|
||||
msgstr ""
|
||||
"Будет создан новый блокнот \"%s\" и в него будет импортирован файл \"%s\""
|
||||
"Будет создан новый блокнот \"%s\" и файл \"%s\" будет импортирован в него"
|
||||
|
||||
#: packages/app-desktop/gui/ImportScreen.min.js:68
|
||||
#: packages/app-cli/app/command-import.js:47
|
||||
@@ -1189,7 +1190,7 @@ msgstr "Шифрование"
|
||||
|
||||
#: packages/app-desktop/gui/EncryptionConfigScreen.min.js:213
|
||||
msgid "Ignore"
|
||||
msgstr ""
|
||||
msgstr "Игнорировать"
|
||||
|
||||
#: packages/app-desktop/gui/EncryptionConfigScreen.min.js:244
|
||||
#: packages/app-mobile/components/screens/encryption-config.js:215
|
||||
@@ -1366,7 +1367,7 @@ msgstr "Обзор..."
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/ConfigScreen.js:456
|
||||
msgid "The application must be restarted for these changes to take effect."
|
||||
msgstr ""
|
||||
msgstr "Необходимо перезапустить приложение, чтобы применились изменения."
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/ConfigScreen.js:468
|
||||
#: packages/app-desktop/gui/NoteList/NoteList.js:163
|
||||
@@ -1375,25 +1376,24 @@ msgstr "Загрузить сейчас"
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/ConfigScreen.js:468
|
||||
msgid "Later"
|
||||
msgstr ""
|
||||
msgstr "Позже"
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/ConfigScreen.js:521
|
||||
#, fuzzy
|
||||
msgid "Restart now"
|
||||
msgstr "Загрузить сейчас:"
|
||||
msgstr "Перезагрузить сейчас"
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/ButtonBar.js:27
|
||||
msgid "Apply"
|
||||
msgstr "Применить"
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/controls/PluginsStates.js:137
|
||||
#, fuzzy, javascript-format
|
||||
#, javascript-format
|
||||
msgid "Delete plugin \"%s\"?"
|
||||
msgstr "Удалить заметку \"%s\"?"
|
||||
msgstr "Удалить плагин \"%s\"?"
|
||||
|
||||
#: packages/app-desktop/gui/ConfigScreen/controls/PluginsStates.js:181
|
||||
msgid "Install plugin"
|
||||
msgstr ""
|
||||
msgstr "Установить плагин"
|
||||
|
||||
#: packages/app-desktop/gui/PromptDialog.min.js:249
|
||||
msgid "Clear"
|
||||
@@ -1518,7 +1518,6 @@ msgid "Please wait..."
|
||||
msgstr "Пожалуйста, подождите…"
|
||||
|
||||
#: packages/app-desktop/gui/ResourceScreen.js:143
|
||||
#, fuzzy
|
||||
msgid "No resources!"
|
||||
msgstr "Нет данных!"
|
||||
|
||||
@@ -1572,12 +1571,11 @@ msgstr "Выйти из внешнего редактора"
|
||||
|
||||
#: packages/app-desktop/commands/toggleExternalEditing.js:37
|
||||
msgid "Stop"
|
||||
msgstr ""
|
||||
msgstr "Остановить"
|
||||
|
||||
#: packages/app-desktop/commands/copyDevCommand.js:18
|
||||
#, fuzzy
|
||||
msgid "Copy dev mode command to clipboard"
|
||||
msgstr "Скопировать путь в буфер обмена"
|
||||
msgstr "Скопировать команду режима разработчика в буфер обмена"
|
||||
|
||||
#: packages/app-desktop/commands/stopExternalEditing.js:18
|
||||
msgid "Stop external editing"
|
||||
@@ -1594,9 +1592,8 @@ msgid "Error opening note in editor: %s"
|
||||
msgstr "Ошибка при открытии заметки в редакторе: %s"
|
||||
|
||||
#: packages/app-desktop/commands/openProfileDirectory.js:18
|
||||
#, fuzzy
|
||||
msgid "Open profile directory"
|
||||
msgstr "Открыть папку с шаблонами"
|
||||
msgstr "Открыть директорию с настройками"
|
||||
|
||||
#: packages/app-desktop/app.js:336
|
||||
#, javascript-format
|
||||
@@ -1624,9 +1621,8 @@ msgid "Save alarm"
|
||||
msgstr "Сохранить напоминание"
|
||||
|
||||
#: packages/app-mobile/components/NoteBodyViewer/hooks/useOnResourceLongPress.js:28
|
||||
#, fuzzy
|
||||
msgid "Open"
|
||||
msgstr "Открыть..."
|
||||
msgstr "Открыть"
|
||||
|
||||
#: packages/app-mobile/components/NoteBodyViewer/hooks/useOnResourceLongPress.js:29
|
||||
#: packages/app-mobile/components/screens/Note.js:796
|
||||
@@ -1698,7 +1694,7 @@ msgstr "Обновить"
|
||||
|
||||
#: packages/app-mobile/components/screens/UpgradeSyncTargetScreen.js:42
|
||||
msgid "Sync Target Upgrade"
|
||||
msgstr ""
|
||||
msgstr "Обновление цели синхронизации"
|
||||
|
||||
#: packages/app-mobile/components/screens/notes.js:154
|
||||
#: packages/app-cli/app/command-rmbook.js:26
|
||||
@@ -1915,11 +1911,14 @@ msgid ""
|
||||
"\n"
|
||||
"You may turn off this option at any time in the Configuration screen."
|
||||
msgstr ""
|
||||
"Для возможности сохранения информации в заметке о географическом "
|
||||
"местоположении приложению необходим доступ к вашему местоположению.\n"
|
||||
"\n"
|
||||
"Вы можете выключить эту опцию в любое время в Конфигурации."
|
||||
|
||||
#: packages/app-mobile/components/screens/Note.js:343
|
||||
#, fuzzy
|
||||
msgid "Permission needed"
|
||||
msgstr "Разрешение на использование камеры"
|
||||
msgstr "Необходимы разрешения"
|
||||
|
||||
#: packages/app-mobile/components/screens/Note.js:449
|
||||
#: packages/app-cli/app/command-rmnote.js:27
|
||||
@@ -2159,9 +2158,8 @@ msgid "AWS S3 bucket"
|
||||
msgstr "AWS S3 bucket"
|
||||
|
||||
#: packages/lib/models/Setting.js:226
|
||||
#, fuzzy
|
||||
msgid "AWS S3 URL"
|
||||
msgstr "AWS S3"
|
||||
msgstr "AWS S3 URL"
|
||||
|
||||
#: packages/lib/models/Setting.js:237
|
||||
msgid "AWS key"
|
||||
@@ -2399,9 +2397,8 @@ msgstr ""
|
||||
"умолчанию."
|
||||
|
||||
#: packages/lib/models/Setting.js:609
|
||||
#, fuzzy
|
||||
msgid "Custom stylesheet for rendered Markdown"
|
||||
msgstr "Пользовательская таблица стилей для приложения"
|
||||
msgstr "Пользовательская таблица стилей для отображаемых заметок"
|
||||
|
||||
#: packages/lib/models/Setting.js:625
|
||||
msgid "Custom stylesheet for Joplin-wide app styles"
|
||||
@@ -2634,9 +2631,8 @@ msgid "Web Clipper"
|
||||
msgstr "Настройки веб-клиппера"
|
||||
|
||||
#: packages/lib/models/Setting.js:1337
|
||||
#, fuzzy
|
||||
msgid "Keyboard Shortcuts"
|
||||
msgstr "Режим работы клавиатуры"
|
||||
msgstr "Сочетания клавиш"
|
||||
|
||||
#: packages/lib/models/Setting.js:1344
|
||||
msgid ""
|
||||
@@ -2988,14 +2984,15 @@ msgid "HTML Directory"
|
||||
msgstr "HTML каталог"
|
||||
|
||||
#: packages/lib/services/interop/InteropService.js:127
|
||||
#, fuzzy, javascript-format
|
||||
#, javascript-format
|
||||
msgid "Cannot load \"%s\" module for format \"%s\" and output \"%s\""
|
||||
msgstr "Не удалось загрузить модуль \"%s\" для формата \"%s\""
|
||||
msgstr ""
|
||||
"Не удалось загрузить модуль \"%s\" для форматирования \"%s\" и вывода \"%s\""
|
||||
|
||||
#: packages/lib/services/interop/InteropService.js:150
|
||||
#, fuzzy, javascript-format
|
||||
#, javascript-format
|
||||
msgid "Cannot load \"%s\" module for format \"%s\" and target \"%s\""
|
||||
msgstr "Не удалось загрузить модуль \"%s\" для формата \"%s\""
|
||||
msgstr "Не удалось загрузить модуль \"%s\" для формата \"%s\" и цели \"%s\""
|
||||
|
||||
#: packages/lib/services/interop/InteropService.js:194
|
||||
#: packages/lib/services/interop/InteropService.js:206
|
||||
@@ -3033,23 +3030,23 @@ msgstr "Пожалуйста, укажите формат импорта для
|
||||
|
||||
#: packages/lib/services/KeymapService.js:512
|
||||
msgid "command"
|
||||
msgstr ""
|
||||
msgstr "команда"
|
||||
|
||||
#: packages/lib/services/KeymapService.js:512
|
||||
#: packages/lib/services/KeymapService.js:517
|
||||
#, javascript-format
|
||||
msgid "\"%s\" is missing the required \"%s\" property."
|
||||
msgstr ""
|
||||
msgstr "В \"%s\" отсутствует необходимое свойство \"%s\"."
|
||||
|
||||
#: packages/lib/services/KeymapService.js:517
|
||||
#: packages/lib/services/KeymapService.js:524
|
||||
msgid "accelerator"
|
||||
msgstr ""
|
||||
msgstr "сочетание клавиш"
|
||||
|
||||
#: packages/lib/services/KeymapService.js:524
|
||||
#, fuzzy, javascript-format
|
||||
#, javascript-format
|
||||
msgid "Invalid %s: %s."
|
||||
msgstr "Неверный ответ: %s"
|
||||
msgstr "Недопустимое \"%s\": %s."
|
||||
|
||||
#: packages/lib/services/KeymapService.js:542
|
||||
#, javascript-format
|
||||
@@ -3057,11 +3054,13 @@ msgid ""
|
||||
"Accelerator \"%s\" is used for \"%s\" and \"%s\" commands. This may lead to "
|
||||
"unexpected behaviour."
|
||||
msgstr ""
|
||||
"Сочетание клавиш \"%s\" используется для команд \"%s\" и \"%s\". Это может "
|
||||
"привести к неожиданному поведению."
|
||||
|
||||
#: packages/lib/services/KeymapService.js:567
|
||||
#, javascript-format
|
||||
msgid "Accelerator \"%s\" is not valid."
|
||||
msgstr ""
|
||||
msgstr "Сочетание клавиш \"%s\" недопустимо."
|
||||
|
||||
#: packages/lib/services/report.js:121
|
||||
msgid "Items that cannot be synchronised"
|
||||
@@ -3177,20 +3176,19 @@ msgstr "В %s: %s"
|
||||
|
||||
#: packages/lib/services/spellChecker/SpellCheckerService.js:107
|
||||
msgid "No suggestions"
|
||||
msgstr ""
|
||||
msgstr "Нет вариантов"
|
||||
|
||||
#: packages/lib/services/spellChecker/SpellCheckerService.js:114
|
||||
msgid "Add to dictionary"
|
||||
msgstr ""
|
||||
msgstr "Добавить в словарь"
|
||||
|
||||
#: packages/lib/services/spellChecker/SpellCheckerService.js:153
|
||||
msgid "Use spell checker"
|
||||
msgstr ""
|
||||
msgstr "Использовать проверку орфографии"
|
||||
|
||||
#: packages/lib/services/spellChecker/SpellCheckerService.js:173
|
||||
#, fuzzy
|
||||
msgid "Change language"
|
||||
msgstr "Язык"
|
||||
msgstr "Изменить язык"
|
||||
|
||||
#: packages/app-cli/app/command-cp.js:13
|
||||
msgid ""
|
||||
@@ -3412,7 +3410,7 @@ msgstr ""
|
||||
|
||||
#: packages/app-cli/app/command-sync.js:35
|
||||
msgid "Upgrade the sync target to the latest version."
|
||||
msgstr ""
|
||||
msgstr "Обновить цель синхронизации до последней версии."
|
||||
|
||||
#: packages/app-cli/app/command-sync.js:105
|
||||
#, javascript-format
|
||||
@@ -3442,7 +3440,6 @@ msgid "Synchronisation target: %s (%s)"
|
||||
msgstr "Цель синхронизации: %s (%s)"
|
||||
|
||||
#: packages/app-cli/app/command-sync.js:177
|
||||
#, fuzzy
|
||||
msgid "Cannot initialise synchroniser."
|
||||
msgstr "Не удалось инициализировать модуль синхронизации."
|
||||
|
||||
@@ -3458,6 +3455,7 @@ msgstr "Загрузка ресурсов..."
|
||||
#, javascript-format
|
||||
msgid "Sync target must be upgraded! Run `%s` to proceed."
|
||||
msgstr ""
|
||||
"Цель синхронизации необходимо обновить! Выполните \"%s\" чтобы продолжить."
|
||||
|
||||
#: packages/app-cli/app/command-sync.js:260
|
||||
msgid "Cancelling... Please wait."
|
||||
@@ -3532,7 +3530,7 @@ msgstr "Пожалуйста, сначала выберите заметку и
|
||||
|
||||
#: packages/app-cli/app/app-gui.js:750
|
||||
msgid "Press Ctrl+D or type \"exit\" to exit the application"
|
||||
msgstr "Для выхода из приложения нажмите Ctrl+D или введите \"exit\""
|
||||
msgstr "Нажмите Ctrl+D или введите \"exit\" для выхода из приложения"
|
||||
|
||||
#: packages/app-cli/app/command-rmnote.js:13
|
||||
msgid "Deletes the notes matching <note-pattern>."
|
||||
@@ -3854,7 +3852,6 @@ msgstr "Заметка не является задачей: \"%s\""
|
||||
#~ msgid "Notebook properties"
|
||||
#~ msgstr "Свойства блокнота"
|
||||
|
||||
#, javascript-format
|
||||
#~ msgid "This file could not be opened: %s"
|
||||
#~ msgstr "Этот файл не может быть открыт: %s"
|
||||
|
||||
@@ -3882,7 +3879,6 @@ msgstr "Заметка не является задачей: \"%s\""
|
||||
#~ msgid "Move to notebook..."
|
||||
#~ msgstr "Переместить в блокнот..."
|
||||
|
||||
#, javascript-format
|
||||
#~ msgid "Move %d notes to notebook \"%s\"?"
|
||||
#~ msgstr "Переместить %d заметок в блокнот \"%s\"?"
|
||||
|
||||
@@ -3900,11 +3896,9 @@ msgstr "Заметка не является задачей: \"%s\""
|
||||
#~ msgid "Errors only"
|
||||
#~ msgstr "Только ошибки"
|
||||
|
||||
#, javascript-format
|
||||
#~ msgid "Database v%s"
|
||||
#~ msgstr "База данных v%s"
|
||||
|
||||
#, javascript-format
|
||||
#~ msgid "FTS enabled: %d"
|
||||
#~ msgstr "FTS включен: %d"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user