2023-07-27 17:05:56 +02:00
|
|
|
import Logger from '@joplin/utils/Logger';
|
2023-01-11 16:00:36 +02:00
|
|
|
|
|
|
|
// 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 {
|
2023-03-06 16:22:01 +02:00
|
|
|
public async alert(message: string, title = '') {
|
2017-12-24 10:36:31 +02:00
|
|
|
await smalltalk.alert(title, message);
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async confirm(message: string, title = '', options: any = {}) {
|
2017-12-24 10:36:31 +02:00
|
|
|
try {
|
2020-11-19 14:34:49 +02:00
|
|
|
await smalltalk.confirm(title, message, options);
|
2017-12-24 10:36:31 +02:00
|
|
|
return true;
|
|
|
|
} catch (error) {
|
2023-01-11 16:00:36 +02:00
|
|
|
logger.error(error);
|
2017-12-24 10:36:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
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) {
|
2023-01-11 16:00:36 +02:00
|
|
|
logger.error(error);
|
2017-12-24 10:36:31 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const dialogs = new Dialogs();
|
|
|
|
|
2020-11-19 14:34:49 +02:00
|
|
|
export default dialogs;
|