mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-31 10:08:34 +08:00
complete the basic customisation feature
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { FuzzySuggestModal, FuzzyMatch } from 'obsidian';
|
import { FuzzySuggestModal, FuzzyMatch } from 'obsidian';
|
||||||
import MyPlugin from "../main";
|
import MyPlugin from "../main";
|
||||||
import {i18nConfig} from "../lang/I18n";
|
import { i18nConfig } from "../lang/I18n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple interface for what should be displayed and stored for suggester
|
* Simple interface for what should be displayed and stored for suggester
|
||||||
@@ -38,7 +38,7 @@ export class FuzzySuggester extends FuzzySuggestModal<DatabaseList>{
|
|||||||
return item.name
|
return item.name
|
||||||
}
|
}
|
||||||
|
|
||||||
onChooseItem(item: DatabaseList, evt:MouseEvent | KeyboardEvent): void { }
|
onChooseItem(item: DatabaseList, evt: MouseEvent | KeyboardEvent): void { }
|
||||||
|
|
||||||
onChooseSuggestion(item: FuzzyMatch<DatabaseList>, evt: MouseEvent | KeyboardEvent): void {
|
onChooseSuggestion(item: FuzzyMatch<DatabaseList>, evt: MouseEvent | KeyboardEvent): void {
|
||||||
this.callback(item.item, evt)
|
this.callback(item.item, evt)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {i18nConfig} from "src/lang/I18n";
|
import { i18nConfig } from "src/lang/I18n";
|
||||||
import {Editor, MarkdownView} from "obsidian";
|
import { Editor, MarkdownView } from "obsidian";
|
||||||
import {FuzzySuggester, DatabaseList} from "./FuzzySuggester";
|
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";
|
||||||
|
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ interface Command {
|
|||||||
|
|
||||||
// create the commands list
|
// create the commands list
|
||||||
export default class RibbonCommands {
|
export default class RibbonCommands {
|
||||||
plugin: ObsidianSyncNotionPlugin;
|
plugin: ObsidianSyncNotionPlugin;
|
||||||
|
|
||||||
Ncommand: Command[] = [];
|
Ncommand: Command[] = [];
|
||||||
|
|
||||||
@@ -55,22 +55,22 @@ export default class RibbonCommands {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
match: command.editorCallback
|
match: command.editorCallback
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const fusg = new FuzzySuggester(this.plugin);
|
const fusg = new FuzzySuggester(this.plugin);
|
||||||
|
|
||||||
fusg.setSuggesterData(NcommandList);
|
fusg.setSuggesterData(NcommandList);
|
||||||
await fusg.display(async (results) => {await results.match()})
|
await fusg.display(async (results) => { await results.match() })
|
||||||
};
|
};
|
||||||
|
|
||||||
// if the setting has been changed, try to rebuild the command list
|
// if the setting has been changed, try to rebuild the command list
|
||||||
async updateCommand() {
|
async updateCommand() {
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ export const I18n: { [key: string]: any } = {
|
|||||||
NotionUserText: "Enter your notion ID",
|
NotionUserText: "Enter your notion ID",
|
||||||
NotionGeneralSettingHeader: "General Notion Database Settings",
|
NotionGeneralSettingHeader: "General Notion Database Settings",
|
||||||
NotionGeneralButton: "Notion General command switch",
|
NotionGeneralButton: "Notion General command switch",
|
||||||
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette",
|
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette",
|
||||||
NotionCustomTitle: "Customise column name",
|
NotionCustomTitle: "Customise column name",
|
||||||
NotionCustomTitleDesc: "Modify the column name of the Notion database, default (off)",
|
NotionCustomTitleDesc: "Modify the column name of the Notion database, default (off)",
|
||||||
NotionCustomTitleName: "Preferred title name",
|
NotionCustomTitleName: "Preferred title name",
|
||||||
NotionCustomTitleNameDesc: "Enter the preferred title name for the first column of the Notion database",
|
NotionCustomTitleNameDesc: "Enter the preferred title name for the first column of the Notion database",
|
||||||
NotionCustomTitleText: "Enter the name",
|
NotionCustomTitleText: "Enter the name",
|
||||||
NotYetFinish:
|
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",
|
||||||
@@ -47,9 +47,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",
|
NotionCustomSettingHeader: "Notion Custom Database Settings",
|
||||||
NotionCustomButton: "Notion Customised command switch",
|
NotionCustomButton: "Notion Customised command switch",
|
||||||
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette",
|
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette",
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
ribbonIcon: "分享到 NotionNext",
|
ribbonIcon: "分享到 NotionNext",
|
||||||
@@ -58,8 +58,8 @@ export const I18n: { [key: string]: any } = {
|
|||||||
CommandName: "分享到 NotionNext",
|
CommandName: "分享到 NotionNext",
|
||||||
CommandIDGeneral: "share-to-notion",
|
CommandIDGeneral: "share-to-notion",
|
||||||
CommandNameGeneral: "分享到 Notion 普通数据库",
|
CommandNameGeneral: "分享到 Notion 普通数据库",
|
||||||
NotionNextButton: "NotionNext 同步命令开关",
|
NotionNextButton: "NotionNext 同步命令开关",
|
||||||
NotionNextButtonDesc: "打开此选项,NotionNext 同步将显示在命令面板中",
|
NotionNextButtonDesc: "打开此选项,NotionNext 同步将显示在命令面板中",
|
||||||
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
||||||
NotionAPI: "Notion API 令牌",
|
NotionAPI: "Notion API 令牌",
|
||||||
NotionAPIDesc: "显示为密码",
|
NotionAPIDesc: "显示为密码",
|
||||||
@@ -75,14 +75,14 @@ export const I18n: { [key: string]: any } = {
|
|||||||
"你的 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: "普通数据库同步命令开关",
|
NotionGeneralButton: "普通数据库同步命令开关",
|
||||||
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中",
|
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中",
|
||||||
NotionCustomTitle: "修改 Notion 数据库表头开关",
|
NotionCustomTitle: "修改 Notion 数据库表头开关",
|
||||||
NotionCustomTitleDesc: "自定义Notion 数据库第一列表头,默认关闭",
|
NotionCustomTitleDesc: "自定义Notion 数据库第一列表头,默认关闭",
|
||||||
NotionCustomTitleName: "想要修改的表头名",
|
NotionCustomTitleName: "想要修改的表头名",
|
||||||
NotionCustomTitleNameDesc: "输入你想要修改的notion数据库的表头名",
|
NotionCustomTitleNameDesc: "输入你想要修改的notion数据库的表头名",
|
||||||
NotionCustomTitleText: "输入表头名",
|
NotionCustomTitleText: "输入表头名",
|
||||||
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
||||||
PlaceHolder: "输入数据库名称",
|
PlaceHolder: "输入数据库名称",
|
||||||
"notion-logo": "分享到NotionNext",
|
"notion-logo": "分享到NotionNext",
|
||||||
"sync-success": "同步到NotionNext成功:\n",
|
"sync-success": "同步到NotionNext成功:\n",
|
||||||
@@ -94,9 +94,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 自定义数据库设置",
|
NotionCustomSettingHeader: "Notion 自定义数据库设置",
|
||||||
NotionCustomButton: "Notion 自定义数据库同步命令开关",
|
NotionCustomButton: "Notion 自定义数据库同步命令开关",
|
||||||
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中",
|
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
10
src/main.ts
10
src/main.ts
@@ -1,8 +1,8 @@
|
|||||||
import {App, Editor, MarkdownView, Notice, Plugin, PluginSettingTab, Setting} from "obsidian";
|
import { App, Editor, MarkdownView, Notice, Plugin, PluginSettingTab, Setting } from "obsidian";
|
||||||
import {addIcons} from 'src/ui/icon';
|
import { addIcons } from 'src/ui/icon';
|
||||||
import {Upload2NotionGeneral} from "src/upload/upload_general/Upload2NotionGeneral";
|
import { Upload2NotionGeneral } from "src/upload/upload_general/Upload2NotionGeneral";
|
||||||
import {Upload2NotionNext} from "src/upload/upload_next/Upload2NotionNext";
|
import { Upload2NotionNext } from "src/upload/upload_next/Upload2NotionNext";
|
||||||
import {i18nConfig} from "src/lang/I18n";
|
import { i18nConfig } from "src/lang/I18n";
|
||||||
import ribbonCommands from "src/commands/NotionCommands";
|
import ribbonCommands from "src/commands/NotionCommands";
|
||||||
import { ObsidianSettingTab, PluginSettings, DEFAULT_SETTINGS } from "src/ui/settingTabs";
|
import { ObsidianSettingTab, PluginSettings, DEFAULT_SETTINGS } from "src/ui/settingTabs";
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export interface PluginSettings {
|
|||||||
CustomButton: boolean;
|
CustomButton: boolean;
|
||||||
notionAPICustom: string;
|
notionAPICustom: string;
|
||||||
databaseIDCustom: string;
|
databaseIDCustom: string;
|
||||||
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: PluginSettings = {
|
export const DEFAULT_SETTINGS: PluginSettings = {
|
||||||
@@ -53,9 +54,9 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
// General Settings
|
// General Settings
|
||||||
containerEl.createEl('h2', { text: i18nConfig.GeneralSetting });
|
containerEl.createEl('h2', { text: i18nConfig.GeneralSetting });
|
||||||
|
|
||||||
this.createSettingEl(containerEl, i18nConfig.BannerUrl, i18nConfig.BannerUrlDesc, 'text', i18nConfig.BannerUrlText, this.plugin.settings.bannerUrl)
|
this.createSettingEl(containerEl, i18nConfig.BannerUrl, i18nConfig.BannerUrlDesc, 'text', i18nConfig.BannerUrlText, this.plugin.settings.bannerUrl, 'bannerUrl')
|
||||||
|
|
||||||
this.createSettingEl(containerEl, i18nConfig.NotionUser, i18nConfig.NotionUserDesc, 'text', i18nConfig.NotionUserText, this.plugin.settings.notionUser)
|
this.createSettingEl(containerEl, i18nConfig.NotionUser, i18nConfig.NotionUserDesc, 'text', i18nConfig.NotionUserText, this.plugin.settings.notionUser, 'notionUser')
|
||||||
|
|
||||||
containerEl.createEl('h2', { text: i18nConfig.NotionNextSettingHeader })
|
containerEl.createEl('h2', { text: i18nConfig.NotionNextSettingHeader })
|
||||||
|
|
||||||
@@ -80,10 +81,10 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
|
|
||||||
const notionAPINextEl = this.createStyleDiv('api-next', this.plugin.settings.NextButton)
|
const notionAPINextEl = this.createStyleDiv('api-next', this.plugin.settings.NextButton)
|
||||||
this.createSettingEl(notionAPINextEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPINext)
|
this.createSettingEl(notionAPINextEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPINext, 'notionAPINext')
|
||||||
|
|
||||||
const databaseIDNextEl = this.createStyleDiv('databaseID-next', this.plugin.settings.NextButton)
|
const databaseIDNextEl = this.createStyleDiv('databaseID-next', this.plugin.settings.NextButton)
|
||||||
this.createSettingEl(databaseIDNextEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDNext)
|
this.createSettingEl(databaseIDNextEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDNext, 'databaseIDNext')
|
||||||
|
|
||||||
|
|
||||||
// General Database Settings
|
// General Database Settings
|
||||||
@@ -129,7 +130,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const CustomNameEl = this.createStyleDiv('custom-name', this.plugin.settings.CustomTitleButton);
|
const CustomNameEl = this.createStyleDiv('custom-name', this.plugin.settings.CustomTitleButton);
|
||||||
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName)
|
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName, 'CustomTitleName')
|
||||||
|
|
||||||
// new Setting(containerEl)
|
// new Setting(containerEl)
|
||||||
// .setName("Convert tags(optional)")
|
// .setName("Convert tags(optional)")
|
||||||
@@ -144,11 +145,11 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
// );
|
// );
|
||||||
|
|
||||||
const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton);
|
const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton);
|
||||||
this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPIGeneral)
|
this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPIGeneral, 'notionAPIGeneral')
|
||||||
|
|
||||||
|
|
||||||
const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton);
|
const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton);
|
||||||
this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDGeneral)
|
this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDGeneral, 'databaseIDGeneral')
|
||||||
|
|
||||||
// Custom Database Settings
|
// Custom Database Settings
|
||||||
|
|
||||||
@@ -177,12 +178,12 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
private updateSettingEl(element: HTMLElement, commandValue: boolean) {
|
private updateSettingEl(element: HTMLElement, commandValue: boolean) {
|
||||||
element.style.borderTop = commandValue ? "1px solid var(--background-modifier-border)" : "none";
|
element.style.borderTop = commandValue ? "1px solid var(--background-modifier-border)" : "none";
|
||||||
element.style.paddingTop = commandValue ? "0.75em" : "0";
|
element.style.paddingTop = commandValue ? "0.75em" : "0";
|
||||||
element.style.display = commandValue? "block" : "none";
|
element.style.display = commandValue ? "block" : "none";
|
||||||
element.style.alignItems = "center";
|
element.style.alignItems = "center";
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to add one setting element in the setting tab.
|
// function to add one setting element in the setting tab.
|
||||||
private createSettingEl(containerEl: HTMLElement, name: string, desc: string, type: string, placeholder: string, holderValue: any) {
|
private createSettingEl(containerEl: HTMLElement, name: string, desc: string, type: string, placeholder: string, holderValue: any, settingsKey: string) {
|
||||||
if (type === 'password') {
|
if (type === 'password') {
|
||||||
return new Setting(containerEl)
|
return new Setting(containerEl)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
@@ -193,11 +194,10 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
.setPlaceholder(placeholder)
|
.setPlaceholder(placeholder)
|
||||||
.setValue(holderValue)
|
.setValue(holderValue)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
holderValue = value;
|
this.plugin.settings[settingsKey] = value; // Update the plugin settings directly
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
}
|
});
|
||||||
)
|
|
||||||
} else if (type === 'toggle') {
|
} else if (type === 'toggle') {
|
||||||
return new Setting(containerEl)
|
return new Setting(containerEl)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
@@ -206,13 +206,13 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
toggle
|
toggle
|
||||||
.setValue(holderValue)
|
.setValue(holderValue)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
holderValue = value;
|
this.plugin.settings[settingsKey] = value; // Update the plugin settings directly
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
await this.plugin.commands.updateCommand();
|
await this.plugin.commands.updateCommand();
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
} else if (type === 'text') {
|
} else if (type === 'text') {
|
||||||
new Setting(containerEl)
|
return new Setting(containerEl)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
.setDesc(desc)
|
.setDesc(desc)
|
||||||
.addText((text) =>
|
.addText((text) =>
|
||||||
@@ -220,11 +220,11 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
.setPlaceholder(placeholder)
|
.setPlaceholder(placeholder)
|
||||||
.setValue(holderValue)
|
.setValue(holderValue)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
holderValue = value;
|
this.plugin.settings[settingsKey] = value; // Update the plugin settings directly
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
await this.plugin.commands.updateCommand();
|
await this.plugin.commands.updateCommand();
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {App, Notice, TFile} from "obsidian";
|
import { App, Notice, TFile } from "obsidian";
|
||||||
import ObsidianSyncNotionPlugin from "../main";
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
import {PluginSettings} from "../ui/settingTabs";
|
import { PluginSettings } from "../ui/settingTabs";
|
||||||
|
|
||||||
export async function updateYamlInfo(
|
export async function updateYamlInfo(
|
||||||
yamlContent: string,
|
yamlContent: string,
|
||||||
@@ -9,7 +9,7 @@ export async function updateYamlInfo(
|
|||||||
app: App,
|
app: App,
|
||||||
plugin: ObsidianSyncNotionPlugin,
|
plugin: ObsidianSyncNotionPlugin,
|
||||||
) {
|
) {
|
||||||
let {url, id} = res.json
|
let { url, id } = res.json
|
||||||
// replace www to notionID
|
// replace www to notionID
|
||||||
const { notionUser } = plugin.settings;
|
const { notionUser } = plugin.settings;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import {i18nConfig} from "../lang/I18n";
|
import { i18nConfig } from "../lang/I18n";
|
||||||
import {App, Notice} from "obsidian";
|
import { App, Notice } from "obsidian";
|
||||||
import {Upload2NotionNext} from "./upload_next/Upload2NotionNext";
|
import { Upload2NotionNext } from "./upload_next/Upload2NotionNext";
|
||||||
import {Upload2NotionGeneral} from "./upload_general/Upload2NotionGeneral";
|
import { Upload2NotionGeneral } from "./upload_general/Upload2NotionGeneral";
|
||||||
import {PluginSettings} from "../ui/settingTabs";
|
import { PluginSettings } from "../ui/settingTabs";
|
||||||
import ObsidianSyncNotionPlugin from "../main";
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
import {getNowFileMarkdownContentNext} from "./upload_next/getMarkdownNext";
|
import { getNowFileMarkdownContentNext } from "./upload_next/getMarkdownNext";
|
||||||
import {getNowFileMarkdownContentGeneral} from "./upload_general/getMarkdownGeneral";
|
import { getNowFileMarkdownContentGeneral } from "./upload_general/getMarkdownGeneral";
|
||||||
|
|
||||||
export async function uploadCommandNext(
|
export async function uploadCommandNext(
|
||||||
plugin: ObsidianSyncNotionPlugin,
|
plugin: ObsidianSyncNotionPlugin,
|
||||||
@@ -13,7 +13,7 @@ export async function uploadCommandNext(
|
|||||||
app: App,
|
app: App,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const {notionAPINext, databaseIDNext} = settings;
|
const { notionAPINext, databaseIDNext } = settings;
|
||||||
|
|
||||||
// Check if NNon exists
|
// Check if NNon exists
|
||||||
// if (NNon === undefined) {
|
// if (NNon === undefined) {
|
||||||
@@ -29,10 +29,10 @@ export async function uploadCommandNext(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {markDownData, nowFile, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime} = await getNowFileMarkdownContentNext(app, settings)
|
const { markDownData, nowFile, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime } = await getNowFileMarkdownContentNext(app, settings)
|
||||||
|
|
||||||
if (markDownData) {
|
if (markDownData) {
|
||||||
const {basename} = nowFile;
|
const { basename } = nowFile;
|
||||||
const upload = new Upload2NotionNext(plugin);
|
const upload = new Upload2NotionNext(plugin);
|
||||||
const res = await upload.syncMarkdownToNotionNext(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app);
|
const res = await upload.syncMarkdownToNotionNext(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app);
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ export async function uploadCommandGeneral(
|
|||||||
app: App,
|
app: App,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const{ notionAPIGeneral, databaseIDGeneral} = settings;
|
const { notionAPIGeneral, databaseIDGeneral } = settings;
|
||||||
|
|
||||||
// Check if the user has set up the Notion API and database ID
|
// Check if the user has set up the Notion API and database ID
|
||||||
if (notionAPIGeneral === "" || databaseIDGeneral === "") {
|
if (notionAPIGeneral === "" || databaseIDGeneral === "") {
|
||||||
@@ -62,10 +62,10 @@ export async function uploadCommandGeneral(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {markDownData, nowFile,cover, tags} = await getNowFileMarkdownContentGeneral(app, settings)
|
const { markDownData, nowFile, cover, tags } = await getNowFileMarkdownContentGeneral(app, settings)
|
||||||
|
|
||||||
if (markDownData) {
|
if (markDownData) {
|
||||||
const {basename} = nowFile;
|
const { basename } = nowFile;
|
||||||
|
|
||||||
const upload = new Upload2NotionGeneral(plugin);
|
const upload = new Upload2NotionGeneral(plugin);
|
||||||
const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app);
|
const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app);
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import { markdownToBlocks, } from "@tryfabric/martian";
|
|||||||
import * as yamlFrontMatter from "yaml-front-matter";
|
import * as yamlFrontMatter from "yaml-front-matter";
|
||||||
// import * as yaml from "yaml"
|
// import * as yaml from "yaml"
|
||||||
import MyPlugin from "src/main";
|
import MyPlugin from "src/main";
|
||||||
import {PluginSettings} from "../../ui/settingTabs";
|
import { PluginSettings } from "../../ui/settingTabs";
|
||||||
import {UploadBaseGeneral} from "./BaseUpload2NotionGeneral";
|
import { UploadBaseGeneral } from "./BaseUpload2NotionGeneral";
|
||||||
import {updateYamlInfo} from "../updateYaml";
|
import { updateYamlInfo } from "../updateYaml";
|
||||||
|
|
||||||
export class Upload2NotionGeneral extends UploadBaseGeneral {
|
export class Upload2NotionGeneral extends UploadBaseGeneral {
|
||||||
settings: PluginSettings;
|
settings: PluginSettings;
|
||||||
|
|
||||||
constructor(plugin: MyPlugin) {
|
constructor(plugin: MyPlugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 因为需要解析notion的block进行对比,非常的麻烦,
|
// 因为需要解析notion的block进行对比,非常的麻烦,
|
||||||
@@ -22,7 +22,7 @@ export class Upload2NotionGeneral extends UploadBaseGeneral {
|
|||||||
title: string,
|
title: string,
|
||||||
cover: string,
|
cover: string,
|
||||||
tags: string[],
|
tags: string[],
|
||||||
childArr: any
|
childArr: any,
|
||||||
) {
|
) {
|
||||||
await this.deletePage(notionID)
|
await this.deletePage(notionID)
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ export class Upload2NotionGeneral extends UploadBaseGeneral {
|
|||||||
database_id: this.plugin.settings.databaseIDGeneral,
|
database_id: this.plugin.settings.databaseIDGeneral,
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
[this.plugin.settings.CustomTitleButton ? this.plugin.settings.CustomTitleName : 'title']: {
|
||||||
title: [
|
title: [
|
||||||
{
|
{
|
||||||
text: {
|
text: {
|
||||||
|
|||||||
Reference in New Issue
Block a user