mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-31 18:18:36 +08:00
restructure the code for further feature
This commit is contained in:
61
src/commands/NotionCommands.ts
Normal file
61
src/commands/NotionCommands.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import {i18nConfig} from "src/lang/I18n";
|
||||
import {Editor, MarkdownView} from "obsidian";
|
||||
import {FuzzySuggester, DatabaseList} from "./FuzzySuggester";
|
||||
import {uploadCommand} from "../upload/uploadCommand";
|
||||
import ObsidianSyncNotionPlugin from "src/main";
|
||||
|
||||
// create the commands list
|
||||
export default class RibbonCommands {
|
||||
plugin: ObsidianSyncNotionPlugin;
|
||||
|
||||
// Total commands that will be used
|
||||
Ncommand = [
|
||||
{
|
||||
id: "share-to-notionnext",
|
||||
name: i18nConfig.ribbonIcon, // Use the translated text from i18nConfig
|
||||
editorCallback: async (editor: Editor, view: MarkdownView) => {
|
||||
// await this.plugin.uploadCommand()
|
||||
await uploadCommand(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 this.plugin.upload();
|
||||
// }
|
||||
// }
|
||||
];
|
||||
|
||||
async ribbonDisplay() {
|
||||
const NcommandList: DatabaseList[] = [];
|
||||
this.Ncommand.map(command => NcommandList.push(
|
||||
{
|
||||
name:command.name,
|
||||
match: command.editorCallback
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
const fusg = new FuzzySuggester(this.plugin);
|
||||
|
||||
fusg.setSuggesterData(NcommandList);
|
||||
await fusg.display(async (results) => {await results.match()})
|
||||
};
|
||||
|
||||
constructor(plugin: ObsidianSyncNotionPlugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
// Register all the commands
|
||||
this.Ncommand.forEach(command => {
|
||||
this.plugin.addCommand(
|
||||
{
|
||||
id: command.id,
|
||||
name: command.name,
|
||||
editorCallback: command.editorCallback,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user