add button to display the command in the command palette

This commit is contained in:
Jiaxin Peng
2023-11-11 00:29:35 +00:00
parent afec5d8364
commit 041a78fb52
4 changed files with 94 additions and 37 deletions

View File

@@ -4,28 +4,20 @@ import {FuzzySuggester, DatabaseList} from "./FuzzySuggester";
import {uploadCommandGeneral, uploadCommandNext} from "../upload/uploadCommand";
import ObsidianSyncNotionPlugin from "src/main";
interface Command {
id: string;
name: string;
editorCallback: (editor: Editor, view: MarkdownView) => Promise<void>;
}
// create the commands list
export default class RibbonCommands {
plugin: ObsidianSyncNotionPlugin;
// Total commands that will be used
Ncommand = [
{
id: "share-to-notionnext",
name: i18nConfig.CommandName, // Use the translated text from i18nConfig
editorCallback: async (editor: Editor, view: MarkdownView) => {
// await this.plugin.uploadCommand()
await uploadCommandNext(this.plugin, this.plugin.settings, this.plugin.app)
}
},
{
id: "share-to-notion",
name: i18nConfig.CommandNameGeneral, // Use the translated text from i18nConfig
editorCallback: async (editor: Editor, view: MarkdownView) => {
await uploadCommandGeneral(this.plugin, this.plugin.settings, this.plugin.app);
}
}
];
Ncommand: Command[] = [];
async ribbonDisplay() {
const NcommandList: DatabaseList[] = [];
@@ -46,6 +38,28 @@ export default class RibbonCommands {
constructor(plugin: ObsidianSyncNotionPlugin) {
this.plugin = plugin;
// Check if NextButton is true, then include the corresponding command
if (this.plugin.settings.NextButton) {
this.Ncommand.push({
id: "share-to-notionnext",
name: i18nConfig.CommandName, // Use the translated text from i18nConfig
editorCallback: async (editor: Editor, view: MarkdownView) => {
await uploadCommandNext(this.plugin, this.plugin.settings, this.plugin.app);
}
});
}
// Check if GeneralButton is true, then include the corresponding command
if (this.plugin.settings.GeneralButton) {
this.Ncommand.push({
id: "share-to-notion",
name: i18nConfig.CommandNameGeneral, // Use the translated text from i18nConfig
editorCallback: async (editor: Editor, view: MarkdownView) => {
await uploadCommandGeneral(this.plugin, this.plugin.settings, this.plugin.app);
}
});
}
// Register all the commands
this.Ncommand.forEach(command => {
this.plugin.addCommand(