mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
add switch button
This commit is contained in:
@@ -16,27 +16,10 @@ interface Command {
|
||||
export default class RibbonCommands {
|
||||
plugin: ObsidianSyncNotionPlugin;
|
||||
|
||||
|
||||
Ncommand: Command[] = [];
|
||||
|
||||
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;
|
||||
constructor(plugin: ObsidianSyncNotionPlugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
// Check if NextButton is true, then include the corresponding command
|
||||
if (this.plugin.settings.NextButton) {
|
||||
@@ -60,16 +43,68 @@ export default class RibbonCommands {
|
||||
});
|
||||
}
|
||||
|
||||
// Register all the commands
|
||||
this.Ncommand.forEach(command => {
|
||||
this.plugin.addCommand(
|
||||
{
|
||||
id: command.id,
|
||||
name: command.name,
|
||||
editorCallback: command.editorCallback,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
// Register all the commands
|
||||
this.Ncommand.forEach(command => {
|
||||
this.plugin.addCommand(
|
||||
{
|
||||
id: command.id,
|
||||
name: command.name,
|
||||
editorCallback: command.editorCallback,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
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()})
|
||||
};
|
||||
|
||||
// if the setting has been changed, try to rebuild the command list
|
||||
async updateCommand() {
|
||||
|
||||
this.Ncommand = [];
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.Ncommand.forEach(command => {
|
||||
this.plugin.addCommand(
|
||||
{
|
||||
id: command.id,
|
||||
name: command.name,
|
||||
editorCallback: command.editorCallback,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ export const I18n: { [key: string]: any } = {
|
||||
DatabaseIDText: "Enter your Database ID",
|
||||
BannerUrl: "Banner url(optional)",
|
||||
BannerUrlDesc:
|
||||
"page banner url(optional), default is empty, if you want to show a banner, please enter the url(like: https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
||||
"Default is empty, if you want to show a banner, please enter the url(like: https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
||||
BannerUrlText: "Enter your banner url",
|
||||
NotionUser: "Notion ID(username, optional)",
|
||||
NotionUserDesc:
|
||||
"Your notion ID (optional),share link likes:https://username.notion.site/,your notion id is [username]",
|
||||
NotionUserText: "Enter your notion ID (options)",
|
||||
NotionUserText: "Enter your notion ID",
|
||||
NotionGeneralSettingHeader: "General Notion Database Settings",
|
||||
NotionGeneralButton: "Notion General command switch",
|
||||
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette",
|
||||
@@ -63,12 +63,12 @@ export const I18n: { [key: string]: any } = {
|
||||
DatabaseIDText: "输入你的数据库 ID",
|
||||
BannerUrl: "封面图片地址(可选)",
|
||||
BannerUrlDesc:
|
||||
"页面封面图片地址(可选),默认为空,如果你想显示封面图片,请输入图片地址(例如:https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
||||
"默认为空,如果你想显示封面图片,请输入图片地址(例如:https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
||||
BannerUrlText: "输入你的封面图片地址",
|
||||
NotionUser: "Notion ID(用户名,可选)",
|
||||
NotionUserDesc:
|
||||
"你的 Notion ID(可选),分享链接类似:https://username.notion.site/,你的 Notion ID 是 [username]",
|
||||
NotionUserText: "输入你的 Notion ID(可选)",
|
||||
NotionUserText: "输入你的 Notion ID",
|
||||
NotionGeneralSettingHeader: "普通 Notion 数据库设置",
|
||||
NotionGeneralButton: "普通数据库同步命令开关",
|
||||
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中",
|
||||
|
||||
@@ -48,18 +48,6 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
|
||||
containerEl.createEl('h2', {text: i18nConfig.GeneralSetting})
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionNextButton)
|
||||
.setDesc(i18nConfig.NotionNextButtonDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.NextButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.NextButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.BannerUrl)
|
||||
.setDesc(i18nConfig.BannerUrlDesc)
|
||||
@@ -89,6 +77,19 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
|
||||
containerEl.createEl('h2', {text: i18nConfig.NotionNextSettingHeader})
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionNextButton)
|
||||
.setDesc(i18nConfig.NotionNextButtonDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.NextButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.NextButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionAPI)
|
||||
.setDesc(i18nConfig.NotionAPIDesc)
|
||||
@@ -136,6 +137,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.GeneralButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -182,18 +184,18 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
|
||||
// Custom Database Settings
|
||||
|
||||
containerEl.createEl('h2', {text: i18nConfig.NotionCustomSettingHeader});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionCustomButton)
|
||||
.setDesc(i18nConfig.NotionCustomButtonDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.CustomButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.CustomButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
// containerEl.createEl('h2', {text: i18nConfig.NotionCustomSettingHeader});
|
||||
//
|
||||
// new Setting(containerEl)
|
||||
// .setName(i18nConfig.NotionCustomButton)
|
||||
// .setDesc(i18nConfig.NotionCustomButtonDesc)
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.plugin.settings.CustomButton)
|
||||
// .onChange(async (value) => {
|
||||
// this.plugin.settings.CustomButton = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user