Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,17 @@ joplin.plugins.register({
command: "showPluginDocumentation"
}
]);
await commandsPanel.create();

await joplin.commands.register({
name: "showTemplatesPanel",
label: "Templates",
iconName: "far fa-file-alt",
execute: async () => {
await commandsPanel.create();
}
});

await joplin.views.menuItems.create("showTemplatesPanelMenuItem", "showTemplatesPanel", MenuItemLocation.Tools);
}
},
});
9 changes: 8 additions & 1 deletion src/views/commandsPanel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import joplin from "api";
import { PassThrough } from "stream";

export interface CommandButton {
label: string;
Expand All @@ -10,12 +9,19 @@ export class CommandsPanel {
private panelHandle: string;
private commands: CommandButton[];

private created = false;

constructor(commands: CommandButton[]) {
this.panelHandle = "templatesCommandsPanel";
this.commands = commands;
}

public async create(): Promise<void> {
if (this.created) {
await joplin.views.panels.show(this.panelHandle, true);
return;
}

try {
// Create the panel
this.panelHandle = await joplin.views.panels.create(this.panelHandle);
Expand All @@ -41,6 +47,7 @@ export class CommandsPanel {

// Show the panel
await joplin.views.panels.show(this.panelHandle, true);
this.created = true;
} catch (error) {
console.error("Error creating commands panel:", error);
throw error;
Expand Down