From f282dde1b74aed148b4c470bc8bbf93573a947b5 Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sat, 31 Aug 2024 00:00:09 +0100 Subject: [PATCH 1/5] fix: test the desktop function of custom database with platform function --- src/lang/locale/en.ts | 1 + src/upload/uploadCommand.ts | 3 + .../upoload_custom/Upload2NotionCustom.ts | 143 ++++++++++++------ 3 files changed, 102 insertions(+), 45 deletions(-) diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 8c7fbef..23eb1b8 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -79,4 +79,5 @@ export const en = { BlockUploaded: "All blocks uploaded", ExtraBlockUploaded: "Extra blocks uploaded", CheckConsole: "Check the console for more information \n opt+cmd+i/ctrl+shift+i", + "reach-mobile-limit": "The number of blocks exceeds the limit of 100, please use the desktop plugin", } diff --git a/src/upload/uploadCommand.ts b/src/upload/uploadCommand.ts index d412aa5..cb440f7 100644 --- a/src/upload/uploadCommand.ts +++ b/src/upload/uploadCommand.ts @@ -111,6 +111,9 @@ export async function uploadCommandCustom( const {markDownData, nowFile, cover, customValues} = await getNowFileMarkdownContentCustom(app, dbDetails) + new Notice(`Start upload ${nowFile.basename}`); + console.log(`Start upload ${nowFile.basename}`); + if (markDownData) { const {basename} = nowFile; diff --git a/src/upload/upoload_custom/Upload2NotionCustom.ts b/src/upload/upoload_custom/Upload2NotionCustom.ts index de64711..797704c 100644 --- a/src/upload/upoload_custom/Upload2NotionCustom.ts +++ b/src/upload/upoload_custom/Upload2NotionCustom.ts @@ -1,4 +1,4 @@ -import {App, Notice, TFile} from "obsidian"; +import {App, Notice, Platform, TFile} from "obsidian"; import {markdownToBlocks} from "@jxpeng98/martian"; import * as yamlFrontMatter from "yaml-front-matter"; // import * as yaml from "yaml" @@ -10,6 +10,11 @@ import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; +interface CreatePageResponse { + response: any; + data: any; +} + export class Upload2NotionCustom extends UploadBaseCustom { settings: PluginSettings; dbDetails: DatabaseDetails; @@ -46,7 +51,7 @@ export class Upload2NotionCustom extends UploadBaseCustom { cover: string, customValues: Record, childArr: any, - ) { + ): Promise { const { databaseID, @@ -110,56 +115,81 @@ export class Upload2NotionCustom extends UploadBaseCustom { } console.log(bodyString) + console.log(Platform.isDesktopApp) - const response = await fetch("https://api.notion.com/v1/pages", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(bodyString), - }); + let response: any; + let data: any; - const data: any = await response.json(); - - if (!response.ok) { - new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${data.message}`); - } else { - console.log(`Page created: ${data.url}`); - console.log(`Page ID: ${data.id}`); - } - - // upload the rest of the blocks - if (pushCount > 0) { - for (let i = 0; i < pushCount; i++) { - const extraBlocks = { - children: extraArr[i], - }; - - console.log(extraBlocks) - - const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - method: "PATCH", + if (Platform.isMobileApp) { + if(childArrLength > 100) { + new Notice(i18nConfig["reach-mobile-limit"], 5000); + } else { + response = await requestUrl({ + url: `https://api.notion.com/v1/pages`, + method: "POST", headers: { "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, + // 'User-Agent': 'obsidian.md', + Authorization: + "Bearer " + notionAPI, "Notion-Version": "2022-06-28", }, - body: JSON.stringify(extraBlocks), + body: JSON.stringify(bodyString), }); + } + } - const extraData: any = await extraResponse.json(); + if (Platform.isDesktopApp) { + response = await fetch("https://api.notion.com/v1/pages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); - if (!extraResponse.ok) { - new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${extraData.message}`); - } else { - console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - if (i === pushCount - 1) { - console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + data = await response.json(); + + if (!response.ok) { + new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${data.message}`); + } else { + console.log(`Page created: ${data.url}`); + console.log(`Page ID: ${data.id}`); + } + + // upload the rest of the blocks + if (pushCount > 0) { + for (let i = 0; i < pushCount; i++) { + const extraBlocks = { + children: extraArr[i], + }; + + console.log(extraBlocks) + + const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(extraBlocks), + }); + + const extraData: any = await extraResponse.json(); + + if (!extraResponse.ok) { + new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${extraData.message}`); + } else { + console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + if (i === pushCount - 1) { + console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + } } } } @@ -209,10 +239,33 @@ export class Upload2NotionCustom extends UploadBaseCustom { // console.log(response) - if (response && response.status === 200) { - await updateYamlInfo(markdown, nowFile, data, app, this.plugin, this.dbDetails); + if (Platform.isDesktopApp) { + if (response && response.status === 200) { + await updateYamlInfo( + markdown, + nowFile, + data, + app, + this.plugin, + this.dbDetails + ); + } } + if (Platform.isMobileApp) { + if (response && response.status === 200) { + await updateYamlInfo( + markdown, + nowFile, + response, + app, + this.plugin, + this.dbDetails, + ); + } + } + + return res; } From 885ccba027a59321a7bbe44933a2b0ec81c51068 Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sat, 31 Aug 2024 23:43:19 +0100 Subject: [PATCH 2/5] fix: test the desktop function for next and general --- .../upload_general/Upload2NotionGeneral.ts | 151 ++++++++++++------ src/upload/upload_next/Upload2NotionNext.ts | 146 ++++++++++------- 2 files changed, 192 insertions(+), 105 deletions(-) diff --git a/src/upload/upload_general/Upload2NotionGeneral.ts b/src/upload/upload_general/Upload2NotionGeneral.ts index 8f9201a..eba4cbe 100644 --- a/src/upload/upload_general/Upload2NotionGeneral.ts +++ b/src/upload/upload_general/Upload2NotionGeneral.ts @@ -1,8 +1,6 @@ -import {App, Notice, TFile} from "obsidian"; -import {Client} from "@notionhq/client"; +import {App, Notice, TFile, Platform, requestUrl} from "obsidian"; import {markdownToBlocks} from "@jxpeng98/martian"; import * as yamlFrontMatter from "yaml-front-matter"; -// import * as yaml from "yaml" import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {UploadBaseGeneral} from "./BaseUpload2NotionGeneral"; @@ -10,6 +8,11 @@ import {updateYamlInfo} from "../updateYaml"; import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; +interface CreatePageResponse { + response: any; + data: any; +} + export class Upload2NotionGeneral extends UploadBaseGeneral { settings: PluginSettings; dbDetails: DatabaseDetails; @@ -48,7 +51,7 @@ export class Upload2NotionGeneral extends UploadBaseGeneral { cover: string, tags: string[], childArr: any, - ) { + ): Promise { const { databaseID, @@ -139,63 +142,89 @@ export class Upload2NotionGeneral extends UploadBaseGeneral { } console.log(bodyString) + console.log(Platform.isDesktopApp) - const response = await fetch("https://api.notion.com/v1/pages", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(bodyString), - }); + let response: any; + let data: any; - const data: any = await response.json(); - - if (!response.ok) { - new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - } else { - console.log(`Page created: ${data.url}`); - console.log(`Page ID: ${data.id}`); - } - - // upload the rest of the blocks - if (pushCount > 0) { - for (let i = 0; i < pushCount; i++) { - const extraBlocks = { - children: extraArr[i], - }; - - console.log(extraBlocks) - - const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - method: "PATCH", + if (Platform.isMobileApp) { + if(childArrLength > 100) { + new Notice(i18nConfig["reach-mobile-limit"], 5000); + } else { + response = await requestUrl({ + url: `https://api.notion.com/v1/pages`, + method: "POST", headers: { "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, + // 'User-Agent': 'obsidian.md', + Authorization: + "Bearer " + notionAPI, "Notion-Version": "2022-06-28", }, - body: JSON.stringify(extraBlocks), + body: JSON.stringify(bodyString), }); + } + } - const extraData: any = await extraResponse.json(); + if (Platform.isDesktopApp) { + response = await fetch("https://api.notion.com/v1/pages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); - if (!extraResponse.ok) { - new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${extraData.message}`); - } else { - console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - if (i === pushCount - 1) { - console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + data = await response.json(); + + if (!response.ok) { + new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${data.message}`); + } else { + console.log(`Page created: ${data.url}`); + console.log(`Page ID: ${data.id}`); + } + + // upload the rest of the blocks + if (pushCount > 0) { + for (let i = 0; i < pushCount; i++) { + const extraBlocks = { + children: extraArr[i], + }; + + console.log(extraBlocks) + + const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(extraBlocks), + }); + + const extraData: any = await extraResponse.json(); + + if (!extraResponse.ok) { + new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${extraData.message}`); + } else { + console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + if (i === pushCount - 1) { + console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + } } } } } return { - response, // for status code - data // for id and url + response, + data } } @@ -216,11 +245,11 @@ export class Upload2NotionGeneral extends UploadBaseGeneral { const yamlContent: any = yamlFrontMatter.loadFront(markdown); const __content = yamlContent.__content; const file2Block = markdownToBlocks(__content, options); - const frontmasster = + const frontMatter = app.metadataCache.getFileCache(nowFile)?.frontmatter; const {abName} = this.dbDetails const notionIDKey = `NotionID-${abName}`; - const notionID = frontmasster ? frontmasster[notionIDKey] : null; + const notionID = frontMatter ? frontMatter[notionIDKey] : null; if (notionID) { @@ -237,10 +266,30 @@ export class Upload2NotionGeneral extends UploadBaseGeneral { let {response, data} = res; - // console.log(response) + if (Platform.isDesktopApp) { + if (response && response.status === 200) { + await updateYamlInfo( + markdown, + nowFile, + data, + app, + this.plugin, + this.dbDetails + ); + } + } - if (response && response.status === 200) { - await updateYamlInfo(markdown, nowFile, data, app, this.plugin, this.dbDetails); + if (Platform.isMobileApp) { + if (response && response.status === 200) { + await updateYamlInfo( + markdown, + nowFile, + response, + app, + this.plugin, + this.dbDetails, + ); + } } return res; diff --git a/src/upload/upload_next/Upload2NotionNext.ts b/src/upload/upload_next/Upload2NotionNext.ts index 832e163..57bff03 100644 --- a/src/upload/upload_next/Upload2NotionNext.ts +++ b/src/upload/upload_next/Upload2NotionNext.ts @@ -1,5 +1,5 @@ import {UploadBaseNext} from "./BaseUpload2NotionNext"; -import {App, Notice, TFile} from "obsidian"; +import {App, Notice, TFile, Platform, requestUrl} from "obsidian"; import {Client} from "@notionhq/client"; import {markdownToBlocks} from "@jxpeng98/martian"; import * as yamlFrontMatter from "yaml-front-matter"; @@ -8,9 +8,14 @@ import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {updateYamlInfo} from "../updateYaml"; import {LIMITS, paragraph} from "@jxpeng98/martian/src/notion"; -import fetch from "node-fetch"; +import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; +interface CreatePageResponse { + response: any; + data: any; +} + export class Upload2NotionNext extends UploadBaseNext { settings: PluginSettings; dbDetails: DatabaseDetails; @@ -79,7 +84,7 @@ export class Upload2NotionNext extends UploadBaseNext { favicon: string, datetime: string, childArr: any, - ) { + ): Promise { const {databaseID, notionAPI} = this.dbDetails; // remove the annotations from the childArr if type is code block @@ -241,39 +246,59 @@ export class Upload2NotionNext extends UploadBaseNext { console.log(bodyString); - const response = await fetch("https://api.notion.com/v1/pages", { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(bodyString), - }); + let response: any; + let data: any; - const data: any = await response.json(); - - // can use response.ok or response.status === 200 - if (!response.ok) { - new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${data.message}`); - } else { - console.log(`Page created: ${data.url}`); - console.log(`Page ID: ${data.id}`); + if (Platform.isMobileApp) { + if(childArrLength > 100) { + new Notice(i18nConfig["reach-mobile-limit"], 5000); + } else { + response = await requestUrl({ + url: `https://api.notion.com/v1/pages`, + method: "POST", + headers: { + "Content-Type": "application/json", + // 'User-Agent': 'obsidian.md', + Authorization: + "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); + } } - // if the childArr is over 100, patch the rest of the blocks append to the page - if (pushCount > 0) { - for (let i = 0; i < pushCount; i++) { - const extraBlocks = { - children: extraArr[i] - } + if (Platform.isDesktopApp) { + response = await fetch("https://api.notion.com/v1/pages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); - console.log(extraBlocks) + data = await response.json(); - const extraResponse = await fetch( - `https://api.notion.com/v1/blocks/${data.id}/children`, - { + if (!response.ok) { + new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${data.message}`); + } else { + console.log(`Page created: ${data.url}`); + console.log(`Page ID: ${data.id}`); + } + + // upload the rest of the blocks + if (pushCount > 0) { + for (let i = 0; i < pushCount; i++) { + const extraBlocks = { + children: extraArr[i], + }; + + console.log(extraBlocks) + + const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { method: "PATCH", headers: { "Content-Type": "application/json", @@ -283,27 +308,25 @@ export class Upload2NotionNext extends UploadBaseNext { body: JSON.stringify(extraBlocks), }); - const extraData: any = await extraResponse.json(); + const extraData: any = await extraResponse.json(); - if (!extraResponse.ok) { - new Notice( - `Extra Block: Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, - 5000, - ); - console.log(`Error message: \n ${extraData.message}`); - } else { - console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - if (i === pushCount - 1) { - console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + if (!extraResponse.ok) { + new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${extraData.message}`); + } else { + console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + if (i === pushCount - 1) { + console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + } } } } } return { - response, // for status code - data, // for id and url + response, + data }; } @@ -395,15 +418,30 @@ export class Upload2NotionNext extends UploadBaseNext { let {response, data} = res; - if (response && response.status === 200) { - await updateYamlInfo( - markdown, - nowFile, - data, - app, - this.plugin, - this.dbDetails, - ); + if (Platform.isDesktopApp) { + if (response && response.status === 200) { + await updateYamlInfo( + markdown, + nowFile, + data, + app, + this.plugin, + this.dbDetails + ); + } + } + + if (Platform.isMobileApp) { + if (response && response.status === 200) { + await updateYamlInfo( + markdown, + nowFile, + response, + app, + this.plugin, + this.dbDetails, + ); + } } return res; From a90e4871bb0812be6e571cc6dcc85623b19a97cf Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sun, 1 Sep 2024 22:57:03 +0100 Subject: [PATCH 3/5] Backup mobile requesturl after version 2.4.1 --- src/upload/uploadCommand.ts | 3 + .../upload_general/Upload2NotionGeneral.ts | 112 ++++++++--------- src/upload/upload_next/Upload2NotionNext.ts | 114 +++++++++-------- .../upoload_custom/Upload2NotionCustom.ts | 116 +++++++++--------- 4 files changed, 172 insertions(+), 173 deletions(-) diff --git a/src/upload/uploadCommand.ts b/src/upload/uploadCommand.ts index cb440f7..63fa6dc 100644 --- a/src/upload/uploadCommand.ts +++ b/src/upload/uploadCommand.ts @@ -76,6 +76,9 @@ export async function uploadCommandGeneral( const {markDownData, nowFile, cover, tags} = await getNowFileMarkdownContentGeneral(app, settings) + new Notice(`Start upload ${nowFile.basename}`); + console.log(`Start upload ${nowFile.basename}`); + if (markDownData) { const {basename} = nowFile; diff --git a/src/upload/upload_general/Upload2NotionGeneral.ts b/src/upload/upload_general/Upload2NotionGeneral.ts index eba4cbe..4645fe8 100644 --- a/src/upload/upload_general/Upload2NotionGeneral.ts +++ b/src/upload/upload_general/Upload2NotionGeneral.ts @@ -5,7 +5,7 @@ import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {UploadBaseGeneral} from "./BaseUpload2NotionGeneral"; import {updateYamlInfo} from "../updateYaml"; -import fetch from 'node-fetch'; +// import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; interface CreatePageResponse { @@ -166,61 +166,61 @@ export class Upload2NotionGeneral extends UploadBaseGeneral { } } - if (Platform.isDesktopApp) { - response = await fetch("https://api.notion.com/v1/pages", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(bodyString), - }); - - data = await response.json(); - - if (!response.ok) { - new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${data.message}`); - } else { - console.log(`Page created: ${data.url}`); - console.log(`Page ID: ${data.id}`); - } - - // upload the rest of the blocks - if (pushCount > 0) { - for (let i = 0; i < pushCount; i++) { - const extraBlocks = { - children: extraArr[i], - }; - - console.log(extraBlocks) - - const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - method: "PATCH", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(extraBlocks), - }); - - const extraData: any = await extraResponse.json(); - - if (!extraResponse.ok) { - new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${extraData.message}`); - } else { - console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - if (i === pushCount - 1) { - console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); - } - } - } - } - } + // if (Platform.isDesktopApp) { + // response = await fetch("https://api.notion.com/v1/pages", { + // method: "POST", + // headers: { + // "Content-Type": "application/json", + // "Authorization": "Bearer " + notionAPI, + // "Notion-Version": "2022-06-28", + // }, + // body: JSON.stringify(bodyString), + // }); + // + // data = await response.json(); + // + // if (!response.ok) { + // new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + // console.log(`Error message: \n ${data.message}`); + // } else { + // console.log(`Page created: ${data.url}`); + // console.log(`Page ID: ${data.id}`); + // } + // + // // upload the rest of the blocks + // if (pushCount > 0) { + // for (let i = 0; i < pushCount; i++) { + // const extraBlocks = { + // children: extraArr[i], + // }; + // + // console.log(extraBlocks) + // + // const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + // method: "PATCH", + // headers: { + // "Content-Type": "application/json", + // "Authorization": "Bearer " + notionAPI, + // "Notion-Version": "2022-06-28", + // }, + // body: JSON.stringify(extraBlocks), + // }); + // + // const extraData: any = await extraResponse.json(); + // + // if (!extraResponse.ok) { + // new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + // console.log(`Error message: \n ${extraData.message}`); + // } else { + // console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + // if (i === pushCount - 1) { + // console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + // new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + // } + // } + // } + // } + // } return { response, diff --git a/src/upload/upload_next/Upload2NotionNext.ts b/src/upload/upload_next/Upload2NotionNext.ts index 57bff03..592cb9b 100644 --- a/src/upload/upload_next/Upload2NotionNext.ts +++ b/src/upload/upload_next/Upload2NotionNext.ts @@ -1,14 +1,12 @@ import {UploadBaseNext} from "./BaseUpload2NotionNext"; import {App, Notice, TFile, Platform, requestUrl} from "obsidian"; -import {Client} from "@notionhq/client"; import {markdownToBlocks} from "@jxpeng98/martian"; import * as yamlFrontMatter from "yaml-front-matter"; -// import * as yaml from "yaml" import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {updateYamlInfo} from "../updateYaml"; import {LIMITS, paragraph} from "@jxpeng98/martian/src/notion"; -import fetch from 'node-fetch'; +// import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; interface CreatePageResponse { @@ -268,61 +266,61 @@ export class Upload2NotionNext extends UploadBaseNext { } } - if (Platform.isDesktopApp) { - response = await fetch("https://api.notion.com/v1/pages", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(bodyString), - }); - - data = await response.json(); - - if (!response.ok) { - new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${data.message}`); - } else { - console.log(`Page created: ${data.url}`); - console.log(`Page ID: ${data.id}`); - } - - // upload the rest of the blocks - if (pushCount > 0) { - for (let i = 0; i < pushCount; i++) { - const extraBlocks = { - children: extraArr[i], - }; - - console.log(extraBlocks) - - const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - method: "PATCH", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(extraBlocks), - }); - - const extraData: any = await extraResponse.json(); - - if (!extraResponse.ok) { - new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${extraData.message}`); - } else { - console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - if (i === pushCount - 1) { - console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); - } - } - } - } - } + // if (Platform.isDesktopApp) { + // response = await fetch("https://api.notion.com/v1/pages", { + // method: "POST", + // headers: { + // "Content-Type": "application/json", + // "Authorization": "Bearer " + notionAPI, + // "Notion-Version": "2022-06-28", + // }, + // body: JSON.stringify(bodyString), + // }); + // + // data = await response.json(); + // + // if (!response.ok) { + // new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + // console.log(`Error message: \n ${data.message}`); + // } else { + // console.log(`Page created: ${data.url}`); + // console.log(`Page ID: ${data.id}`); + // } + // + // // upload the rest of the blocks + // if (pushCount > 0) { + // for (let i = 0; i < pushCount; i++) { + // const extraBlocks = { + // children: extraArr[i], + // }; + // + // console.log(extraBlocks) + // + // const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + // method: "PATCH", + // headers: { + // "Content-Type": "application/json", + // "Authorization": "Bearer " + notionAPI, + // "Notion-Version": "2022-06-28", + // }, + // body: JSON.stringify(extraBlocks), + // }); + // + // const extraData: any = await extraResponse.json(); + // + // if (!extraResponse.ok) { + // new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + // console.log(`Error message: \n ${extraData.message}`); + // } else { + // console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + // if (i === pushCount - 1) { + // console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + // new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + // } + // } + // } + // } + // } return { response, diff --git a/src/upload/upoload_custom/Upload2NotionCustom.ts b/src/upload/upoload_custom/Upload2NotionCustom.ts index 797704c..9f072b6 100644 --- a/src/upload/upoload_custom/Upload2NotionCustom.ts +++ b/src/upload/upoload_custom/Upload2NotionCustom.ts @@ -1,12 +1,11 @@ -import {App, Notice, Platform, TFile} from "obsidian"; +import {App, Notice, Platform, TFile, requestUrl} from "obsidian"; import {markdownToBlocks} from "@jxpeng98/martian"; import * as yamlFrontMatter from "yaml-front-matter"; -// import * as yaml from "yaml" import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {updateYamlInfo} from "../updateYaml"; import {UploadBaseCustom} from "./BaseUpload2NotionCustom"; -import fetch from 'node-fetch'; +// import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; @@ -139,61 +138,61 @@ export class Upload2NotionCustom extends UploadBaseCustom { } } - if (Platform.isDesktopApp) { - response = await fetch("https://api.notion.com/v1/pages", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(bodyString), - }); - - data = await response.json(); - - if (!response.ok) { - new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${data.message}`); - } else { - console.log(`Page created: ${data.url}`); - console.log(`Page ID: ${data.id}`); - } - - // upload the rest of the blocks - if (pushCount > 0) { - for (let i = 0; i < pushCount; i++) { - const extraBlocks = { - children: extraArr[i], - }; - - console.log(extraBlocks) - - const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - method: "PATCH", - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer " + notionAPI, - "Notion-Version": "2022-06-28", - }, - body: JSON.stringify(extraBlocks), - }); - - const extraData: any = await extraResponse.json(); - - if (!extraResponse.ok) { - new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - console.log(`Error message: \n ${extraData.message}`); - } else { - console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - if (i === pushCount - 1) { - console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); - } - } - } - } - } + // if (Platform.isDesktopApp) { + // response = await fetch("https://api.notion.com/v1/pages", { + // method: "POST", + // headers: { + // "Content-Type": "application/json", + // "Authorization": "Bearer " + notionAPI, + // "Notion-Version": "2022-06-28", + // }, + // body: JSON.stringify(bodyString), + // }); + // + // data = await response.json(); + // + // if (!response.ok) { + // new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + // console.log(`Error message: \n ${data.message}`); + // } else { + // console.log(`Page created: ${data.url}`); + // console.log(`Page ID: ${data.id}`); + // } + // + // // upload the rest of the blocks + // if (pushCount > 0) { + // for (let i = 0; i < pushCount; i++) { + // const extraBlocks = { + // children: extraArr[i], + // }; + // + // console.log(extraBlocks) + // + // const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + // method: "PATCH", + // headers: { + // "Content-Type": "application/json", + // "Authorization": "Bearer " + notionAPI, + // "Notion-Version": "2022-06-28", + // }, + // body: JSON.stringify(extraBlocks), + // }); + // + // const extraData: any = await extraResponse.json(); + // + // if (!extraResponse.ok) { + // new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + // console.log(`Error message: \n ${extraData.message}`); + // } else { + // console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + // if (i === pushCount - 1) { + // console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + // new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + // } + // } + // } + // } + // } return { response, // for status code @@ -265,7 +264,6 @@ export class Upload2NotionCustom extends UploadBaseCustom { } } - return res; } From 1b385ccd0a5b1f783867a402e61bf6fa8fba094e Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sun, 1 Sep 2024 23:26:22 +0100 Subject: [PATCH 4/5] solve: the fail to load of mobile caused by the node version --- .gitignore | 5 +- .../upload_general/Upload2NotionGeneral.ts | 112 +++++++++--------- src/upload/upload_next/Upload2NotionNext.ts | 112 +++++++++--------- .../upoload_custom/Upload2NotionCustom.ts | 112 +++++++++--------- 4 files changed, 172 insertions(+), 169 deletions(-) diff --git a/.gitignore b/.gitignore index c344413..142a30f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,7 @@ data.json # Exclude macOS Finder (System Explorer) View States .DS_Store -.history \ No newline at end of file +.history + +# local data +local-data diff --git a/src/upload/upload_general/Upload2NotionGeneral.ts b/src/upload/upload_general/Upload2NotionGeneral.ts index 4645fe8..eba4cbe 100644 --- a/src/upload/upload_general/Upload2NotionGeneral.ts +++ b/src/upload/upload_general/Upload2NotionGeneral.ts @@ -5,7 +5,7 @@ import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {UploadBaseGeneral} from "./BaseUpload2NotionGeneral"; import {updateYamlInfo} from "../updateYaml"; -// import fetch from 'node-fetch'; +import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; interface CreatePageResponse { @@ -166,61 +166,61 @@ export class Upload2NotionGeneral extends UploadBaseGeneral { } } - // if (Platform.isDesktopApp) { - // response = await fetch("https://api.notion.com/v1/pages", { - // method: "POST", - // headers: { - // "Content-Type": "application/json", - // "Authorization": "Bearer " + notionAPI, - // "Notion-Version": "2022-06-28", - // }, - // body: JSON.stringify(bodyString), - // }); - // - // data = await response.json(); - // - // if (!response.ok) { - // new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - // console.log(`Error message: \n ${data.message}`); - // } else { - // console.log(`Page created: ${data.url}`); - // console.log(`Page ID: ${data.id}`); - // } - // - // // upload the rest of the blocks - // if (pushCount > 0) { - // for (let i = 0; i < pushCount; i++) { - // const extraBlocks = { - // children: extraArr[i], - // }; - // - // console.log(extraBlocks) - // - // const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - // method: "PATCH", - // headers: { - // "Content-Type": "application/json", - // "Authorization": "Bearer " + notionAPI, - // "Notion-Version": "2022-06-28", - // }, - // body: JSON.stringify(extraBlocks), - // }); - // - // const extraData: any = await extraResponse.json(); - // - // if (!extraResponse.ok) { - // new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - // console.log(`Error message: \n ${extraData.message}`); - // } else { - // console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - // if (i === pushCount - 1) { - // console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - // new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); - // } - // } - // } - // } - // } + if (Platform.isDesktopApp) { + response = await fetch("https://api.notion.com/v1/pages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); + + data = await response.json(); + + if (!response.ok) { + new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${data.message}`); + } else { + console.log(`Page created: ${data.url}`); + console.log(`Page ID: ${data.id}`); + } + + // upload the rest of the blocks + if (pushCount > 0) { + for (let i = 0; i < pushCount; i++) { + const extraBlocks = { + children: extraArr[i], + }; + + console.log(extraBlocks) + + const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(extraBlocks), + }); + + const extraData: any = await extraResponse.json(); + + if (!extraResponse.ok) { + new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${extraData.message}`); + } else { + console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + if (i === pushCount - 1) { + console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + } + } + } + } + } return { response, diff --git a/src/upload/upload_next/Upload2NotionNext.ts b/src/upload/upload_next/Upload2NotionNext.ts index 592cb9b..1f1ef01 100644 --- a/src/upload/upload_next/Upload2NotionNext.ts +++ b/src/upload/upload_next/Upload2NotionNext.ts @@ -6,7 +6,7 @@ import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {updateYamlInfo} from "../updateYaml"; import {LIMITS, paragraph} from "@jxpeng98/martian/src/notion"; -// import fetch from 'node-fetch'; +import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; interface CreatePageResponse { @@ -266,61 +266,61 @@ export class Upload2NotionNext extends UploadBaseNext { } } - // if (Platform.isDesktopApp) { - // response = await fetch("https://api.notion.com/v1/pages", { - // method: "POST", - // headers: { - // "Content-Type": "application/json", - // "Authorization": "Bearer " + notionAPI, - // "Notion-Version": "2022-06-28", - // }, - // body: JSON.stringify(bodyString), - // }); - // - // data = await response.json(); - // - // if (!response.ok) { - // new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - // console.log(`Error message: \n ${data.message}`); - // } else { - // console.log(`Page created: ${data.url}`); - // console.log(`Page ID: ${data.id}`); - // } - // - // // upload the rest of the blocks - // if (pushCount > 0) { - // for (let i = 0; i < pushCount; i++) { - // const extraBlocks = { - // children: extraArr[i], - // }; - // - // console.log(extraBlocks) - // - // const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - // method: "PATCH", - // headers: { - // "Content-Type": "application/json", - // "Authorization": "Bearer " + notionAPI, - // "Notion-Version": "2022-06-28", - // }, - // body: JSON.stringify(extraBlocks), - // }); - // - // const extraData: any = await extraResponse.json(); - // - // if (!extraResponse.ok) { - // new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - // console.log(`Error message: \n ${extraData.message}`); - // } else { - // console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - // if (i === pushCount - 1) { - // console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - // new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); - // } - // } - // } - // } - // } + if (Platform.isDesktopApp) { + response = await fetch("https://api.notion.com/v1/pages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); + + data = await response.json(); + + if (!response.ok) { + new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${data.message}`); + } else { + console.log(`Page created: ${data.url}`); + console.log(`Page ID: ${data.id}`); + } + + // upload the rest of the blocks + if (pushCount > 0) { + for (let i = 0; i < pushCount; i++) { + const extraBlocks = { + children: extraArr[i], + }; + + console.log(extraBlocks) + + const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(extraBlocks), + }); + + const extraData: any = await extraResponse.json(); + + if (!extraResponse.ok) { + new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${extraData.message}`); + } else { + console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + if (i === pushCount - 1) { + console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + } + } + } + } + } return { response, diff --git a/src/upload/upoload_custom/Upload2NotionCustom.ts b/src/upload/upoload_custom/Upload2NotionCustom.ts index 9f072b6..552a458 100644 --- a/src/upload/upoload_custom/Upload2NotionCustom.ts +++ b/src/upload/upoload_custom/Upload2NotionCustom.ts @@ -5,7 +5,7 @@ import MyPlugin from "src/main"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {updateYamlInfo} from "../updateYaml"; import {UploadBaseCustom} from "./BaseUpload2NotionCustom"; -// import fetch from 'node-fetch'; +import fetch from 'node-fetch'; import {i18nConfig} from "../../lang/I18n"; @@ -138,61 +138,61 @@ export class Upload2NotionCustom extends UploadBaseCustom { } } - // if (Platform.isDesktopApp) { - // response = await fetch("https://api.notion.com/v1/pages", { - // method: "POST", - // headers: { - // "Content-Type": "application/json", - // "Authorization": "Bearer " + notionAPI, - // "Notion-Version": "2022-06-28", - // }, - // body: JSON.stringify(bodyString), - // }); - // - // data = await response.json(); - // - // if (!response.ok) { - // new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - // console.log(`Error message: \n ${data.message}`); - // } else { - // console.log(`Page created: ${data.url}`); - // console.log(`Page ID: ${data.id}`); - // } - // - // // upload the rest of the blocks - // if (pushCount > 0) { - // for (let i = 0; i < pushCount; i++) { - // const extraBlocks = { - // children: extraArr[i], - // }; - // - // console.log(extraBlocks) - // - // const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { - // method: "PATCH", - // headers: { - // "Content-Type": "application/json", - // "Authorization": "Bearer " + notionAPI, - // "Notion-Version": "2022-06-28", - // }, - // body: JSON.stringify(extraBlocks), - // }); - // - // const extraData: any = await extraResponse.json(); - // - // if (!extraResponse.ok) { - // new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); - // console.log(`Error message: \n ${extraData.message}`); - // } else { - // console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); - // if (i === pushCount - 1) { - // console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); - // new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); - // } - // } - // } - // } - // } + if (Platform.isDesktopApp) { + response = await fetch("https://api.notion.com/v1/pages", { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(bodyString), + }); + + data = await response.json(); + + if (!response.ok) { + new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${data.message}`); + } else { + console.log(`Page created: ${data.url}`); + console.log(`Page ID: ${data.id}`); + } + + // upload the rest of the blocks + if (pushCount > 0) { + for (let i = 0; i < pushCount; i++) { + const extraBlocks = { + children: extraArr[i], + }; + + console.log(extraBlocks) + + const extraResponse = await fetch(`https://api.notion.com/v1/blocks/${data.id}/children`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notionAPI, + "Notion-Version": "2022-06-28", + }, + body: JSON.stringify(extraBlocks), + }); + + const extraData: any = await extraResponse.json(); + + if (!extraResponse.ok) { + new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000); + console.log(`Error message: \n ${extraData.message}`); + } else { + console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`); + if (i === pushCount - 1) { + console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`); + new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000); + } + } + } + } + } return { response, // for status code From 296125f6b405f68a82b6d504d7ca55dce9925a39 Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Tue, 3 Sep 2024 12:15:36 +0100 Subject: [PATCH 5/5] chore: remove process from dependencies --- package.json | 3 +-- yarn.lock | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d5d4a30..4342567 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,8 @@ "@jxpeng98/martian": "^1.2.7", "https-proxy-agent": "^7.0.2", "node-fetch": "^3.3.2", - "process": "^0.11.10", "remark-math": "^6.0.0", "yaml": "^2.3.4", "yaml-front-matter": "^4.1.1" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index fab5712..c3c78f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -460,6 +460,14 @@ commander@^8.3.0: resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== +cors@^2.8.5: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + data-uri-to-buffer@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" @@ -714,6 +722,11 @@ katex@^0.16.0: dependencies: commander "^8.3.0" +ky@^1.7.2: + version "1.7.2" + resolved "https://registry.yarnpkg.com/ky/-/ky-1.7.2.tgz#b97d9b997ba51ff1e152f0815d3d27b86513eb1c" + integrity sha512-OzIvbHKKDpi60TnF9t7UUVAF1B4mcqc02z5PIvrm08Wyb+yOcz63GRvEuVxNT18a9E1SrNouhB4W2NNLeD7Ykg== + longest-streak@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4" @@ -1215,6 +1228,11 @@ node-fetch@^3.3.2: fetch-blob "^3.1.4" formdata-polyfill "^4.0.10" +object-assign@^4: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== + obsidian@^1.6.6: version "1.6.6" resolved "https://registry.yarnpkg.com/obsidian/-/obsidian-1.6.6.tgz#d45c4021c291765e1b77ed4a1c645e562ff6e77f" @@ -1245,11 +1263,6 @@ picomatch@^2.3.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== -process@^0.11.10: - version "0.11.10" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== - queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -1446,6 +1459,11 @@ unist-util-visit@^5.0.0: unist-util-is "^6.0.0" unist-util-visit-parents "^6.0.0" +vary@^1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + vfile-message@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-2.0.4.tgz#5b43b88171d409eae58477d13f23dd41d52c371a"