mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
rebuild the locale file and add tag button to control tag syncing function
This commit is contained in:
16
README-zh.md
16
README-zh.md
@@ -5,6 +5,22 @@
|
|||||||
所以我在[原作者](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编辑,整理好之后一键发布。
|
||||||
|
|
||||||
## 更新说明
|
## 更新说明
|
||||||
|
### 1.1.0
|
||||||
|
- 修复设置中自定义标题的显示问题。
|
||||||
|
- 增加了标签同步的控制按钮。以减少空标签集造成的上传失败。
|
||||||
|
|
||||||
|
如果你不想使用同步标签功能,你可以在设置中关闭。不论你在md文件表头添加了tags与否,都不会将标签同步到Notion数据库中。
|
||||||
|
|
||||||
|
如果你需要同步标签到Notion数据库中,**你需要通过如下格式添加表填到md表头中。**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: #空标签,选项1
|
||||||
|
tags: [test,test1,test2] # 用中括号将所有的标签括起来,选项2
|
||||||
|
tags:
|
||||||
|
- test
|
||||||
|
- test1
|
||||||
|
- test2 # 每个标签单独一行,选项3
|
||||||
|
```
|
||||||
|
|
||||||
### 1.0.1
|
### 1.0.1
|
||||||
|
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -15,6 +15,23 @@ Thus, based on the [original author's work](https://github.com/EasyChris/obsidia
|
|||||||
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
|
### 1.1.0
|
||||||
|
- Fix the custom name setting tab display bug.
|
||||||
|
- Add a toggle to control whether to sync `tags` since the empty tags may cause the syncing error.
|
||||||
|
|
||||||
|
If you switch off the `tags` function in the plugin settings, it will ignore the `tags` in your frontmatter.
|
||||||
|
|
||||||
|
If you prefer to sync tags to Notion database, you can switch on the `tags` function in the plugin settings. **You can only use the following format for tags:**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: #empty tags, option 1
|
||||||
|
tags: [test,test1,test2] # use the square brackets, option 2
|
||||||
|
tags:
|
||||||
|
- test
|
||||||
|
- test1
|
||||||
|
- test2 # use the dash option 3
|
||||||
|
```
|
||||||
|
|
||||||
### 1.0.1
|
### 1.0.1
|
||||||
|
|
||||||
- Fix the custom name element display bug in the settings.
|
- Fix the custom name element display bug in the settings.
|
||||||
|
|||||||
104
src/lang/I18n.ts
104
src/lang/I18n.ts
@@ -1,103 +1,9 @@
|
|||||||
|
import {en} from "./en";
|
||||||
|
import {zh} from "./zh";
|
||||||
|
|
||||||
export const I18n: { [key: string]: any } = {
|
export const I18n: { [key: string]: any } = {
|
||||||
en: {
|
en,
|
||||||
ribbonIcon: "Share to NotionNext",
|
zh,
|
||||||
GeneralSetting: "General information Settings",
|
|
||||||
CommandID: "share-to-notionnext",
|
|
||||||
CommandName: "Share to NotionNext Database",
|
|
||||||
CommandIDGeneral: "share-to-notion",
|
|
||||||
CommandNameGeneral: "Share to Notion General Database",
|
|
||||||
NotionNextButton: "NotionNext Sync",
|
|
||||||
NotionNextButtonDesc: "Open this option, Sync to NotionNext command will be displayed in the command palette (default: ON)",
|
|
||||||
NotionNextSettingHeader: "NotionNext Database Settings",
|
|
||||||
NotionAPI: "Notion API Token",
|
|
||||||
NotionAPIDesc: "Generate from https://www.notion.so/my-integrations",
|
|
||||||
NotionAPIText: "Enter your Notion API Token",
|
|
||||||
DatabaseID: "Database ID",
|
|
||||||
DatabaseIDText: "Enter your Database ID",
|
|
||||||
BannerUrl: "Banner url (optional)",
|
|
||||||
BannerUrlDesc:
|
|
||||||
"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:
|
|
||||||
"Collect from share link likes:https://username.notion.site. Your notion id is [username]",
|
|
||||||
NotionUserText: "Enter your notion ID",
|
|
||||||
NotionGeneralSettingHeader: "General Notion Database Settings",
|
|
||||||
NotionGeneralButton: "Notion General Sync",
|
|
||||||
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette (default: ON)",
|
|
||||||
NotionCustomTitle: "Customise title property",
|
|
||||||
NotionCustomTitleDesc: "Modify the column name of the Notion database (default: OFF)",
|
|
||||||
NotionCustomTitleName: "Preferred title name",
|
|
||||||
NotionCustomTitleNameDesc: "Enter the preferred title name for the first column of the Notion database (default: title)",
|
|
||||||
NotionCustomTitleText: "Enter the name",
|
|
||||||
NotYetFinish:
|
|
||||||
"Not finished. This function will be available in the next version",
|
|
||||||
PlaceHolder: "Enter database Name",
|
|
||||||
"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.",
|
|
||||||
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: {
|
|
||||||
ribbonIcon: "分享到 NotionNext",
|
|
||||||
GeneralSetting: "通用设置",
|
|
||||||
CommandID: "share-to-notionnext",
|
|
||||||
CommandName: "分享到 NotionNext",
|
|
||||||
CommandIDGeneral: "share-to-notion",
|
|
||||||
CommandNameGeneral: "分享到 Notion 普通数据库",
|
|
||||||
NotionNextButton: "NotionNext 同步",
|
|
||||||
NotionNextButtonDesc: "打开此选项,NotionNext 同步将显示在命令面板中(默认:开)",
|
|
||||||
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
|
||||||
NotionAPI: "Notion API 令牌",
|
|
||||||
NotionAPIDesc: "从 https://www.notion.so/my-integrations 生成",
|
|
||||||
NotionAPIText: "输入你的 Notion API 令牌",
|
|
||||||
DatabaseID: "数据库 ID",
|
|
||||||
DatabaseIDText: "输入你的数据库 ID",
|
|
||||||
BannerUrl: "封面图片地址(可选)",
|
|
||||||
BannerUrlDesc:
|
|
||||||
"默认为空,如果你想显示封面图片,请输入图片地址(例如:https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
|
||||||
BannerUrlText: "输入你的封面图片地址",
|
|
||||||
NotionUser: "Notion ID(用户名,可选)",
|
|
||||||
NotionUserDesc:
|
|
||||||
"数据库分享链接类似:https://username.notion.site/。你的 Notion ID 是 [username]",
|
|
||||||
NotionUserText: "输入你的 Notion ID",
|
|
||||||
NotionGeneralSettingHeader: "普通 Notion 数据库设置",
|
|
||||||
NotionGeneralButton: "普通数据库同步",
|
|
||||||
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中(默认:开)",
|
|
||||||
NotionCustomTitle: "修改 Notion 数据库表头开关",
|
|
||||||
NotionCustomTitleDesc: "自定义Notion 数据库第一列表头名(默认:关)",
|
|
||||||
NotionCustomTitleName: "想要修改的表头名",
|
|
||||||
NotionCustomTitleNameDesc: "输入你想要修改的notion数据库的表头名(默认:title)",
|
|
||||||
NotionCustomTitleText: "输入表头名",
|
|
||||||
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
|
||||||
PlaceHolder: "输入数据库名称",
|
|
||||||
"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",
|
|
||||||
NotionCustomSettingHeader: "Notion 自定义数据库设置",
|
|
||||||
NotionCustomButton: "Notion 自定义数据库同步命令开关",
|
|
||||||
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中",
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const I18nConfig = (lang: any): any => {
|
export const I18nConfig = (lang: any): any => {
|
||||||
|
|||||||
54
src/lang/en.ts
Normal file
54
src/lang/en.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
export const en = {
|
||||||
|
ribbonIcon: "Share to NotionNext",
|
||||||
|
GeneralSetting: "General information Settings",
|
||||||
|
CommandID: "share-to-notionnext",
|
||||||
|
CommandName: "Share to NotionNext Database",
|
||||||
|
CommandIDGeneral: "share-to-notion",
|
||||||
|
CommandNameGeneral: "Share to Notion General Database",
|
||||||
|
NotionNextButton: "NotionNext Sync",
|
||||||
|
NotionNextButtonDesc: "Open this option, Sync to NotionNext command will be displayed in the command palette (default: ON)",
|
||||||
|
NotionNextSettingHeader: "NotionNext Database Settings",
|
||||||
|
NotionAPI: "Notion API Token",
|
||||||
|
NotionAPIDesc: "Generate from https://www.notion.so/my-integrations",
|
||||||
|
NotionAPIText: "Enter your Notion API Token",
|
||||||
|
DatabaseID: "Database ID",
|
||||||
|
DatabaseIDText: "Enter your Database ID",
|
||||||
|
BannerUrl: "Banner url (optional)",
|
||||||
|
BannerUrlDesc:
|
||||||
|
"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:
|
||||||
|
"Collect from share link likes:https://username.notion.site. Your notion id is [username]",
|
||||||
|
NotionUserText: "Enter your notion ID",
|
||||||
|
NotionGeneralSettingHeader: "General Notion Database Settings",
|
||||||
|
NotionGeneralButton: "Notion General Sync",
|
||||||
|
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette (default: ON)",
|
||||||
|
NotionTagButton: "Notion Tags Sync",
|
||||||
|
NotionTagButtonDesc: "Sync Tags to Notion General Database (default: ON)",
|
||||||
|
NotionCustomTitle: "Customise title property",
|
||||||
|
NotionCustomTitleDesc: "Modify the column name of the Notion database (default: OFF)",
|
||||||
|
NotionCustomTitleName: "Preferred title name",
|
||||||
|
NotionCustomTitleNameDesc: "Enter the preferred title name for the first column of the Notion database (default: title)",
|
||||||
|
NotionCustomTitleText: "Enter the name",
|
||||||
|
NotYetFinish:
|
||||||
|
"Not finished. This function will be available in the next version",
|
||||||
|
PlaceHolder: "Enter database Name",
|
||||||
|
"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.",
|
||||||
|
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",
|
||||||
|
}
|
||||||
49
src/lang/zh.ts
Normal file
49
src/lang/zh.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
export const zh = {
|
||||||
|
ribbonIcon: "分享到 NotionNext",
|
||||||
|
GeneralSetting: "通用设置",
|
||||||
|
CommandID: "share-to-notionnext",
|
||||||
|
CommandName: "分享到 NotionNext",
|
||||||
|
CommandIDGeneral: "share-to-notion",
|
||||||
|
CommandNameGeneral: "分享到 Notion 普通数据库",
|
||||||
|
NotionNextButton: "NotionNext 同步",
|
||||||
|
NotionNextButtonDesc: "打开此选项,NotionNext 同步将显示在命令面板中(默认:开)",
|
||||||
|
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
||||||
|
NotionAPI: "Notion API 令牌",
|
||||||
|
NotionAPIDesc: "从 https://www.notion.so/my-integrations 生成",
|
||||||
|
NotionAPIText: "输入你的 Notion API 令牌",
|
||||||
|
DatabaseID: "数据库 ID",
|
||||||
|
DatabaseIDText: "输入你的数据库 ID",
|
||||||
|
BannerUrl: "封面图片地址(可选)",
|
||||||
|
BannerUrlDesc:
|
||||||
|
"默认为空,如果你想显示封面图片,请输入图片地址(例如:https://minioapi.pjx.ac.cn/img1/2023/11/b7b40a0724e93b7d7ab494bb3b8a2da8.png)",
|
||||||
|
BannerUrlText: "输入你的封面图片地址",
|
||||||
|
NotionUser: "Notion ID(用户名,可选)",
|
||||||
|
NotionUserDesc:
|
||||||
|
"数据库分享链接类似:https://username.notion.site/。你的 Notion ID 是 [username]",
|
||||||
|
NotionUserText: "输入你的 Notion ID",
|
||||||
|
NotionGeneralSettingHeader: "普通 Notion 数据库设置",
|
||||||
|
NotionGeneralButton: "普通数据库同步",
|
||||||
|
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中(默认:开)",
|
||||||
|
NotionTagButton: "标签同步开关",
|
||||||
|
NotionTagButtonDesc: "将标签同步到普通数据库(默认:开)",
|
||||||
|
NotionCustomTitle: "修改 Notion 数据库表头开关",
|
||||||
|
NotionCustomTitleDesc: "自定义Notion 数据库第一列表头名(默认:关)",
|
||||||
|
NotionCustomTitleName: "想要修改的表头名",
|
||||||
|
NotionCustomTitleNameDesc: "输入你想要修改的notion数据库的表头名(默认:title)",
|
||||||
|
NotionCustomTitleText: "输入表头名",
|
||||||
|
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
||||||
|
PlaceHolder: "输入数据库名称",
|
||||||
|
"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",
|
||||||
|
NotionCustomSettingHeader: "Notion 自定义数据库设置",
|
||||||
|
NotionCustomButton: "Notion 自定义数据库同步命令开关",
|
||||||
|
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中",
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ export interface PluginSettings {
|
|||||||
notionUser: string;
|
notionUser: string;
|
||||||
proxy: string;
|
proxy: string;
|
||||||
GeneralButton: boolean;
|
GeneralButton: boolean;
|
||||||
|
tagButton: boolean;
|
||||||
CustomTitleButton: boolean;
|
CustomTitleButton: boolean;
|
||||||
CustomTitleName: string;
|
CustomTitleName: string;
|
||||||
notionAPIGeneral: string;
|
notionAPIGeneral: string;
|
||||||
@@ -28,6 +29,7 @@ export const DEFAULT_SETTINGS: PluginSettings = {
|
|||||||
notionUser: "",
|
notionUser: "",
|
||||||
proxy: "",
|
proxy: "",
|
||||||
GeneralButton: true,
|
GeneralButton: true,
|
||||||
|
tagButton: true,
|
||||||
CustomTitleButton: false,
|
CustomTitleButton: false,
|
||||||
CustomTitleName: "",
|
CustomTitleName: "",
|
||||||
notionAPIGeneral: "",
|
notionAPIGeneral: "",
|
||||||
@@ -101,6 +103,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.plugin.settings.GeneralButton = value;
|
this.plugin.settings.GeneralButton = value;
|
||||||
|
|
||||||
|
this.updateSettingEl(tagButtonEl, value)
|
||||||
this.updateSettingEl(CustomTitleEl, value)
|
this.updateSettingEl(CustomTitleEl, value)
|
||||||
// name should follow the result of the title button
|
// name should follow the result of the title button
|
||||||
if (value) {
|
if (value) {
|
||||||
@@ -119,6 +122,11 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// add the tagButton to control whether to add tags to the general database
|
||||||
|
const tagButtonEl = this.createStyleDiv('tag-button', (this.plugin.settings.GeneralButton && this.plugin.settings.CustomTitleButton));
|
||||||
|
this.createSettingEl(tagButtonEl, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.plugin.settings.tagButton, 'tagButton')
|
||||||
|
|
||||||
|
// Custom Title Button
|
||||||
const CustomTitleEl = this.createStyleDiv('custom-title', this.plugin.settings.GeneralButton);
|
const CustomTitleEl = this.createStyleDiv('custom-title', this.plugin.settings.GeneralButton);
|
||||||
new Setting(CustomTitleEl)
|
new Setting(CustomTitleEl)
|
||||||
.setName(i18nConfig.NotionCustomTitle)
|
.setName(i18nConfig.NotionCustomTitle)
|
||||||
@@ -136,8 +144,8 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Custom Title Name
|
||||||
const CustomNameEl = this.createStyleDiv('custom-name', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
const CustomNameEl = this.createStyleDiv('custom-name', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
||||||
|
|
||||||
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName, 'CustomTitleName')
|
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName, 'CustomTitleName')
|
||||||
|
|
||||||
// new Setting(containerEl)
|
// new Setting(containerEl)
|
||||||
|
|||||||
@@ -59,14 +59,13 @@ export class Upload2NotionGeneral extends UploadBaseGeneral {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
...(this.plugin.settings.tagsButton
|
||||||
|
? {
|
||||||
tags: {
|
tags: {
|
||||||
multi_select:
|
multi_select: tags && true ? tags.map((tag) => ({ name: tag })) : [],
|
||||||
tags && true
|
|
||||||
? tags.map((tag) => {
|
|
||||||
return { name: tag };
|
|
||||||
})
|
|
||||||
: [],
|
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
},
|
},
|
||||||
children: childArr,
|
children: childArr,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user