diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts +++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/webpack.config.js b/packages/app-cli/tests/support/plugins/codemirror_content_script/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/codemirror_content_script/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/content_script/api/types.ts b/packages/app-cli/tests/support/plugins/content_script/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/content_script/api/types.ts +++ b/packages/app-cli/tests/support/plugins/content_script/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/content_script/webpack.config.js b/packages/app-cli/tests/support/plugins/content_script/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/content_script/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/content_script/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/dialog/api/types.ts b/packages/app-cli/tests/support/plugins/dialog/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/dialog/api/types.ts +++ b/packages/app-cli/tests/support/plugins/dialog/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/dialog/webpack.config.js b/packages/app-cli/tests/support/plugins/dialog/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/dialog/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/dialog/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts +++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/webpack.config.js b/packages/app-cli/tests/support/plugins/editor_context_menu/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/editor_context_menu/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/editor_context_menu/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/events/api/types.ts b/packages/app-cli/tests/support/plugins/events/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/events/api/types.ts +++ b/packages/app-cli/tests/support/plugins/events/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/events/webpack.config.js b/packages/app-cli/tests/support/plugins/events/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/events/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/events/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/external_assets/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/external_assets/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/external_assets/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/external_assets/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/external_assets/api/types.ts b/packages/app-cli/tests/support/plugins/external_assets/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/external_assets/api/types.ts +++ b/packages/app-cli/tests/support/plugins/external_assets/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/external_assets/webpack.config.js b/packages/app-cli/tests/support/plugins/external_assets/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/external_assets/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/external_assets/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts +++ b/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/jpl_test/webpack.config.js b/packages/app-cli/tests/support/plugins/jpl_test/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/jpl_test/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/jpl_test/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/json_export/api/types.ts b/packages/app-cli/tests/support/plugins/json_export/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/json_export/api/types.ts +++ b/packages/app-cli/tests/support/plugins/json_export/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/json_export/webpack.config.js b/packages/app-cli/tests/support/plugins/json_export/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/json_export/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/json_export/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/menu/api/types.ts b/packages/app-cli/tests/support/plugins/menu/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/menu/api/types.ts +++ b/packages/app-cli/tests/support/plugins/menu/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/menu/webpack.config.js b/packages/app-cli/tests/support/plugins/menu/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/menu/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/menu/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts +++ b/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/multi_selection/webpack.config.js b/packages/app-cli/tests/support/plugins/multi_selection/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/multi_selection/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/multi_selection/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/nativeModule/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/nativeModule/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/nativeModule/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/nativeModule/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/nativeModule/api/types.ts b/packages/app-cli/tests/support/plugins/nativeModule/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/nativeModule/api/types.ts +++ b/packages/app-cli/tests/support/plugins/nativeModule/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/nativeModule/webpack.config.js b/packages/app-cli/tests/support/plugins/nativeModule/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/nativeModule/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/nativeModule/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/post_messages/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/post_messages/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/post_messages/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/post_messages/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/post_messages/api/types.ts b/packages/app-cli/tests/support/plugins/post_messages/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/post_messages/api/types.ts +++ b/packages/app-cli/tests/support/plugins/post_messages/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/post_messages/webpack.config.js b/packages/app-cli/tests/support/plugins/post_messages/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/post_messages/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/post_messages/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/register_command/api/types.ts b/packages/app-cli/tests/support/plugins/register_command/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/register_command/api/types.ts +++ b/packages/app-cli/tests/support/plugins/register_command/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/register_command/webpack.config.js b/packages/app-cli/tests/support/plugins/register_command/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/register_command/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/register_command/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts new file mode 100644 index 000000000..8de655c83 --- /dev/null +++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts @@ -0,0 +1,17 @@ +import { ExportModule, ImportModule } from './types'; +/** + * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. + * + * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) + * + * To implement an import or export module, you would simply define an object with various event handlers that are called + * by the application during the import/export process. + * + * See the documentation of the [[ExportModule]] and [[ImportModule]] for more information. + * + * You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/ + */ +export default class JoplinInterop { + registerExportModule(module: ExportModule): Promise; + registerImportModule(module: ImportModule): Promise; +} diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/types.ts b/packages/app-cli/tests/support/plugins/selected_text/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/selected_text/api/types.ts +++ b/packages/app-cli/tests/support/plugins/selected_text/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/selected_text/webpack.config.js b/packages/app-cli/tests/support/plugins/selected_text/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/selected_text/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/selected_text/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/settings/api/types.ts b/packages/app-cli/tests/support/plugins/settings/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/settings/api/types.ts +++ b/packages/app-cli/tests/support/plugins/settings/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/settings/webpack.config.js b/packages/app-cli/tests/support/plugins/settings/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/settings/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/settings/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/toc/api/types.ts b/packages/app-cli/tests/support/plugins/toc/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/toc/api/types.ts +++ b/packages/app-cli/tests/support/plugins/toc/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/toc/webpack.config.js b/packages/app-cli/tests/support/plugins/toc/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/toc/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/toc/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts index 8a9f30451..3e3452bfb 100644 --- a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts +++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts +++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */ diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/webpack.config.js b/packages/app-cli/tests/support/plugins/withExternalModules/webpack.config.js index 47eafec06..d6052c5db 100644 --- a/packages/app-cli/tests/support/plugins/withExternalModules/webpack.config.js +++ b/packages/app-cli/tests/support/plugins/withExternalModules/webpack.config.js @@ -135,7 +135,9 @@ const pluginConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + // JSON files can also be required from scripts so we include this. + // https://github.com/joplin/plugin-bibtex/pull/2 + extensions: ['.tsx', '.ts', '.js', '.json'], }, output: { filename: 'index.js', @@ -167,7 +169,7 @@ const extraScriptConfig = Object.assign({}, baseConfig, { alias: { api: path.resolve(__dirname, 'api'), }, - extensions: ['.tsx', '.ts', '.js'], + extensions: ['.tsx', '.ts', '.js', '.json'], }, }); diff --git a/packages/generator-joplin/generators/app/templates/api/JoplinCommands.d.ts b/packages/generator-joplin/generators/app/templates/api/JoplinCommands.d.ts index e175d2e14..e4487cf33 100644 --- a/packages/generator-joplin/generators/app/templates/api/JoplinCommands.d.ts +++ b/packages/generator-joplin/generators/app/templates/api/JoplinCommands.d.ts @@ -19,6 +19,34 @@ import { Command } from './types'; * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. + * + * ## Executing editor commands + * + * There might be a situation where you want to invoke editor commands + * without using a {@link JoplinContentScripts | contentScript}. For this + * reason Joplin provides the built in `editor.execCommand` command. + * + * `editor.execCommand` should work with any core command in both the + * [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and + * [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors, + * as well as most functions calls directly on a CodeMirror editor object (extensions). + * + * * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands) + * * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands) + * + * `editor.execCommand` supports adding arguments for the commands. + * + * ```typescript + * await joplin.commands.execute('editor.execCommand', { + * name: 'madeUpCommand', // CodeMirror and TinyMCE + * args: [], // CodeMirror and TinyMCE + * ui: false, // TinyMCE only + * value: '', // TinyMCE only + * }); + * ``` + * + * [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts) + * */ export default class JoplinCommands { /** diff --git a/packages/generator-joplin/generators/app/templates/api/types.ts b/packages/generator-joplin/generators/app/templates/api/types.ts index ed817ba68..9c4aa7332 100644 --- a/packages/generator-joplin/generators/app/templates/api/types.ts +++ b/packages/generator-joplin/generators/app/templates/api/types.ts @@ -27,11 +27,12 @@ export interface Command { execute(...args: any[]): Promise; /** - * Defines whether the command should be enabled or disabled, which in turns affects - * the enabled state of any associated button or menu item. + * Defines whether the command should be enabled or disabled, which in turns + * affects the enabled state of any associated button or menu item. * - * The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to - * `true` or `false`. It supports the following operators: + * The condition should be expressed as a "when-clause" (as in Visual Studio + * Code). It's a simple boolean expression that evaluates to `true` or + * `false`. It supports the following operators: * * Operator | Symbol | Example * -- | -- | -- @@ -40,7 +41,15 @@ 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/lib/services/commands/stateToWhenClauseContext.ts). + * Joplin, unlike VSCode, also supports parenthesis, which allows creating + * more complex expressions such as `cond1 || (cond2 && cond3)`. Only one + * level of parenthesis is possible (nested ones aren't supported). + * + * Currently the supported context variables aren't documented, but you can + * find the list below: + * + * - [Global When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/lib/services/commands/stateToWhenClauseContext.ts) + * - [Desktop app When Clauses](https://github.com/laurent22/joplin/blob/dev/packages/app-desktop/services/commands/stateToWhenClauseContext.ts) * * Note: Commands are enabled by default unless you use this property. */