From 201f72ae0ee024494edcf8b6da9d5cb210ce40d4 Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Sun, 14 Jul 2024 11:28:34 +0100 Subject: [PATCH 1/3] update notice --- src/lang/locale/en.ts | 23 ++++++++++--------- src/lang/locale/ja.ts | 1 + src/lang/locale/zh.ts | 1 + src/upload/updateYaml.ts | 4 +++- src/upload/uploadCommand.ts | 6 ++--- .../upoload_custom/Upload2NotionCustom.ts | 5 ++-- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index cbba596..2a7250a 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -27,11 +27,11 @@ export const en = { DatabaseIDText: "Enter your Database ID", BannerUrl: "Banner url (optional)", BannerUrlDesc: -"Default is empty, if you want to show a banner, please enter the url (like: https://abc.com/b.png)", + "Default is empty, if you want to show a banner, please enter the url (like: https://abc.com/b.png)", BannerUrlText: "Enter your banner url", NotionUser: "Notion ID (username, optional)", NotionUserDesc: -"Collect from share link likes:https://username.notion.site. Your notion id is [username]", + "Collect from share link likes:https://username.notion.site. Your notion id is [username]", NotionUserText: "Enter your notion ID", NotionLinkDisplay: "Notion Link Display", NotionLinkDisplayDesc: "Default is ON, if you want to hide the link in the front matter, please turn it off", @@ -48,23 +48,23 @@ export const en = { NotionCustomValues: "Customise values property", NotionCustomValuesDesc: "Modify the column name of the Notion database,one per line", NotionCustomValuesText: "Enter all properties that you want to sync", - NotYetFinish: -"Not finished. This function will be available in the next version", + NotYetFinish: "Not finished. This function will be available in the next version", PlaceHolder: "Enter database Name", "notion-logo": "Share to NotionNext", - "sync-success": "Sync to NotionNext success: \n", - "sync-fail": "Sync to NotionNext fail: \n", + "sync-preffix": "Sync to ", + "sync-success": "success", + "sync-fail": "failed", "open-notion": "Please open the file that needs to be synchronized", "config-secrets-notion-api": -"Please set up the notion API in the settings tab.", + "Please set up the notion API in the settings tab.", "config-secrets-database-id": -"Please set up the database id in the settings tab.", + "Please set up the database id in the settings tab.", "set-tags-fail": -"Set tags fail,please check the frontmatter of the file or close the tag switch in the settings tab.", + "Set tags fail,please check the frontmatter of the file or close the tag switch in the settings tab.", NNonMissing: -"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": -"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", NotionCustomButton: "Notion Customised command switch", NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette", @@ -75,4 +75,5 @@ export const en = { AddCustomProperty: "Add Custom Property", AddNewProperty: "Add New Property", AddNewPropertyDesc: "Add new property match with your notion database", + CopyErrorMessage: "Auto copy failed, please copy it manually", } diff --git a/src/lang/locale/ja.ts b/src/lang/locale/ja.ts index 0221025..25f10f2 100644 --- a/src/lang/locale/ja.ts +++ b/src/lang/locale/ja.ts @@ -67,4 +67,5 @@ export const ja = { AddCustomProperty: "カスタムプロパティを追加", AddNewProperty: "新しいプロパティを追加", AddNewPropertyDesc: "新しいプロパティを追加してください", + CopyErrorMessage: "自動コピーに失敗しました", }; diff --git a/src/lang/locale/zh.ts b/src/lang/locale/zh.ts index 08a9375..0ae609f 100644 --- a/src/lang/locale/zh.ts +++ b/src/lang/locale/zh.ts @@ -70,4 +70,5 @@ export const zh = { AddCustomProperty: "添加自定义属性", AddNewProperty: "添加新属性", AddNewPropertyDesc: "添加一个和Notion数据库匹配的新属性", + CopyErrorMessage: "复制链接失败,请手动复制", } diff --git a/src/upload/updateYaml.ts b/src/upload/updateYaml.ts index d479015..9772adb 100644 --- a/src/upload/updateYaml.ts +++ b/src/upload/updateYaml.ts @@ -1,6 +1,7 @@ import { App, Notice, TFile } from "obsidian"; import ObsidianSyncNotionPlugin from "../main"; import { DatabaseDetails } from "../ui/settingTabs"; +import { i18nConfig } from "src/lang/I18n"; export async function updateYamlInfo( yamlContent: string, @@ -37,6 +38,7 @@ export async function updateYamlInfo( try { await navigator.clipboard.writeText(url) } catch (error) { - new Notice(`复制链接失败,请手动复制${error}`) + console.log(error) + new Notice(`${i18nConfig.CopyErrorMessage}`); } } diff --git a/src/upload/uploadCommand.ts b/src/upload/uploadCommand.ts index 9f9bc3b..1194b96 100644 --- a/src/upload/uploadCommand.ts +++ b/src/upload/uploadCommand.ts @@ -54,9 +54,9 @@ export async function uploadCommandNext( const res = await upload.syncMarkdownToNotionNext(basename, emoji, cover, tags, type, slug, stats, category, summary, paword, favicon, datetime, markDownData, nowFile, this.app); if (res.status === 200) { - new Notice(`${i18nConfig["sync-success"]}${basename}`); + new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green"; } else { - new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); + new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000).noticeEl.style.color = "red"; } } @@ -88,7 +88,7 @@ export async function uploadCommandGeneral( const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app); if (res.status === 200) { - new Notice(`${i18nConfig["sync-success"]}${basename}`); + new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green"; } else { new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); } diff --git a/src/upload/upoload_custom/Upload2NotionCustom.ts b/src/upload/upoload_custom/Upload2NotionCustom.ts index da03bf9..9cdd115 100644 --- a/src/upload/upoload_custom/Upload2NotionCustom.ts +++ b/src/upload/upoload_custom/Upload2NotionCustom.ts @@ -99,6 +99,7 @@ export class Upload2NotionCustom extends UploadBaseCustom { app: App, ): Promise { const options = { + strictImageUrls: true, notionLimits: { truncate: false, } @@ -123,7 +124,7 @@ export class Upload2NotionCustom extends UploadBaseCustom { } else { res = await this.createPage(cover, customValues, file2Block); } - if (res.status === 200) { + if (res && res.status === 200) { await updateYamlInfo(markdown, nowFile, res, app, this.plugin, this.dbDetails); } else { new Notice(`${res.text}`); @@ -228,7 +229,7 @@ export class Upload2NotionCustom extends UploadBaseCustom { } ); - console.log(properties) + // console.log(properties) return { parent: { From bb522db9a24668f420f0d014b848f5337d8381fc Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Mon, 15 Jul 2024 14:13:09 +0100 Subject: [PATCH 2/3] fix: readme gif link update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5581cbf..ccaf3ef 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ If you want to use this plugin, you need to follow the following steps to set up 1). Go to [Notion API](https://www.notion.com/my-integrations) to create a new integration, and **copy the token**. -![create-api](https://minioapi.pjx.ac.cn/img1/2024/07/4ffbcb9c531e889f35151333913beec7.gif) +![create-api](https://minioapi.pjx.ac.cn/img1/2024/07/28526e416571f8b1fe70d90bd9975b81.gif) 2). Create a database in your Notion workspace. From 3a814b83908d8389dd0ce6c135710b04738ff93c Mon Sep 17 00:00:00 2001 From: Jiaxin Peng Date: Mon, 15 Jul 2024 14:15:10 +0100 Subject: [PATCH 3/3] feat: change the success notice colour --- src/upload/uploadCommand.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/upload/uploadCommand.ts b/src/upload/uploadCommand.ts index 1194b96..35f28da 100644 --- a/src/upload/uploadCommand.ts +++ b/src/upload/uploadCommand.ts @@ -18,13 +18,6 @@ export async function uploadCommandNext( const { notionAPI, databaseID } = dbDetails; - // 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"]; @@ -56,7 +49,7 @@ export async function uploadCommandNext( if (res.status === 200) { new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green"; } else { - new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000).noticeEl.style.color = "red"; + new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); } } @@ -122,7 +115,7 @@ export async function uploadCommandCustom( const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app); if (res.status === 200) { - new Notice(`${i18nConfig["sync-success"]}${basename}`); + new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green"; } else { new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); }