mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-30 00:48:36 +08:00
@@ -3,6 +3,14 @@
|
|||||||
|
|
||||||
所以我在[原作者](https://github.com/EasyChris/obsidian-to-notion)的基础之上,增加了匹配[NotionNext](https://github.com/tangly1024/NotionNext)模板的功能。这样可以直接在Obsidian编辑,整理好之后一键发布。
|
所以我在[原作者](https://github.com/EasyChris/obsidian-to-notion)的基础之上,增加了匹配[NotionNext](https://github.com/tangly1024/NotionNext)模板的功能。这样可以直接在Obsidian编辑,整理好之后一键发布。
|
||||||
## 更新说明
|
## 更新说明
|
||||||
|
### 0.2.6
|
||||||
|
- 增加一个按钮用来控制是否在名列列表中显示如下数据库。
|
||||||
|
|
||||||
|

|
||||||
|
如果你关闭普通数据库的按钮,你在上传命令列表中就不会出现普通数据库的选项。如果你关闭NotionNext数据库的按钮,你在上传命令列表中就不会出现NotionNext数据库的选项。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### 0.2.3
|
### 0.2.3
|
||||||
- 修复了一个bug,现在可以正常更新了。
|
- 修复了一个bug,现在可以正常更新了。
|
||||||
### 0.2.2
|
### 0.2.2
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -5,6 +5,16 @@ Thanks to the [original author](https://github.com/EasyChris/obsidian-to-notion)
|
|||||||
|
|
||||||
Thus, based on the [original author's work](https://github.com/EasyChris/obsidian-to-notion), I've added a feature to match the [NotionNext](https://github.com/tangly1024/NotionNext) template. This way, you can edit directly in Obsidian and publish with a single click after organizing.
|
Thus, based on the [original author's work](https://github.com/EasyChris/obsidian-to-notion), I've added a feature to match the [NotionNext](https://github.com/tangly1024/NotionNext) template. This way, you can edit directly in Obsidian and publish with a single click after organizing.
|
||||||
## Update
|
## Update
|
||||||
|
### 0.2.6
|
||||||
|
- Add a switch button to control whether to show the upload command in the command palette.
|
||||||
|
|
||||||
|

|
||||||
|
If you turn off the button for the General database, you won't see the option for the General database in the upload command list.
|
||||||
|
|
||||||
|
If you turn off the button for the NotionNext database, you won't see the option for the NotionNext database in the upload command list.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### 0.2.3
|
### 0.2.3
|
||||||
- Fix the bug, now you can update normally.
|
- Fix the bug, now you can update normally.
|
||||||
### 0.2.2
|
### 0.2.2
|
||||||
|
|||||||
@@ -4,31 +4,60 @@ import {FuzzySuggester, DatabaseList} from "./FuzzySuggester";
|
|||||||
import {uploadCommandGeneral, uploadCommandNext} from "../upload/uploadCommand";
|
import {uploadCommandGeneral, uploadCommandNext} from "../upload/uploadCommand";
|
||||||
import ObsidianSyncNotionPlugin from "src/main";
|
import ObsidianSyncNotionPlugin from "src/main";
|
||||||
|
|
||||||
|
|
||||||
|
interface Command {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
editorCallback: (editor: Editor, view: MarkdownView) => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// create the commands list
|
// create the commands list
|
||||||
export default class RibbonCommands {
|
export default class RibbonCommands {
|
||||||
plugin: ObsidianSyncNotionPlugin;
|
plugin: ObsidianSyncNotionPlugin;
|
||||||
|
|
||||||
// Total commands that will be used
|
Ncommand: Command[] = [];
|
||||||
Ncommand = [
|
|
||||||
{
|
constructor(plugin: ObsidianSyncNotionPlugin) {
|
||||||
id: "share-to-notionnext",
|
this.plugin = plugin;
|
||||||
name: i18nConfig.CommandName, // Use the translated text from i18nConfig
|
|
||||||
editorCallback: async (editor: Editor, view: MarkdownView) => {
|
// Check if NextButton is true, then include the corresponding command
|
||||||
// await this.plugin.uploadCommand()
|
if (this.plugin.settings.NextButton) {
|
||||||
await uploadCommandNext(this.plugin, this.plugin.settings, this.plugin.app)
|
this.Ncommand.push({
|
||||||
}
|
id: "share-to-notionnext",
|
||||||
},
|
name: i18nConfig.CommandName, // Use the translated text from i18nConfig
|
||||||
{
|
editorCallback: async (editor: Editor, view: MarkdownView) => {
|
||||||
id: "share-to-notion",
|
await uploadCommandNext(this.plugin, this.plugin.settings, this.plugin.app);
|
||||||
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);
|
}
|
||||||
}
|
|
||||||
}
|
// 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(
|
||||||
|
{
|
||||||
|
id: command.id,
|
||||||
|
name: command.name,
|
||||||
|
editorCallback: command.editorCallback,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async ribbonDisplay() {
|
async ribbonDisplay() {
|
||||||
const NcommandList: DatabaseList[] = [];
|
const NcommandList: DatabaseList[] = [];
|
||||||
|
|
||||||
this.Ncommand.map(command => NcommandList.push(
|
this.Ncommand.map(command => NcommandList.push(
|
||||||
{
|
{
|
||||||
name:command.name,
|
name:command.name,
|
||||||
@@ -43,19 +72,39 @@ export default class RibbonCommands {
|
|||||||
await fusg.display(async (results) => {await results.match()})
|
await fusg.display(async (results) => {await results.match()})
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(plugin: ObsidianSyncNotionPlugin) {
|
// if the setting has been changed, try to rebuild the command list
|
||||||
this.plugin = plugin;
|
async updateCommand() {
|
||||||
|
|
||||||
// Register all the commands
|
this.Ncommand = [];
|
||||||
this.Ncommand.forEach(command => {
|
|
||||||
this.plugin.addCommand(
|
|
||||||
{
|
|
||||||
id: command.id,
|
|
||||||
name: command.name,
|
|
||||||
editorCallback: command.editorCallback,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ export const I18n: { [key: string]: any } = {
|
|||||||
CommandName: "Share to NotionNext Database",
|
CommandName: "Share to NotionNext Database",
|
||||||
CommandIDGeneral: "share-to-notion",
|
CommandIDGeneral: "share-to-notion",
|
||||||
CommandNameGeneral: "Share to Notion General Database",
|
CommandNameGeneral: "Share to Notion General Database",
|
||||||
NotionNextVersion: "NotionNext Version Database",
|
NotionNextButton: "NotionNext command switch",
|
||||||
NotionNextVersionDesc:
|
NotionNextButtonDesc: "Open this option, Sync to NotionNext command will be displayed in the command palette",
|
||||||
"Turn on this option if you are using NotionNext",
|
|
||||||
NotionNextSettingHeader: "NotionNext Database Settings",
|
NotionNextSettingHeader: "NotionNext Database Settings",
|
||||||
NotionAPI: "Notion API Token",
|
NotionAPI: "Notion API Token",
|
||||||
NotionAPIDesc: "It's a secret",
|
NotionAPIDesc: "It's a secret",
|
||||||
@@ -17,14 +16,16 @@ export const I18n: { [key: string]: any } = {
|
|||||||
DatabaseIDText: "Enter your Database ID",
|
DatabaseIDText: "Enter your Database ID",
|
||||||
BannerUrl: "Banner url(optional)",
|
BannerUrl: "Banner url(optional)",
|
||||||
BannerUrlDesc:
|
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",
|
BannerUrlText: "Enter your banner url",
|
||||||
NotionUser: "Notion ID(username, optional)",
|
NotionUser: "Notion ID(username, optional)",
|
||||||
NotionUserDesc:
|
NotionUserDesc:
|
||||||
"Your notion ID (optional),share link likes:https://username.notion.site/,your notion id is [username]",
|
"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",
|
NotionGeneralSettingHeader: "General Notion Database Settings",
|
||||||
NotYetFinish:
|
NotionGeneralButton: "Notion General command switch",
|
||||||
|
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette",
|
||||||
|
NotYetFinish:
|
||||||
"Not finished. This function will be available in the next version",
|
"Not finished. This function will be available in the next version",
|
||||||
PlaceHolder: "Enter database Name",
|
PlaceHolder: "Enter database Name",
|
||||||
"notion-logo": "Share to NotionNext",
|
"notion-logo": "Share to NotionNext",
|
||||||
@@ -41,6 +42,9 @@ export const I18n: { [key: string]: any } = {
|
|||||||
"The 'NNon' property is missing in the settings. Please set it up.",
|
"The 'NNon' property is missing in the settings. Please set it up.",
|
||||||
"set-api-id":
|
"set-api-id":
|
||||||
"Please set up the notion API and database ID in the settings tab.",
|
"Please set up the notion API and database ID in the settings tab.",
|
||||||
|
NotionCustomSettingHeader: "Notion Custom Database Settings",
|
||||||
|
NotionCustomButton: "Notion Customised command switch",
|
||||||
|
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette",
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
ribbonIcon: "分享到 NotionNext",
|
ribbonIcon: "分享到 NotionNext",
|
||||||
@@ -49,8 +53,8 @@ export const I18n: { [key: string]: any } = {
|
|||||||
CommandName: "分享到 NotionNext",
|
CommandName: "分享到 NotionNext",
|
||||||
CommandIDGeneral: "share-to-notion",
|
CommandIDGeneral: "share-to-notion",
|
||||||
CommandNameGeneral: "分享到 Notion 普通数据库",
|
CommandNameGeneral: "分享到 Notion 普通数据库",
|
||||||
NotionNextVersion: "NotionNext 版本数据库",
|
NotionNextButton: "NotionNext 同步命令开关",
|
||||||
NotionNextVersionDesc: "如果你使用的是NotionNext,请打开此选项",
|
NotionNextButtonDesc: "打开此选项,NotionNext 同步将显示在命令面板中",
|
||||||
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
||||||
NotionAPI: "Notion API 令牌",
|
NotionAPI: "Notion API 令牌",
|
||||||
NotionAPIDesc: "显示为密码",
|
NotionAPIDesc: "显示为密码",
|
||||||
@@ -59,13 +63,15 @@ export const I18n: { [key: string]: any } = {
|
|||||||
DatabaseIDText: "输入你的数据库 ID",
|
DatabaseIDText: "输入你的数据库 ID",
|
||||||
BannerUrl: "封面图片地址(可选)",
|
BannerUrl: "封面图片地址(可选)",
|
||||||
BannerUrlDesc:
|
BannerUrlDesc:
|
||||||
"页面封面图片地址(可选),默认为空,如果你想显示封面图片,请输入图片地址(例如:https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
"默认为空,如果你想显示封面图片,请输入图片地址(例如:https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
||||||
BannerUrlText: "输入你的封面图片地址",
|
BannerUrlText: "输入你的封面图片地址",
|
||||||
NotionUser: "Notion ID(用户名,可选)",
|
NotionUser: "Notion ID(用户名,可选)",
|
||||||
NotionUserDesc:
|
NotionUserDesc:
|
||||||
"你的 Notion ID(可选),分享链接类似:https://username.notion.site/,你的 Notion ID 是 [username]",
|
"你的 Notion ID(可选),分享链接类似:https://username.notion.site/,你的 Notion ID 是 [username]",
|
||||||
NotionUserText: "输入你的 Notion ID(可选)",
|
NotionUserText: "输入你的 Notion ID",
|
||||||
NotionGeneralSettingHeader: "普通 Notion 数据库设置",
|
NotionGeneralSettingHeader: "普通 Notion 数据库设置",
|
||||||
|
NotionGeneralButton: "普通数据库同步命令开关",
|
||||||
|
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中",
|
||||||
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
||||||
PlaceHolder: "输入数据库名称",
|
PlaceHolder: "输入数据库名称",
|
||||||
"notion-logo": "分享到NotionNext",
|
"notion-logo": "分享到NotionNext",
|
||||||
@@ -78,6 +84,9 @@ export const I18n: { [key: string]: any } = {
|
|||||||
"设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
"设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
||||||
NNonMissing: "未设置'NNon'属性,请在插件设置中选择NotionNext数据库。",
|
NNonMissing: "未设置'NNon'属性,请在插件设置中选择NotionNext数据库。",
|
||||||
"set-api-id": "请在插件设置中设置notion API和database ID",
|
"set-api-id": "请在插件设置中设置notion API和database ID",
|
||||||
|
NotionCustomSettingHeader: "Notion 自定义数据库设置",
|
||||||
|
NotionCustomButton: "Notion 自定义数据库同步命令开关",
|
||||||
|
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
0
src/ui/addButton.ts
Normal file
0
src/ui/addButton.ts
Normal file
@@ -3,25 +3,33 @@ import {i18nConfig} from "../lang/I18n";
|
|||||||
import ObsidianSyncNotionPlugin from "../main";
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
|
|
||||||
export interface PluginSettings {
|
export interface PluginSettings {
|
||||||
NNon: boolean;
|
NextButton: boolean;
|
||||||
notionAPINext: string;
|
notionAPINext: string;
|
||||||
databaseIDNext: string;
|
databaseIDNext: string;
|
||||||
bannerUrl: string;
|
bannerUrl: string;
|
||||||
notionUser: string;
|
notionUser: string;
|
||||||
proxy: string;
|
proxy: string;
|
||||||
|
GeneralButton: boolean;
|
||||||
notionAPIGeneral: string;
|
notionAPIGeneral: string;
|
||||||
databaseIDGeneral: string;
|
databaseIDGeneral: string;
|
||||||
|
CustomButton: boolean;
|
||||||
|
notionAPICustom: string;
|
||||||
|
databaseIDCustom: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: PluginSettings = {
|
export const DEFAULT_SETTINGS: PluginSettings = {
|
||||||
NNon: undefined,
|
NextButton: true,
|
||||||
notionAPINext: "",
|
notionAPINext: "",
|
||||||
databaseIDNext: "",
|
databaseIDNext: "",
|
||||||
bannerUrl: "",
|
bannerUrl: "",
|
||||||
notionUser: "",
|
notionUser: "",
|
||||||
proxy: "",
|
proxy: "",
|
||||||
|
GeneralButton: true,
|
||||||
notionAPIGeneral: "",
|
notionAPIGeneral: "",
|
||||||
databaseIDGeneral: "",
|
databaseIDGeneral: "",
|
||||||
|
CustomButton: false,
|
||||||
|
notionAPICustom: "",
|
||||||
|
databaseIDCustom: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -40,18 +48,6 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
containerEl.createEl('h2', {text: i18nConfig.GeneralSetting})
|
containerEl.createEl('h2', {text: i18nConfig.GeneralSetting})
|
||||||
|
|
||||||
// new Setting(containerEl)
|
|
||||||
// .setName(i18nConfig.NotionNextVersion)
|
|
||||||
// .setDesc(i18nConfig.NotionNextVersionDesc)
|
|
||||||
// .addToggle((toggle) =>
|
|
||||||
// toggle
|
|
||||||
// .setValue(this.plugin.settings.NNon)
|
|
||||||
// .onChange(async (value) => {
|
|
||||||
// this.plugin.settings.NNon = value;
|
|
||||||
// await this.plugin.saveSettings();
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName(i18nConfig.BannerUrl)
|
.setName(i18nConfig.BannerUrl)
|
||||||
.setDesc(i18nConfig.BannerUrlDesc)
|
.setDesc(i18nConfig.BannerUrlDesc)
|
||||||
@@ -81,6 +77,19 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
containerEl.createEl('h2', {text: i18nConfig.NotionNextSettingHeader})
|
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)
|
new Setting(containerEl)
|
||||||
.setName(i18nConfig.NotionAPI)
|
.setName(i18nConfig.NotionAPI)
|
||||||
.setDesc(i18nConfig.NotionAPIDesc)
|
.setDesc(i18nConfig.NotionAPIDesc)
|
||||||
@@ -119,6 +128,18 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
// new Setting(containerEl)
|
// new Setting(containerEl)
|
||||||
// .setName(i18nConfig.NotYetFinish)
|
// .setName(i18nConfig.NotYetFinish)
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName(i18nConfig.NotionGeneralButton)
|
||||||
|
.setDesc(i18nConfig.NotionGeneralButtonDesc)
|
||||||
|
.addToggle((toggle) =>
|
||||||
|
toggle
|
||||||
|
.setValue(this.plugin.settings.GeneralButton)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.GeneralButton = value;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
await this.plugin.commands.updateCommand();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// new Setting(containerEl)
|
// new Setting(containerEl)
|
||||||
// .setName("Convert tags(optional)")
|
// .setName("Convert tags(optional)")
|
||||||
@@ -161,5 +182,20 @@ 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();
|
||||||
|
// })
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user