feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,62 @@
|
||||
import Logger from '@joplin/utils/Logger';
|
||||
|
||||
const logger = Logger.create('dialogs');
|
||||
|
||||
interface Smalltalk {
|
||||
alert(title: string, message: string): Promise<boolean>;
|
||||
confirm(title: string, message: string, options: unknown): Promise<void>;
|
||||
prompt(title: string, message: string, defaultValue: string, options: unknown): Promise<string>;
|
||||
}
|
||||
|
||||
class Dialogs {
|
||||
private activeWindow: Window|null;
|
||||
public setActiveWindow(win: Window) {
|
||||
this.activeWindow = win;
|
||||
}
|
||||
|
||||
private get smalltalk(): Smalltalk {
|
||||
// The smalltalk library shows prompts in whichever document it is loaded in
|
||||
// (it uses the global document object).
|
||||
// As such, a copy of the library needs to be loaded in each window:
|
||||
if (this.activeWindow && 'smalltalk' in this.activeWindow) {
|
||||
return this.activeWindow.smalltalk as Smalltalk;
|
||||
}
|
||||
|
||||
if ('smalltalk' in window) {
|
||||
return window.smalltalk as Smalltalk;
|
||||
}
|
||||
|
||||
throw new Error('Unable to find the smalltalk library. Please make sure it has been loaded with a <script> element.');
|
||||
}
|
||||
|
||||
public async alert(message: string, title = '') {
|
||||
await this.smalltalk.alert(title, message);
|
||||
}
|
||||
|
||||
public async confirm(message: string, title = '', options: unknown = {}) {
|
||||
try {
|
||||
await this.smalltalk.confirm(title, message, options);
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async prompt(message: string, title = '', defaultValue = '', options: Record<string, unknown> = null) {
|
||||
options = { cancel: true, ...options };
|
||||
|
||||
try {
|
||||
// https://github.com/laurent22/joplin/pull/10258#discussion_r1550306545
|
||||
const answer = await this.smalltalk.prompt(title, message, defaultValue, options);
|
||||
return answer;
|
||||
} catch (error) {
|
||||
logger.warn('Prompt appears to have been cancelled:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const dialogs = new Dialogs();
|
||||
|
||||
export default dialogs;
|
||||
在新工单中引用
屏蔽一个用户