feat: support long notes syncing

This commit is contained in:
Jiaxin Peng
2024-08-18 17:16:08 +01:00
parent 800e218dee
commit b05c248c44
9 changed files with 514 additions and 321 deletions

View File

@@ -1,13 +1,13 @@
import { i18nConfig } from "../lang/I18n";
import { App, Notice } from "obsidian";
import { Upload2NotionNext } from "./upload_next/Upload2NotionNext";
import { Upload2NotionGeneral } from "./upload_general/Upload2NotionGeneral";
import { Upload2NotionCustom } from "./upoload_custom/Upload2NotionCustom";
import { DatabaseDetails, PluginSettings } from "../ui/settingTabs";
import {i18nConfig} from "../lang/I18n";
import {App, Notice} from "obsidian";
import {Upload2NotionNext} from "./upload_next/Upload2NotionNext";
import {Upload2NotionGeneral} from "./upload_general/Upload2NotionGeneral";
import {Upload2NotionCustom} from "./upoload_custom/Upload2NotionCustom";
import {DatabaseDetails, PluginSettings} from "../ui/settingTabs";
import ObsidianSyncNotionPlugin from "../main";
import { getNowFileMarkdownContentNext } from "./upload_next/getMarkdownNext";
import { getNowFileMarkdownContentGeneral } from "./upload_general/getMarkdownGeneral";
import { getNowFileMarkdownContentCustom } from "./upoload_custom/getMarkdownCustom";
import {getNowFileMarkdownContentNext} from "./upload_next/getMarkdownNext";
import {getNowFileMarkdownContentGeneral} from "./upload_general/getMarkdownGeneral";
import {getNowFileMarkdownContentCustom} from "./upoload_custom/getMarkdownCustom";
export async function uploadCommandNext(
plugin: ObsidianSyncNotionPlugin,
@@ -16,7 +16,7 @@ export async function uploadCommandNext(
app: App,
) {
const { notionAPI, databaseID } = dbDetails;
const {notionAPI, databaseID} = dbDetails;
// Check if the user has set up the Notion API and database ID
if (notionAPI === "" || databaseID === "") {
@@ -42,12 +42,12 @@ export async function uploadCommandNext(
} = await getNowFileMarkdownContentNext(app, settings)
if (markDownData) {
const { basename } = nowFile;
const {basename} = nowFile;
const upload = new Upload2NotionNext(plugin, dbDetails);
const res = await upload.syncMarkdownToNotionNext(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app);
const { response } = res;
const {response} = res;
if (response.status === 200) {
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
} else {
@@ -65,7 +65,7 @@ export async function uploadCommandGeneral(
app: App,
) {
const { notionAPI, databaseID } = dbDetails;
const {notionAPI, databaseID} = dbDetails;
// Check if the user has set up the Notion API and database ID
if (notionAPI === "" || databaseID === "") {
@@ -74,15 +74,15 @@ export async function uploadCommandGeneral(
return;
}
const { markDownData, nowFile, cover, tags } = await getNowFileMarkdownContentGeneral(app, settings)
const {markDownData, nowFile, cover, tags} = await getNowFileMarkdownContentGeneral(app, settings)
if (markDownData) {
const { basename } = nowFile;
const {basename} = nowFile;
const upload = new Upload2NotionGeneral(plugin, dbDetails);
const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app);
const { response } = res;
const {response} = res;
if (response.status === 200) {
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
} else {
@@ -100,7 +100,7 @@ export async function uploadCommandCustom(
app: App,
) {
const { notionAPI, databaseID } = settings;
const {notionAPI, databaseID} = settings;
// Check if the user has set up the Notion API and database ID
if (notionAPI === "" || databaseID === "") {
@@ -109,15 +109,15 @@ export async function uploadCommandCustom(
return;
}
const { markDownData, nowFile, cover, customValues } = await getNowFileMarkdownContentCustom(app, dbDetails)
const {markDownData, nowFile, cover, customValues} = await getNowFileMarkdownContentCustom(app, dbDetails)
if (markDownData) {
const { basename } = nowFile;
const {basename} = nowFile;
const upload = new Upload2NotionCustom(plugin, dbDetails);
const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app);
const { response } = res;
const {response} = res;
if (response.status === 200) {
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
} else {