Compare commits

..

9 Commits

Author SHA1 Message Date
Jiaxin Peng
a950e2e301 Update version to 2.5.0 2024-11-20 22:19:38 +00:00
Jiaxin Peng
aac7bc154a feat: consistent sync function (requestUrl) for desktop and mobile 2024-11-20 22:19:03 +00:00
Jiaxin Peng
a573ef728d chore: remove node-fetch and change the platform back to browser. 2024-11-20 22:17:49 +00:00
Jiaxin Peng
1344c14933 Update version to 2.4.3 2024-10-22 10:29:09 +01:00
Jiaxin Peng
c1f4ecd14b Update version to 2.4.3 2024-10-22 10:27:49 +01:00
Jiaxin Peng
5942876c92 fix: cannot parse title from front matter 2024-10-22 10:27:33 +01:00
Jiaxin Peng
3218eb9fba Update version to 2.4.2 2024-09-19 13:50:51 +01:00
Jiaxin Peng
48566eca20 Merge pull request #37 from jxpeng98/pluggin-does-not-appear-on-mac
fix: obsidian language not set in English, Chinese and Japanese
2024-09-19 13:49:08 +01:00
Jiaxin Peng
8bd8346423 fix: obsidian language not set in English, Chinese and Japanese 2024-09-19 13:47:57 +01:00
12 changed files with 260 additions and 310 deletions

View File

@@ -1,4 +1,15 @@
## Fix ## Fix
- Fix code block not being highlighted in Notion after syncing. - Fix the bug that the plugin does not work in the mobile app.
- 修复代码块同步之后,在 Notion 中未高亮的问题。 - 修复了在移动端应用中插件无法工作的问题。
## Feature
- Both desktop and mobile apps support syncing long markdown files.
- 桌面端和移动端应用都支持长篇 markdown 文件同步。
## Issue
- Bullet list over 3 levels is not supported.
- 无法同步超过三个分支的列表。

View File

@@ -41,7 +41,6 @@ const ctx = await esbuild.context({
"@codemirror/view", "@codemirror/view",
...builtins, ...builtins,
], ],
platform: "node",
format: "cjs", format: "cjs",
target: "es2016", target: "es2016",
logLevel: "info", logLevel: "info",

View File

@@ -1,7 +1,7 @@
{ {
"id": "share-to-notionnext", "id": "share-to-notionnext",
"name": "Share to NotionNext", "name": "Share to NotionNext",
"version": "2.4.1", "version": "2.5.0",
"minAppVersion": "0.0.1", "minAppVersion": "0.0.1",
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.", "description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
"author": "EasyChris, jxpeng98", "author": "EasyChris, jxpeng98",

View File

@@ -1,6 +1,6 @@
{ {
"name": "share-to-notionnext", "name": "share-to-notionnext",
"version": "2.4.1", "version": "2.5.0",
"type": "module", "type": "module",
"description": "Share files to any Notion database using the Notion API, originally created by EasyChris/obsidian-to-notion.", "description": "Share files to any Notion database using the Notion API, originally created by EasyChris/obsidian-to-notion.",
"main": "main.js", "main": "main.js",
@@ -26,7 +26,6 @@
"dependencies": { "dependencies": {
"@jxpeng98/martian": "^1.2.7", "@jxpeng98/martian": "^1.2.7",
"https-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.2",
"node-fetch": "^3.3.2",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"yaml": "^2.3.4", "yaml": "^2.3.4",
"yaml-front-matter": "^4.1.1" "yaml-front-matter": "^4.1.1"

View File

@@ -8,10 +8,42 @@ export const I18n: {[key: string]:any} = {
ja, ja,
}; };
export const I18nConfig = (lang: string): any => { class I18nManager {
return I18n[lang]; private currentLanguage: string;
};
const storedLanguage = window.localStorage.getItem("language"); constructor() {
this.currentLanguage = this.detectLanguage();
}
export const i18nConfig = I18n[storedLanguage || window.navigator.language.split('-')[0] || "en"]; // return the language to use
private detectLanguage(): string {
const storedLanguage = window.localStorage.getItem("language");
if (storedLanguage && this.isLanguageSupported(storedLanguage)) {
console.log(`Using stored language: ${storedLanguage}`);
return storedLanguage;
}
const browserLanguage = window.navigator.language.split("-")[0];
if (this.isLanguageSupported(browserLanguage)) {
console.log(`Using browser language: ${browserLanguage}`);
return browserLanguage;
}
// Default to English if no match is found
console.log("Using default language: en");
return "en";
}
private isLanguageSupported(lang: string): boolean {
return Object.prototype.hasOwnProperty.call(I18n, lang);
}
// Get the i18n configuration for the current language
public getConfig(): any {
return I18n[this.currentLanguage];
}
}
export const i18nManager = new I18nManager();
export const i18nConfig = i18nManager.getConfig();

View File

@@ -20,7 +20,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
addIcons(); addIcons();
// This creates an icon in the left ribbon. // This creates an icon in the left ribbon.
const ribbonIconEl = this.addRibbonIcon( this.addRibbonIcon(
"notion-logo", "notion-logo",
i18nConfig.ribbonIcon, i18nConfig.ribbonIcon,
async (evt: MouseEvent) => { async (evt: MouseEvent) => {

View File

@@ -50,8 +50,10 @@ export async function uploadCommandNext(
const {response} = res; const {response} = res;
if (response.status === 200) { if (response.status === 200) {
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green"; new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
console.log(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`);
} else { } else {
new Notice(`${i18nConfig["sync-fail"]} ${basename}`, 5000); new Notice(`${i18nConfig["sync-fail"]} ${basename}`, 5000);
console.log(`${i18nConfig["sync-fail"]} ${basename}`);
} }
} }
@@ -88,8 +90,10 @@ export async function uploadCommandGeneral(
const {response} = res; const {response} = res;
if (response.status === 200) { if (response.status === 200) {
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green"; new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
console.log(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`);
} else { } else {
new Notice(`${i18nConfig["sync-fail"]} ${basename}`, 5000); new Notice(`${i18nConfig["sync-fail"]} ${basename}`, 5000);
console.log(`${i18nConfig["sync-fail"]} ${basename}`);
} }
} }
@@ -124,10 +128,13 @@ export async function uploadCommandCustom(
const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app); const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app);
const {response} = res; const {response} = res;
if (response.status === 200) { if (response.status === 200) {
new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green"; new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
console.log(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`);
} else { } else {
new Notice(`${i18nConfig["sync-fail"]} ${basename}`, 5000); new Notice(`${i18nConfig["sync-fail"]} ${basename}`, 5000);
console.log(`${i18nConfig["sync-fail"]} ${basename}`);
} }
} }

View File

@@ -1,11 +1,10 @@
import {App, Notice, TFile, Platform, requestUrl} from "obsidian"; import {App, Notice, TFile, requestUrl} from "obsidian";
import {markdownToBlocks} from "@jxpeng98/martian"; import {markdownToBlocks} from "@jxpeng98/martian";
import * as yamlFrontMatter from "yaml-front-matter"; import * as yamlFrontMatter from "yaml-front-matter";
import MyPlugin from "src/main"; import MyPlugin from "src/main";
import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs";
import {UploadBaseGeneral} from "./BaseUpload2NotionGeneral"; import {UploadBaseGeneral} from "./BaseUpload2NotionGeneral";
import {updateYamlInfo} from "../updateYaml"; import {updateYamlInfo} from "../updateYaml";
import fetch from 'node-fetch';
import {i18nConfig} from "../../lang/I18n"; import {i18nConfig} from "../../lang/I18n";
interface CreatePageResponse { interface CreatePageResponse {
@@ -142,81 +141,67 @@ export class Upload2NotionGeneral extends UploadBaseGeneral {
} }
console.log(bodyString) console.log(bodyString)
console.log(Platform.isDesktopApp)
let response: any; let response: any;
let data: any; let data: any;
if (Platform.isMobileApp) { response = await requestUrl({
if(childArrLength > 100) { url: `https://api.notion.com/v1/pages`,
new Notice(i18nConfig["reach-mobile-limit"], 5000); method: "POST",
} else { headers: {
response = await requestUrl({ "Content-Type": "application/json",
url: `https://api.notion.com/v1/pages`, // 'User-Agent': 'obsidian.md',
method: "POST", Authorization:
"Bearer " + notionAPI,
"Notion-Version": "2022-06-28",
},
body: JSON.stringify(bodyString),
throw: false
});
data = await response.json;
// console.log(data)
// console.log(response.status)
if (response.status !== 200) {
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 requestUrl({
url: `https://api.notion.com/v1/blocks/${data.id}/children`,
method: "PATCH",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
// 'User-Agent': 'obsidian.md', "Authorization": "Bearer " + notionAPI,
Authorization:
"Bearer " + notionAPI,
"Notion-Version": "2022-06-28", "Notion-Version": "2022-06-28",
}, },
body: JSON.stringify(bodyString), body: JSON.stringify(extraBlocks),
}); });
}
}
if (Platform.isDesktopApp) { const extraData: any = await extraResponse.json;
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 (extraResponse.status !== 200) {
new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000);
if (!response.ok) { console.log(`Error message: \n ${extraData.message}`);
new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); } else {
console.log(`Error message: \n ${data.message}`); console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`);
} else { if (i === pushCount - 1) {
console.log(`Page created: ${data.url}`); console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`);
console.log(`Page ID: ${data.id}`); new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000);
}
// 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);
}
} }
} }
} }
@@ -266,30 +251,17 @@ export class Upload2NotionGeneral extends UploadBaseGeneral {
let {response, data} = res; let {response, data} = res;
if (Platform.isDesktopApp) { // console.log(response)
if (response && response.status === 200) {
await updateYamlInfo(
markdown,
nowFile,
data,
app,
this.plugin,
this.dbDetails
);
}
}
if (Platform.isMobileApp) { if (response && response.status === 200) {
if (response && response.status === 200) { await updateYamlInfo(
await updateYamlInfo( markdown,
markdown, nowFile,
nowFile, data,
response, app,
app, this.plugin,
this.plugin, this.dbDetails,
this.dbDetails, );
);
}
} }
return res; return res;

View File

@@ -1,12 +1,11 @@
import {UploadBaseNext} from "./BaseUpload2NotionNext"; import {UploadBaseNext} from "./BaseUpload2NotionNext";
import {App, Notice, TFile, Platform, requestUrl} from "obsidian"; import {App, Notice, TFile, requestUrl} from "obsidian";
import {markdownToBlocks} from "@jxpeng98/martian"; import {markdownToBlocks} from "@jxpeng98/martian";
import * as yamlFrontMatter from "yaml-front-matter"; import * as yamlFrontMatter from "yaml-front-matter";
import MyPlugin from "src/main"; import MyPlugin from "src/main";
import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs";
import {updateYamlInfo} from "../updateYaml"; import {updateYamlInfo} from "../updateYaml";
import {LIMITS, paragraph} from "@jxpeng98/martian/src/notion"; import {LIMITS, paragraph} from "@jxpeng98/martian/src/notion";
import fetch from 'node-fetch';
import {i18nConfig} from "../../lang/I18n"; import {i18nConfig} from "../../lang/I18n";
interface CreatePageResponse { interface CreatePageResponse {
@@ -247,76 +246,63 @@ export class Upload2NotionNext extends UploadBaseNext {
let response: any; let response: any;
let data: any; let data: any;
if (Platform.isMobileApp) { response = await requestUrl({
if(childArrLength > 100) { url: `https://api.notion.com/v1/pages`,
new Notice(i18nConfig["reach-mobile-limit"], 5000); method: "POST",
} else { headers: {
response = await requestUrl({ "Content-Type": "application/json",
url: `https://api.notion.com/v1/pages`, // 'User-Agent': 'obsidian.md',
method: "POST", Authorization:
"Bearer " + notionAPI,
"Notion-Version": "2022-06-28",
},
body: JSON.stringify(bodyString),
throw: false
});
data = await response.json;
// console.log(data)
// console.log(response.status)
if (response.status !== 200) {
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 requestUrl({
url: `https://api.notion.com/v1/blocks/${data.id}/children`,
method: "PATCH",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
// 'User-Agent': 'obsidian.md', "Authorization": "Bearer " + notionAPI,
Authorization:
"Bearer " + notionAPI,
"Notion-Version": "2022-06-28", "Notion-Version": "2022-06-28",
}, },
body: JSON.stringify(bodyString), body: JSON.stringify(extraBlocks),
}); });
}
}
if (Platform.isDesktopApp) { const extraData: any = await extraResponse.json;
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 (extraResponse.status !== 200) {
new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000);
if (!response.ok) { console.log(`Error message: \n ${extraData.message}`);
new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); } else {
console.log(`Error message: \n ${data.message}`); console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`);
} else { if (i === pushCount - 1) {
console.log(`Page created: ${data.url}`); console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`);
console.log(`Page ID: ${data.id}`); new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000);
}
// 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);
}
} }
} }
} }
@@ -416,30 +402,17 @@ export class Upload2NotionNext extends UploadBaseNext {
let {response, data} = res; let {response, data} = res;
if (Platform.isDesktopApp) { // console.log(response)
if (response && response.status === 200) {
await updateYamlInfo(
markdown,
nowFile,
data,
app,
this.plugin,
this.dbDetails
);
}
}
if (Platform.isMobileApp) { if (response && response.status === 200) {
if (response && response.status === 200) { await updateYamlInfo(
await updateYamlInfo( markdown,
markdown, nowFile,
nowFile, data,
response, app,
app, this.plugin,
this.plugin, this.dbDetails,
this.dbDetails, );
);
}
} }
return res; return res;

View File

@@ -1,11 +1,10 @@
import {App, Notice, Platform, TFile, requestUrl} from "obsidian"; import {App, Notice, TFile, requestUrl} from "obsidian";
import {markdownToBlocks} from "@jxpeng98/martian"; import {markdownToBlocks} from "@jxpeng98/martian";
import * as yamlFrontMatter from "yaml-front-matter"; import * as yamlFrontMatter from "yaml-front-matter";
import MyPlugin from "src/main"; import MyPlugin from "src/main";
import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs"; import {DatabaseDetails, PluginSettings} from "../../ui/settingTabs";
import {updateYamlInfo} from "../updateYaml"; import {updateYamlInfo} from "../updateYaml";
import {UploadBaseCustom} from "./BaseUpload2NotionCustom"; import {UploadBaseCustom} from "./BaseUpload2NotionCustom";
import fetch from 'node-fetch';
import {i18nConfig} from "../../lang/I18n"; import {i18nConfig} from "../../lang/I18n";
@@ -60,15 +59,15 @@ export class Upload2NotionCustom extends UploadBaseCustom {
// remove the annotations from the childArr if type is code block // remove the annotations from the childArr if type is code block
childArr.forEach((block: any) => { childArr.forEach((block: any) => {
if (block.type === "code") { if (block.type === "code") {
block.code.rich_text.forEach((item: any) => { block.code.rich_text.forEach((item: any) => {
if (item.type === "text" && item.annotations) { if (item.type === "text" && item.annotations) {
delete item.annotations; delete item.annotations;
}
} }
} );
); }
} }
}
); );
// check the length of the childArr and split it into chunks of 100 // check the length of the childArr and split it into chunks of 100
@@ -114,81 +113,67 @@ export class Upload2NotionCustom extends UploadBaseCustom {
} }
console.log(bodyString) console.log(bodyString)
console.log(Platform.isDesktopApp)
let response: any; let response: any;
let data: any; let data: any;
if (Platform.isMobileApp) { response = await requestUrl({
if(childArrLength > 100) { url: `https://api.notion.com/v1/pages`,
new Notice(i18nConfig["reach-mobile-limit"], 5000); method: "POST",
} else { headers: {
response = await requestUrl({ "Content-Type": "application/json",
url: `https://api.notion.com/v1/pages`, // 'User-Agent': 'obsidian.md',
method: "POST", Authorization:
"Bearer " + notionAPI,
"Notion-Version": "2022-06-28",
},
body: JSON.stringify(bodyString),
throw: false
});
data = await response.json;
// console.log(data)
// console.log(response.status)
if (response.status !== 200) {
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 requestUrl({
url: `https://api.notion.com/v1/blocks/${data.id}/children`,
method: "PATCH",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
// 'User-Agent': 'obsidian.md', "Authorization": "Bearer " + notionAPI,
Authorization:
"Bearer " + notionAPI,
"Notion-Version": "2022-06-28", "Notion-Version": "2022-06-28",
}, },
body: JSON.stringify(bodyString), body: JSON.stringify(extraBlocks),
}); });
}
}
if (Platform.isDesktopApp) { const extraData: any = await extraResponse.json;
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 (extraResponse.status !== 200) {
new Notice(`Error ${extraData.status}: ${extraData.code} \n ${i18nConfig["CheckConsole"]}`, 5000);
if (!response.ok) { console.log(`Error message: \n ${extraData.message}`);
new Notice(`Error ${data.status}: ${data.code} \n ${i18nConfig["CheckConsole"]}`, 5000); } else {
console.log(`Error message: \n ${data.message}`); console.log(`${i18nConfig["ExtraBlockUploaded"]} to page: ${data.id}`);
} else { if (i === pushCount - 1) {
console.log(`Page created: ${data.url}`); console.log(`${i18nConfig["BlockUploaded"]} to page: ${data.id}`);
console.log(`Page ID: ${data.id}`); new Notice(`${i18nConfig["BlockUploaded"]} page: ${data.id}`, 5000);
}
// 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);
}
} }
} }
} }
@@ -238,30 +223,15 @@ export class Upload2NotionCustom extends UploadBaseCustom {
// console.log(response) // console.log(response)
if (Platform.isDesktopApp) { if (response && response.status === 200) {
if (response && response.status === 200) { await updateYamlInfo(
await updateYamlInfo( markdown,
markdown, nowFile,
nowFile, data,
data, app,
app, this.plugin,
this.plugin, this.dbDetails,
this.dbDetails );
);
}
}
if (Platform.isMobileApp) {
if (response && response.status === 200) {
await updateYamlInfo(
markdown,
nowFile,
response,
app,
this.plugin,
this.dbDetails,
);
}
} }
return res; return res;

View File

@@ -35,7 +35,10 @@ export async function getNowFileMarkdownContentCustom(
// If a 'title' type property exists, use the file's basename as its value // If a 'title' type property exists, use the file's basename as its value
if (titleProperty) { if (titleProperty) {
customValues[titleProperty.customName] = nowFile.basename; // Use 'basename' for the file name without extension customValues[titleProperty.customName] =
(FileCache.frontmatter && FileCache.frontmatter[titleProperty.customName]) ?
FileCache.frontmatter[titleProperty.customName] : // use the front matter value if it exists
nowFile.basename; // Use 'basename' for the file name without extension
} }
} catch (error) { } catch (error) {

View File

@@ -460,13 +460,12 @@ commander@^8.3.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
cors@^2.8.5: cross-fetch@^4.0.0:
version "2.8.5" version "4.0.0"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-4.0.0.tgz#f037aef1580bb3a1a35164ea2a848ba81b445983"
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==
dependencies: dependencies:
object-assign "^4" node-fetch "^2.6.12"
vary "^1"
data-uri-to-buffer@^4.0.0: data-uri-to-buffer@^4.0.0:
version "4.0.1" version "4.0.1"
@@ -722,11 +721,6 @@ katex@^0.16.0:
dependencies: dependencies:
commander "^8.3.0" 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: longest-streak@^2.0.0:
version "2.0.4" version "2.0.4"
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4" resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4"
@@ -1212,7 +1206,7 @@ node-domexception@^1.0.0:
resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5"
integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==
node-fetch@^2.6.1: node-fetch@^2.6.1, node-fetch@^2.6.12:
version "2.7.0" version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
@@ -1228,11 +1222,6 @@ node-fetch@^3.3.2:
fetch-blob "^3.1.4" fetch-blob "^3.1.4"
formdata-polyfill "^4.0.10" 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: obsidian@^1.6.6:
version "1.6.6" version "1.6.6"
resolved "https://registry.yarnpkg.com/obsidian/-/obsidian-1.6.6.tgz#d45c4021c291765e1b77ed4a1c645e562ff6e77f" resolved "https://registry.yarnpkg.com/obsidian/-/obsidian-1.6.6.tgz#d45c4021c291765e1b77ed4a1c645e562ff6e77f"
@@ -1459,11 +1448,6 @@ unist-util-visit@^5.0.0:
unist-util-is "^6.0.0" unist-util-is "^6.0.0"
unist-util-visit-parents "^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: vfile-message@^2.0.0:
version "2.0.4" version "2.0.4"
resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-2.0.4.tgz#5b43b88171d409eae58477d13f23dd41d52c371a" resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-2.0.4.tgz#5b43b88171d409eae58477d13f23dd41d52c371a"