You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
// Allows referencing the Joplin global:
|
|
/* eslint-disable no-undef */
|
|
|
|
// Allows the `joplin-manifest` block comment:
|
|
/* eslint-disable multiline-comment-style */
|
|
|
|
/* joplin-manifest:
|
|
{
|
|
"id": "org.joplinapp.plugins.example.dialogs",
|
|
"manifest_version": 1,
|
|
"app_min_version": "3.1",
|
|
"name": "JS Bundle test",
|
|
"description": "JS Bundle Test plugin",
|
|
"version": "1.0.0",
|
|
"author": "",
|
|
"homepage_url": "https://joplinapp.org"
|
|
}
|
|
*/
|
|
|
|
joplin.plugins.register({
|
|
onStart: async function() {
|
|
const dialogs = joplin.views.dialogs;
|
|
const dialogHandle = await dialogs.create('test-dialog');
|
|
await dialogs.setHtml(
|
|
dialogHandle,
|
|
`
|
|
<form name="main-form">
|
|
<label>Test: <input type="checkbox" name="test" checked/></label>
|
|
</form>
|
|
`,
|
|
);
|
|
await dialogs.setButtons(dialogHandle, [
|
|
{
|
|
id: 'ok',
|
|
title: 'Okay',
|
|
},
|
|
]);
|
|
await joplin.commands.register({
|
|
name: 'showTestDialog',
|
|
label: 'showTestDialog',
|
|
iconName: 'fas fa-drum',
|
|
execute: async () => {
|
|
const result = await joplin.views.dialogs.open(dialogHandle);
|
|
await joplin.commands.execute('editor.setText', JSON.stringify({
|
|
id: result.id,
|
|
hasFormData: !!result.formData,
|
|
}));
|
|
},
|
|
});
|
|
|
|
await joplin.commands.register({
|
|
name: 'getTestDialogVisibility',
|
|
label: 'Returns the dialog visibility state',
|
|
execute: async () => {
|
|
// panels.visible should also work for dialogs.
|
|
const visible = await joplin.views.panels.visible(dialogHandle);
|
|
// For dialogs, isActive should return the visibility.
|
|
// (Prefer panels.visible for dialogs).
|
|
const active = await joplin.views.panels.isActive(dialogHandle);
|
|
|
|
await joplin.commands.execute('editor.setText', JSON.stringify({
|
|
visible,
|
|
active,
|
|
}));
|
|
},
|
|
});
|
|
},
|
|
});
|