一些检查失败了
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
44 行
992 B
TypeScript
44 行
992 B
TypeScript
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
|
import { WindowControl } from '../utils/useWindowControl';
|
|
|
|
export const declaration: CommandDeclaration = {
|
|
name: 'showPrompt',
|
|
};
|
|
|
|
enum PromptInputType {
|
|
Dropdown = 'dropdown',
|
|
Datetime = 'datetime',
|
|
Tags = 'tags',
|
|
Text = 'text',
|
|
Password = 'password',
|
|
}
|
|
|
|
interface PromptConfig {
|
|
label: string;
|
|
inputType?: PromptInputType;
|
|
value?: string;
|
|
autocomplete?: unknown[];
|
|
buttons?: string[];
|
|
}
|
|
|
|
export const runtime = (comp: WindowControl): CommandRuntime => {
|
|
return {
|
|
execute: async (_context: CommandContext, config: PromptConfig) => {
|
|
return new Promise((resolve) => {
|
|
comp.setState({
|
|
promptOptions: {
|
|
...config,
|
|
onClose: async (answer: unknown, buttonType: unknown) => {
|
|
comp.setState({ promptOptions: null });
|
|
resolve({
|
|
answer: answer,
|
|
buttonType: buttonType,
|
|
});
|
|
},
|
|
},
|
|
});
|
|
});
|
|
},
|
|
};
|
|
};
|