added JSP commands

This commit is contained in:
Ell 2023-08-13 17:23:21 +02:00
parent a5f20a15f2
commit 6c4b1022b0

View file

@ -42,6 +42,58 @@ export default class JustSharePleasePlugin extends Plugin {
} }
} }
})); }));
this.addCommand({
id: "share",
name: "Share current file to JSP",
editorCheckCallback: (checking, _, ctx) => {
if (!this.settings.shared.find(i => i.path == ctx.file.path)) {
if (!checking)
this.shareFile(ctx.file);
return true;
}
return false;
}
});
this.addCommand({
id: "copy",
name: "Copy current file's JSP link",
editorCheckCallback: (checking, _, ctx) => {
let shared = this.settings.shared.find(i => i.path == ctx.file.path);
if (shared) {
if (!checking)
this.copyShareLink(shared);
return true;
}
return false;
}
});
this.addCommand({
id: "update",
name: "Update current file in JSP",
editorCheckCallback: (checking, _, ctx) => {
let shared = this.settings.shared.find(i => i.path == ctx.file.path);
if (shared) {
if (!checking)
this.updateFile(shared, ctx.file);
return true;
}
return false;
}
});
this.addCommand({
id: "delete",
name: "Delete current file from JSP",
editorCheckCallback: (checking, _, ctx) => {
let shared = this.settings.shared.find(i => i.path == ctx.file.path);
if (shared) {
if (!checking)
this.deleteFile(shared);
return true;
}
return false;
}
});
} }
async loadSettings(): Promise<void> { async loadSettings(): Promise<void> {