mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-31 01:48:35 +08:00
add button to display the command in the command palette
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user