mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-31 01:48:35 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfbedea91d | ||
|
|
4cd6557444 | ||
|
|
407688c303 | ||
|
|
84b998aa93 |
@@ -3,6 +3,8 @@
|
||||
|
||||
所以我在[原作者](https://github.com/EasyChris/obsidian-to-notion)的基础之上,增加了匹配[NotionNext](https://github.com/tangly1024/NotionNext)模板的功能。这样可以直接在Obsidian编辑,整理好之后一键发布。
|
||||
## 更新说明
|
||||
### 0.1.10
|
||||
- 修正了设置中的中文显示。
|
||||
### 0.1.8
|
||||
- 重新整理了代码,增加了一个仓库转换按钮为之后的多数据库支持作准备。**但是现在还不支持多数据库,如果你的数据库不是NotionNext,你可以不用更新。**
|
||||
### 0.1.7
|
||||
|
||||
@@ -5,6 +5,8 @@ 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.
|
||||
## Update
|
||||
### 0.1.10
|
||||
- Fix the Chinese support in the settings.
|
||||
### 0.1.8
|
||||
- Rebuild the upload function, and add one button to select the different databases. **However, only NotionNext database is supported for now.**
|
||||
### 0.1.7
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "share-to-notionnext",
|
||||
"name": "Share to NotionNext",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.10",
|
||||
"minAppVersion": "0.0.1",
|
||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||
"author": "EasyChris, jxpeng98",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "share-to-notionnext",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.10",
|
||||
"type": "module",
|
||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||
"main": "main.js",
|
||||
|
||||
46
src/I18n.ts
Normal file
46
src/I18n.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
export const I18n: { [key: string]: any } = {
|
||||
"en": {
|
||||
ribbonIcon: "Share to NotionNext",
|
||||
CommandName: "share to notionnext",
|
||||
NotionNextVersion: "NotionNext Version Database",
|
||||
NotionNextVersionDesc: "Turn on this option if you are using NotionNext",
|
||||
NotionNextSetting: "NotionNext Database Settings",
|
||||
NotionAPI: "Notion API Token",
|
||||
NotionAPIDesc: "It's a secret",
|
||||
NotionAPIText:"Enter your Notion API Token",
|
||||
NotionID: "Database ID",
|
||||
NotionIDText: "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://raw.githubusercontent.com/EasyChris/obsidian-to-notion/ae7a9ac6cf427f3ca338a409ce6967ced9506f12/doc/2.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)",
|
||||
NotionGeneralSetting: "General Notion Database Settings",
|
||||
NotYetFinish: "Not finished. This function will be available in the next version",
|
||||
},
|
||||
"zh": {
|
||||
ribbonIcon: "分享到 NotionNext",
|
||||
CommandName: "分享到 NotionNext",
|
||||
NotionNextVersion: "NotionNext 版本数据库",
|
||||
NotionNextVersionDesc: "如果你使用的是NotionNext,请打开此选项",
|
||||
NotionNextSetting: "NotionNext 数据库参数设置",
|
||||
NotionAPI: "Notion API 令牌",
|
||||
NotionAPIDesc: "显示为密码",
|
||||
NotionAPIText:"输入你的 Notion API 令牌",
|
||||
NotionID: "数据库 ID",
|
||||
NotionIDText: "输入你的数据库 ID",
|
||||
BannerUrl: "封面图片地址(可选)",
|
||||
BannerUrlDesc: "页面封面图片地址(可选),默认为空,如果你想显示封面图片,请输入图片地址(例如:https://raw.githubusercontent.com/EasyChris/obsidian-to-notion/ae7a9ac6cf427f3ca338a409ce6967ced9506f12/doc/2.png)",
|
||||
BannerUrlText: "输入你的封面图片地址",
|
||||
NotionUser: "Notion ID(用户名,可选)",
|
||||
NotionUserDesc: "你的 Notion ID(可选),分享链接类似:https://username.notion.site/,你的 Notion ID 是 [username]",
|
||||
NotionUserText: "输入你的 Notion ID(可选)",
|
||||
NotionGeneralSetting: "普通 Notion 数据库设置",
|
||||
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
||||
},
|
||||
}
|
||||
|
||||
export const I18nConfig = (lang: any): any => {
|
||||
return I18n[lang]
|
||||
}
|
||||
@@ -1,23 +1,29 @@
|
||||
export const NoticeMsg: {[key: string]:any} = {
|
||||
"en": {
|
||||
"notion-logo": "Share to NotionNext",
|
||||
"sync-success": "Sync to NotionNext success: \n",
|
||||
"sync-fail": "Sync to NotionNext fail: \n",
|
||||
"open-notion": "Please open the file that needs to be synchronized",
|
||||
"config-secrets-notion-api": "Please set up the notion API in the settings tab.",
|
||||
"config-secrets-database-id": "Please set up the database id in the settings tab.",
|
||||
"set-tags-fail": "Set tags fail,please check the frontmatter of the file or close the tag switch in the settings tab.",
|
||||
},
|
||||
"zh": {
|
||||
"notion-logo": "分享到NotionNext",
|
||||
"sync-success": "同步到NotionNext成功:\n",
|
||||
"sync-fail": "同步到NotionNext失败: \n",
|
||||
"open-file": "请打开需要同步的文件",
|
||||
"set-tags-fail": "设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
||||
},
|
||||
export const NoticeMsg: { [key: string]: any } = {
|
||||
"en": {
|
||||
"notion-logo": "Share to NotionNext",
|
||||
"sync-success": "Sync to NotionNext success: \n",
|
||||
"sync-fail": "Sync to NotionNext fail: \n",
|
||||
"open-notion": "Please open the file that needs to be synchronized",
|
||||
"config-secrets-notion-api": "Please set up the notion API in the settings tab.",
|
||||
"config-secrets-database-id": "Please set up the database id in the settings tab.",
|
||||
"set-tags-fail": "Set tags fail,please check the frontmatter of the file or close the tag switch in the settings tab.",
|
||||
"NNonMissing": "The 'NNon' property is missing in the settings. Please set it up.",
|
||||
"set-api-id": "Please set up the notion API and database ID in the settings tab."
|
||||
},
|
||||
"zh": {
|
||||
"notion-logo": "分享到NotionNext",
|
||||
"sync-success": "同步到NotionNext成功:\n",
|
||||
"sync-fail": "同步到NotionNext失败: \n",
|
||||
"open-file": "请打开需要同步的文件",
|
||||
"config-secrets-notion-api": "请在插件设置中添加notion API",
|
||||
"config-secrets-database-id": "请在插件设置中添加database id",
|
||||
"set-tags-fail": "设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
||||
"NNonMissing": "未设置'NNon'属性,请在插件设置中选择NotionNext数据库。",
|
||||
"set-api-id": "请在插件设置中设置notion API和database ID"
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
export const NoticeMConfig = (lang:any) :any => {
|
||||
return NoticeMsg[lang]
|
||||
export const NoticeMConfig = (lang: any): any => {
|
||||
return NoticeMsg[lang]
|
||||
}
|
||||
|
||||
63
src/main.ts
63
src/main.ts
@@ -3,7 +3,7 @@ import {addIcons} from 'src/icon';
|
||||
import {Upload2Notion} from "src/Upload2Notion";
|
||||
import {Upload2NotionNext} from "src/Upload2Notion_NN";
|
||||
import {NoticeMConfig} from "src/Message";
|
||||
|
||||
import {I18nConfig} from "src/I18n";
|
||||
|
||||
// Remember to rename these classes and interfaces!
|
||||
|
||||
@@ -18,8 +18,10 @@ interface PluginSettings {
|
||||
|
||||
const langConfig = NoticeMConfig(window.localStorage.getItem('language') || 'en')
|
||||
|
||||
const i18nConfig = I18nConfig(window.localStorage.getItem('language') || 'en')
|
||||
|
||||
const DEFAULT_SETTINGS: PluginSettings = {
|
||||
NNon: true,
|
||||
NNon: undefined,
|
||||
notionAPI: "",
|
||||
databaseID: "",
|
||||
bannerUrl: "",
|
||||
@@ -36,7 +38,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
// This creates an icon in the left ribbon.
|
||||
const ribbonIconEl = this.addRibbonIcon(
|
||||
"notion-logo",
|
||||
"Share to NotionNext",
|
||||
i18nConfig.ribbonIcon,
|
||||
async (evt: MouseEvent) => {
|
||||
// Called when the user clicks the icon.
|
||||
await this.upload();
|
||||
@@ -49,7 +51,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
|
||||
this.addCommand({
|
||||
id: "share-to-notionnext",
|
||||
name: "share to notionnext",
|
||||
name: i18nConfig.CommandName,
|
||||
editorCallback: async (editor: Editor, view: MarkdownView) => {
|
||||
await this.upload()
|
||||
},
|
||||
@@ -65,13 +67,22 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
}
|
||||
|
||||
async upload() {
|
||||
const {NNon, notionAPI, databaseID} = this.settings;
|
||||
const { notionAPI, databaseID, NNon} = this.settings;
|
||||
|
||||
// Check if NNon exists
|
||||
if (NNon === undefined) {
|
||||
const NNonmessage = langConfig.NNonMissing;
|
||||
new Notice(NNonmessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the user has set up the Notion API and database ID
|
||||
if (notionAPI === "" || databaseID === "") {
|
||||
new Notice(
|
||||
"Please set up the notion API and database ID in the settings tab."
|
||||
);
|
||||
const setAPIMessage = langConfig["set-api-id"];
|
||||
new Notice(setAPIMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
const {markDownData, nowFile, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime} = await this.getNowFileMarkdownContent(this.app);
|
||||
|
||||
|
||||
@@ -178,8 +189,8 @@ class ObsidianSettingTab extends PluginSettingTab {
|
||||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("NotionNext version")
|
||||
.setDesc("Turn on this option if you are using NotionNext")
|
||||
.setName(i18nConfig.NotionNextVersion)
|
||||
.setDesc(i18nConfig.NotionNextVersionDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.NNon)
|
||||
@@ -189,15 +200,15 @@ class ObsidianSettingTab extends PluginSettingTab {
|
||||
})
|
||||
);
|
||||
|
||||
containerEl.createEl('h2', {text: 'NotionNext Database Settings'})
|
||||
containerEl.createEl('h2', {text: i18nConfig.NotionNextSetting})
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Notion API Token")
|
||||
.setDesc("It's a secret")
|
||||
.setName(i18nConfig.NotionAPI)
|
||||
.setDesc(i18nConfig.NotionAPIDesc)
|
||||
.addText((text) => {
|
||||
text.inputEl.type = 'password';
|
||||
return text
|
||||
.setPlaceholder("Enter your Notion API Token")
|
||||
.setPlaceholder(i18nConfig.NotionAPIText)
|
||||
.setValue(this.plugin.settings.notionAPI)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.notionAPI = value;
|
||||
@@ -207,12 +218,12 @@ class ObsidianSettingTab extends PluginSettingTab {
|
||||
|
||||
|
||||
const notionDatabaseID = new Setting(containerEl)
|
||||
.setName("Database ID")
|
||||
.setDesc("It's a secret")
|
||||
.setName(i18nConfig.NotionID)
|
||||
.setDesc(i18nConfig.NotionAPIDesc)
|
||||
.addText((text) => {
|
||||
text.inputEl.type = 'password';
|
||||
return text
|
||||
.setPlaceholder("Enter your Database ID")
|
||||
.setPlaceholder(i18nConfig.NotionIDText)
|
||||
.setValue(this.plugin.settings.databaseID)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.databaseID = value;
|
||||
@@ -224,11 +235,11 @@ class ObsidianSettingTab extends PluginSettingTab {
|
||||
// notionDatabaseID.controlEl.querySelector('input').type='password'
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Banner url(optional)")
|
||||
.setDesc("page banner url(optional), default is empty, if you want to show a banner, please enter the url(like:https://raw.githubusercontent.com/EasyChris/obsidian-to-notion/ae7a9ac6cf427f3ca338a409ce6967ced9506f12/doc/2.png)")
|
||||
.setName(i18nConfig.BannerUrl)
|
||||
.setDesc(i18nConfig.BannerUrlDesc)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Enter banner pic url: ")
|
||||
.setPlaceholder(i18nConfig.BannerUrlText)
|
||||
.setValue(this.plugin.settings.bannerUrl)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.bannerUrl = value;
|
||||
@@ -238,11 +249,11 @@ class ObsidianSettingTab extends PluginSettingTab {
|
||||
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Notion ID(username, optional)")
|
||||
.setDesc("Your notion ID(optional),share link likes:https://username.notion.site/,your notion id is [username]")
|
||||
.setName(i18nConfig.NotionUser)
|
||||
.setDesc(i18nConfig.NotionUserDesc)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("Enter notion ID(options) ")
|
||||
.setPlaceholder(i18nConfig.NotionUserText)
|
||||
.setValue(this.plugin.settings.notionID)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.notionID = value;
|
||||
@@ -251,12 +262,10 @@ class ObsidianSettingTab extends PluginSettingTab {
|
||||
);
|
||||
|
||||
// General Database Settings
|
||||
containerEl.createEl('h2', {text: 'General Notion Database Settings'});
|
||||
containerEl.createEl('h2', {text: i18nConfig.NotionGeneralSetting});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Not finished")
|
||||
.setDesc("This functio will be available in the next version");
|
||||
|
||||
.setName(i18nConfig.NotYetFinish)
|
||||
|
||||
// new Setting(containerEl)
|
||||
// .setName("Convert tags(optional)")
|
||||
|
||||
Reference in New Issue
Block a user