1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Plugins: Add support for showOpenDialog method

This commit is contained in:
Laurent Cozic
2023-10-31 15:29:19 +00:00
parent 0a2c3b3a91
commit dd47571dff
6 changed files with 24 additions and 4 deletions

View File

@ -57,9 +57,12 @@ export default class PlatformImplementation extends BasePlatformImplementation {
this.joplin_ = { this.joplin_ = {
views: { views: {
dialogs: { dialogs: {
showMessageBox: async function(message: string) { showMessageBox: async (message: string) => {
return bridge().showMessageBox(message); return bridge().showMessageBox(message);
}, },
showOpenDialog: async (options) => {
return bridge().showOpenDialog(options);
},
}, },
}, },
}; };

View File

@ -43,6 +43,12 @@ export default class JoplinViewsDialogs {
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */
showMessageBox(message: string): Promise<number>; showMessageBox(message: string): Promise<number>;
/**
* Displays a dialog to select a file or a directory. Same options and
* output as
* https://www.electronjs.org/docs/latest/api/dialog#dialogshowopendialogbrowserwindow-options
*/
showOpenDialog(options: any): Promise<any>;
/** /**
* Sets the dialog HTML content * Sets the dialog HTML content
*/ */

View File

@ -1,5 +1,5 @@
import { Size } from './types'; import { Size } from './types';
type ListRendererDatabaseDependency = 'folder.created_time' | 'folder.encryption_applied' | 'folder.encryption_cipher_text' | 'folder.icon' | 'folder.id' | 'folder.is_shared' | 'folder.master_key_id' | 'folder.parent_id' | 'folder.share_id' | 'folder.title' | 'folder.updated_time' | 'folder.user_created_time' | 'folder.user_updated_time' | 'folder.type_' | 'note.altitude' | 'note.application_data' | 'note.author' | 'note.body' | 'note.conflict_original_id' | 'note.created_time' | 'note.encryption_applied' | 'note.encryption_cipher_text' | 'note.id' | 'note.is_conflict' | 'note.is_shared' | 'note.is_todo' | 'note.latitude' | 'note.longitude' | 'note.markup_language' | 'note.master_key_id' | 'note.order' | 'note.parent_id' | 'note.share_id' | 'note.source' | 'note.source_application' | 'note.source_url' | 'note.title' | 'note.todo_completed' | 'note.todo_due' | 'note.updated_time' | 'note.user_created_time' | 'note.user_data' | 'note.user_updated_time' | 'note.type_'; type ListRendererDatabaseDependency = 'folder.created_time' | 'folder.encryption_applied' | 'folder.encryption_cipher_text' | 'folder.icon' | 'folder.id' | 'folder.is_shared' | 'folder.master_key_id' | 'folder.parent_id' | 'folder.share_id' | 'folder.title' | 'folder.updated_time' | 'folder.user_created_time' | 'folder.user_data' | 'folder.user_updated_time' | 'folder.type_' | 'note.altitude' | 'note.application_data' | 'note.author' | 'note.body' | 'note.conflict_original_id' | 'note.created_time' | 'note.encryption_applied' | 'note.encryption_cipher_text' | 'note.id' | 'note.is_conflict' | 'note.is_shared' | 'note.is_todo' | 'note.latitude' | 'note.longitude' | 'note.markup_language' | 'note.master_key_id' | 'note.order' | 'note.parent_id' | 'note.share_id' | 'note.source' | 'note.source_application' | 'note.source_url' | 'note.title' | 'note.todo_completed' | 'note.todo_due' | 'note.updated_time' | 'note.user_created_time' | 'note.user_data' | 'note.user_updated_time' | 'note.type_';
export declare enum ItemFlow { export declare enum ItemFlow {
TopToBottom = "topToBottom", TopToBottom = "topToBottom",
LeftToRight = "leftToRight" LeftToRight = "leftToRight"

View File

@ -3,7 +3,7 @@
import { Size } from './types'; import { Size } from './types';
// AUTO-GENERATED by generate-database-type // AUTO-GENERATED by generate-database-type
type ListRendererDatabaseDependency = 'folder.created_time' | 'folder.encryption_applied' | 'folder.encryption_cipher_text' | 'folder.icon' | 'folder.id' | 'folder.is_shared' | 'folder.master_key_id' | 'folder.parent_id' | 'folder.share_id' | 'folder.title' | 'folder.updated_time' | 'folder.user_created_time' | 'folder.user_updated_time' | 'folder.type_' | 'note.altitude' | 'note.application_data' | 'note.author' | 'note.body' | 'note.conflict_original_id' | 'note.created_time' | 'note.encryption_applied' | 'note.encryption_cipher_text' | 'note.id' | 'note.is_conflict' | 'note.is_shared' | 'note.is_todo' | 'note.latitude' | 'note.longitude' | 'note.markup_language' | 'note.master_key_id' | 'note.order' | 'note.parent_id' | 'note.share_id' | 'note.source' | 'note.source_application' | 'note.source_url' | 'note.title' | 'note.todo_completed' | 'note.todo_due' | 'note.updated_time' | 'note.user_created_time' | 'note.user_data' | 'note.user_updated_time' | 'note.type_'; type ListRendererDatabaseDependency = 'folder.created_time' | 'folder.encryption_applied' | 'folder.encryption_cipher_text' | 'folder.icon' | 'folder.id' | 'folder.is_shared' | 'folder.master_key_id' | 'folder.parent_id' | 'folder.share_id' | 'folder.title' | 'folder.updated_time' | 'folder.user_created_time' | 'folder.user_data' | 'folder.user_updated_time' | 'folder.type_' | 'note.altitude' | 'note.application_data' | 'note.author' | 'note.body' | 'note.conflict_original_id' | 'note.created_time' | 'note.encryption_applied' | 'note.encryption_cipher_text' | 'note.id' | 'note.is_conflict' | 'note.is_shared' | 'note.is_todo' | 'note.latitude' | 'note.longitude' | 'note.markup_language' | 'note.master_key_id' | 'note.order' | 'note.parent_id' | 'note.share_id' | 'note.source' | 'note.source_application' | 'note.source_url' | 'note.title' | 'note.todo_completed' | 'note.todo_due' | 'note.updated_time' | 'note.user_created_time' | 'note.user_data' | 'note.user_updated_time' | 'note.type_';
// AUTO-GENERATED by generate-database-type // AUTO-GENERATED by generate-database-type
export enum ItemFlow { export enum ItemFlow {

View File

@ -7,6 +7,7 @@ import { Implementation as ImagingImplementation } from './api/JoplinImaging';
export interface JoplinViewsDialogs { export interface JoplinViewsDialogs {
showMessageBox(message: string): Promise<number>; showMessageBox(message: string): Promise<number>;
showOpenDialog(options: any): Promise<any>;
} }
export interface JoplinViews { export interface JoplinViews {

View File

@ -5,6 +5,7 @@ import createViewHandle from '../utils/createViewHandle';
import WebviewController, { ContainerType } from '../WebviewController'; import WebviewController, { ContainerType } from '../WebviewController';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; import { ButtonSpec, ViewHandle, DialogResult } from './types';
import { _ } from '../../../locale'; import { _ } from '../../../locale';
import { JoplinViewsDialogs as JoplinViewsDialogsImplementation } from '../BasePlatformImplementation';
/** /**
* Allows creating and managing dialogs. A dialog is modal window that * Allows creating and managing dialogs. A dialog is modal window that
@ -39,7 +40,7 @@ export default class JoplinViewsDialogs {
private store: any; private store: any;
private plugin: Plugin; private plugin: Plugin;
private implementation_: any; private implementation_: JoplinViewsDialogsImplementation;
public constructor(implementation: any, plugin: Plugin, store: any) { public constructor(implementation: any, plugin: Plugin, store: any) {
this.store = store; this.store = store;
@ -73,6 +74,15 @@ export default class JoplinViewsDialogs {
return this.implementation_.showMessageBox(`${_('(In plugin: %s)', this.plugin.manifest.name)}\n\n${message}`); return this.implementation_.showMessageBox(`${_('(In plugin: %s)', this.plugin.manifest.name)}\n\n${message}`);
} }
/**
* Displays a dialog to select a file or a directory. Same options and
* output as
* https://www.electronjs.org/docs/latest/api/dialog#dialogshowopendialogbrowserwindow-options
*/
public async showOpenDialog(options: any): Promise<any> {
return this.implementation_.showOpenDialog(options);
}
/** /**
* Sets the dialog HTML content * Sets the dialog HTML content
*/ */