update the script and support both notionnext and general database

This commit is contained in:
Jiaxin Peng
2023-11-05 17:32:10 +00:00
parent 8617878582
commit 398b785e03
14 changed files with 650 additions and 410 deletions

View File

@@ -1,11 +1,11 @@
import {App, Editor, MarkdownView, Notice, Plugin, PluginSettingTab, Setting} from "obsidian";
import {addIcons} from 'src/ui/icon';
import {Upload2NotionGeneral} from "src/upload/Upload2NotionGeneral";
import {Upload2NotionNext} from "src/upload/Upload2NotionNext";
import {Upload2NotionGeneral} from "src/upload/upload_general/Upload2NotionGeneral";
import {Upload2NotionNext} from "src/upload/upload_next/Upload2NotionNext";
import {i18nConfig} from "src/lang/I18n";
import ribbonCommands from "src/commands/NotionCommands";
import { ObsidianSettingTab, PluginSettings, DEFAULT_SETTINGS } from "src/ui/settingTabs";
import {getNowFileMarkdownContent} from "src/upload/getMarkdown";
// Remember to rename these classes and interfaces!
@@ -43,48 +43,6 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
onunload() {
}
// async uploadCommand() {
// const {notionAPI, databaseID, NNon} = this.settings;
//
// // Check if NNon exists
// if (NNon === undefined) {
// const NNonmessage = i18nConfig.NNonMissing;
// new Notice(NNonmessage);
// return;
// }
//
// // Check if the user has set up the Notion API and database ID
// if (notionAPI === "" || databaseID === "") {
// const setAPIMessage = i18nConfig["set-api-id"];
// new Notice(setAPIMessage);
// return;
// }
//
// const {markDownData, nowFile, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime} = await getNowFileMarkdownContent(this.app, this.settings)
//
// if (markDownData) {
// const {basename} = nowFile;
// let upload;
// let res;
//
// if (NNon) {
// upload = new Upload2NotionNext(this);
// res = await upload.syncMarkdownToNotionNext(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app, this.settings);
// } else {
// upload = new Upload2NotionGeneral(this);
// res = await upload.syncMarkdownToNotionGeneral(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app, this.settings);
// }
//
//
// if (res.status === 200) {
// new Notice(`${i18nConfig["sync-success"]}${basename}`);
// } else {
// new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
// }
// }
// }
async loadSettings() {
this.settings = Object.assign(
{},