mirror of
https://github.com/laurent22/joplin.git
synced 2025-04-14 11:18:47 +02:00
Merge branch 'dev' into release-2.5
This commit is contained in:
commit
59ea52f018
@ -153,12 +153,12 @@ export default class InteropServiceHelper {
|
|||||||
|
|
||||||
if (module.target === 'file') {
|
if (module.target === 'file') {
|
||||||
const noteId = options.sourceNoteIds && options.sourceNoteIds.length ? options.sourceNoteIds[0] : null;
|
const noteId = options.sourceNoteIds && options.sourceNoteIds.length ? options.sourceNoteIds[0] : null;
|
||||||
path = bridge().showSaveDialog({
|
path = await bridge().showSaveDialog({
|
||||||
filters: [{ name: module.description, extensions: module.fileExtensions }],
|
filters: [{ name: module.description, extensions: module.fileExtensions }],
|
||||||
defaultPath: await this.defaultFilename(noteId, module.fileExtensions[0]),
|
defaultPath: await this.defaultFilename(noteId, module.fileExtensions[0]),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
path = bridge().showOpenDialog({
|
path = await bridge().showOpenDialog({
|
||||||
properties: ['openDirectory', 'createDirectory'],
|
properties: ['openDirectory', 'createDirectory'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -125,25 +125,25 @@ export class Bridge {
|
|||||||
return this.window().webContents.closeDevTools();
|
return this.window().webContents.closeDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
showSaveDialog(options: any) {
|
async showSaveDialog(options: any) {
|
||||||
const { dialog } = require('electron');
|
const { dialog } = require('electron');
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
if (!('defaultPath' in options) && this.lastSelectedPaths_.file) options.defaultPath = this.lastSelectedPaths_.file;
|
if (!('defaultPath' in options) && this.lastSelectedPaths_.file) options.defaultPath = this.lastSelectedPaths_.file;
|
||||||
const filePath = dialog.showSaveDialogSync(this.window(), options);
|
const { filePath } = await dialog.showSaveDialog(this.window(), options);
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
this.lastSelectedPaths_.file = filePath;
|
this.lastSelectedPaths_.file = filePath;
|
||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
showOpenDialog(options: any = null) {
|
async showOpenDialog(options: any = null) {
|
||||||
const { dialog } = require('electron');
|
const { dialog } = require('electron');
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
let fileType = 'file';
|
let fileType = 'file';
|
||||||
if (options.properties && options.properties.includes('openDirectory')) fileType = 'directory';
|
if (options.properties && options.properties.includes('openDirectory')) fileType = 'directory';
|
||||||
if (!('defaultPath' in options) && this.lastSelectedPaths_[fileType]) options.defaultPath = this.lastSelectedPaths_[fileType];
|
if (!('defaultPath' in options) && this.lastSelectedPaths_[fileType]) options.defaultPath = this.lastSelectedPaths_[fileType];
|
||||||
if (!('createDirectory' in options)) options.createDirectory = true;
|
if (!('createDirectory' in options)) options.createDirectory = true;
|
||||||
const filePaths = dialog.showOpenDialogSync(this.window(), options);
|
const { filePaths } = await dialog.showOpenDialog(this.window(), options);
|
||||||
if (filePaths && filePaths.length) {
|
if (filePaths && filePaths.length) {
|
||||||
this.lastSelectedPaths_[fileType] = dirname(filePaths[0]);
|
this.lastSelectedPaths_[fileType] = dirname(filePaths[0]);
|
||||||
}
|
}
|
||||||
|
@ -481,8 +481,8 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
|||||||
updateSettingValue(key, joinCmd(cmd));
|
updateSettingValue(key, joinCmd(cmd));
|
||||||
};
|
};
|
||||||
|
|
||||||
const browseButtonClick = () => {
|
const browseButtonClick = async () => {
|
||||||
const paths = bridge().showOpenDialog();
|
const paths = await bridge().showOpenDialog();
|
||||||
if (!paths || !paths.length) return;
|
if (!paths || !paths.length) return;
|
||||||
const cmd = splitCmd(this.state.settings[key]);
|
const cmd = splitCmd(this.state.settings[key]);
|
||||||
cmd[0] = paths[0];
|
cmd[0] = paths[0];
|
||||||
|
@ -181,7 +181,7 @@ export default function(props: Props) {
|
|||||||
}, [pluginSettings, props.onChange]);
|
}, [pluginSettings, props.onChange]);
|
||||||
|
|
||||||
const onInstall = useCallback(async () => {
|
const onInstall = useCallback(async () => {
|
||||||
const result = bridge().showOpenDialog({
|
const result = await bridge().showOpenDialog({
|
||||||
filters: [{ name: 'Joplin Plugin Archive', extensions: ['jpl'] }],
|
filters: [{ name: 'Joplin Plugin Archive', extensions: ['jpl'] }],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export const KeymapConfigScreen = ({ themeId }: KeymapConfigScreenProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleImport = async () => {
|
const handleImport = async () => {
|
||||||
const filePath = bridge().showOpenDialog({
|
const filePath = await bridge().showOpenDialog({
|
||||||
properties: ['openFile'],
|
properties: ['openFile'],
|
||||||
defaultPath: 'keymap-desktop',
|
defaultPath: 'keymap-desktop',
|
||||||
filters: [{ name: 'Joplin Keymaps (keymap-desktop.json)', extensions: ['json'] }],
|
filters: [{ name: 'Joplin Keymaps (keymap-desktop.json)', extensions: ['json'] }],
|
||||||
@ -68,7 +68,7 @@ export const KeymapConfigScreen = ({ themeId }: KeymapConfigScreenProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
const filePath = bridge().showSaveDialog({
|
const filePath = await bridge().showSaveDialog({
|
||||||
defaultPath: 'keymap-desktop',
|
defaultPath: 'keymap-desktop',
|
||||||
filters: [{ name: 'Joplin Keymaps (keymap-desktop.json)', extensions: ['json'] }],
|
filters: [{ name: 'Joplin Keymaps (keymap-desktop.json)', extensions: ['json'] }],
|
||||||
});
|
});
|
||||||
|
@ -20,12 +20,12 @@ export const runtime = (comp: any): CommandRuntime => {
|
|||||||
|
|
||||||
let path = null;
|
let path = null;
|
||||||
if (noteIds.length === 1) {
|
if (noteIds.length === 1) {
|
||||||
path = bridge().showSaveDialog({
|
path = await bridge().showSaveDialog({
|
||||||
filters: [{ name: _('PDF File'), extensions: ['pdf'] }],
|
filters: [{ name: _('PDF File'), extensions: ['pdf'] }],
|
||||||
defaultPath: await InteropServiceHelper.defaultFilename(noteIds[0], 'pdf'),
|
defaultPath: await InteropServiceHelper.defaultFilename(noteIds[0], 'pdf'),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
path = bridge().showOpenDialog({
|
path = await bridge().showOpenDialog({
|
||||||
properties: ['openDirectory', 'createDirectory'],
|
properties: ['openDirectory', 'createDirectory'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -180,11 +180,11 @@ function useMenu(props: Props) {
|
|||||||
let path = null;
|
let path = null;
|
||||||
|
|
||||||
if (moduleSource === 'file') {
|
if (moduleSource === 'file') {
|
||||||
path = bridge().showOpenDialog({
|
path = await bridge().showOpenDialog({
|
||||||
filters: [{ name: module.description, extensions: module.fileExtensions }],
|
filters: [{ name: module.description, extensions: module.fileExtensions }],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
path = bridge().showOpenDialog({
|
path = await bridge().showOpenDialog({
|
||||||
properties: ['openDirectory', 'createDirectory'],
|
properties: ['openDirectory', 'createDirectory'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ export function menuItems(dispatch: Function): ContextMenuItems {
|
|||||||
label: _('Save as...'),
|
label: _('Save as...'),
|
||||||
onAction: async (options: ContextMenuOptions) => {
|
onAction: async (options: ContextMenuOptions) => {
|
||||||
const { resourcePath, resource } = await resourceInfo(options);
|
const { resourcePath, resource } = await resourceInfo(options);
|
||||||
const filePath = bridge().showSaveDialog({
|
const filePath = await bridge().showSaveDialog({
|
||||||
defaultPath: resource.filename ? resource.filename : resource.title,
|
defaultPath: resource.filename ? resource.filename : resource.title,
|
||||||
});
|
});
|
||||||
if (!filePath) return;
|
if (!filePath) return;
|
||||||
|
@ -65,7 +65,7 @@ export async function commandAttachFileToBody(body: string, filePaths: string[]
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!filePaths) {
|
if (!filePaths) {
|
||||||
filePaths = bridge().showOpenDialog({
|
filePaths = await bridge().showOpenDialog({
|
||||||
properties: ['openFile', 'createDirectory', 'multiSelections'],
|
properties: ['openFile', 'createDirectory', 'multiSelections'],
|
||||||
});
|
});
|
||||||
if (!filePaths || !filePaths.length) return null;
|
if (!filePaths || !filePaths.length) return null;
|
||||||
|
@ -25,7 +25,7 @@ const StyledAdvancedToolItem = styled.div`
|
|||||||
async function exportDebugReportClick() {
|
async function exportDebugReportClick() {
|
||||||
const filename = `syncReport-${new Date().getTime()}.csv`;
|
const filename = `syncReport-${new Date().getTime()}.csv`;
|
||||||
|
|
||||||
const filePath = bridge().showSaveDialog({
|
const filePath = await bridge().showSaveDialog({
|
||||||
title: _('Please select where the sync status should be exported to'),
|
title: _('Please select where the sync status should be exported to'),
|
||||||
defaultPath: filename,
|
defaultPath: filename,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user