1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00
joplin/packages/app-desktop/gui/dialogs.ts

40 lines
978 B
TypeScript
Raw Normal View History

import Logger from '@joplin/utils/Logger';
// Can't upgrade beyond 2.x because it doesn't work with Electron. If trying to
// upgrade again, check that adding a link from the CodeMirror editor works/
const smalltalk = require('smalltalk');
const logger = Logger.create('dialogs');
2017-12-24 10:36:31 +02:00
class Dialogs {
public async alert(message: string, title = '') {
2017-12-24 10:36:31 +02:00
await smalltalk.alert(title, message);
}
public async confirm(message: string, title = '', options: any = {}) {
2017-12-24 10:36:31 +02:00
try {
await smalltalk.confirm(title, message, options);
2017-12-24 10:36:31 +02:00
return true;
} catch (error) {
logger.error(error);
2017-12-24 10:36:31 +02:00
return false;
}
}
public async prompt(message: string, title = '', defaultValue = '', options: any = null) {
2017-12-24 10:36:31 +02:00
if (options === null) options = {};
try {
const answer = await smalltalk.prompt(title, message, defaultValue, options);
return answer;
} catch (error) {
logger.error(error);
2017-12-24 10:36:31 +02:00
return null;
}
}
}
const dialogs = new Dialogs();
export default dialogs;