Merge pull request #26 from jxpeng98/notice-info

change the success notice colour
This commit is contained in:
Jiaxin Peng
2024-07-15 14:17:01 +01:00
committed by GitHub
7 changed files with 24 additions and 25 deletions

View File

@@ -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**. 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. 2). Create a database in your Notion workspace.

View File

@@ -27,11 +27,11 @@ export const en = {
DatabaseIDText: "Enter your Database ID", DatabaseIDText: "Enter your Database ID",
BannerUrl: "Banner url (optional)", BannerUrl: "Banner url (optional)",
BannerUrlDesc: 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", BannerUrlText: "Enter your banner url",
NotionUser: "Notion ID (username, optional)", NotionUser: "Notion ID (username, optional)",
NotionUserDesc: 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", NotionUserText: "Enter your notion ID",
NotionLinkDisplay: "Notion Link Display", NotionLinkDisplay: "Notion Link Display",
NotionLinkDisplayDesc: "Default is ON, if you want to hide the link in the front matter, please turn it off", 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", NotionCustomValues: "Customise values property",
NotionCustomValuesDesc: "Modify the column name of the Notion databaseone per line", NotionCustomValuesDesc: "Modify the column name of the Notion databaseone per line",
NotionCustomValuesText: "Enter all properties that you want to sync", NotionCustomValuesText: "Enter all properties that you want to sync",
NotYetFinish: NotYetFinish: "Not finished. This function will be available in the next version",
"Not finished. This function will be available in the next version",
PlaceHolder: "Enter database Name", PlaceHolder: "Enter database Name",
"notion-logo": "Share to NotionNext", "notion-logo": "Share to NotionNext",
"sync-success": "Sync to NotionNext success: \n", "sync-preffix": "Sync to ",
"sync-fail": "Sync to NotionNext fail: \n", "sync-success": "success",
"sync-fail": "failed",
"open-notion": "Please open the file that needs to be synchronized", "open-notion": "Please open the file that needs to be synchronized",
"config-secrets-notion-api": "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": "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":
"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: 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": "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", NotionCustomSettingHeader: "Notion Custom Database Settings",
NotionCustomButton: "Notion Customised command switch", NotionCustomButton: "Notion Customised command switch",
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette", 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", AddCustomProperty: "Add Custom Property",
AddNewProperty: "Add New Property", AddNewProperty: "Add New Property",
AddNewPropertyDesc: "Add new property match with your notion database", AddNewPropertyDesc: "Add new property match with your notion database",
CopyErrorMessage: "Auto copy failed, please copy it manually",
} }

View File

@@ -67,4 +67,5 @@ export const ja = {
AddCustomProperty: "カスタムプロパティを追加", AddCustomProperty: "カスタムプロパティを追加",
AddNewProperty: "新しいプロパティを追加", AddNewProperty: "新しいプロパティを追加",
AddNewPropertyDesc: "新しいプロパティを追加してください", AddNewPropertyDesc: "新しいプロパティを追加してください",
CopyErrorMessage: "自動コピーに失敗しました",
}; };

View File

@@ -70,4 +70,5 @@ export const zh = {
AddCustomProperty: "添加自定义属性", AddCustomProperty: "添加自定义属性",
AddNewProperty: "添加新属性", AddNewProperty: "添加新属性",
AddNewPropertyDesc: "添加一个和Notion数据库匹配的新属性", AddNewPropertyDesc: "添加一个和Notion数据库匹配的新属性",
CopyErrorMessage: "复制链接失败,请手动复制",
} }

View File

@@ -1,6 +1,7 @@
import { App, Notice, TFile } from "obsidian"; import { App, Notice, TFile } from "obsidian";
import ObsidianSyncNotionPlugin from "../main"; import ObsidianSyncNotionPlugin from "../main";
import { DatabaseDetails } from "../ui/settingTabs"; import { DatabaseDetails } from "../ui/settingTabs";
import { i18nConfig } from "src/lang/I18n";
export async function updateYamlInfo( export async function updateYamlInfo(
yamlContent: string, yamlContent: string,
@@ -37,6 +38,7 @@ export async function updateYamlInfo(
try { try {
await navigator.clipboard.writeText(url) await navigator.clipboard.writeText(url)
} catch (error) { } catch (error) {
new Notice(`复制链接失败,请手动复制${error}`) console.log(error)
new Notice(`${i18nConfig.CopyErrorMessage}`);
} }
} }

View File

@@ -18,13 +18,6 @@ export async function uploadCommandNext(
const { notionAPI, databaseID } = dbDetails; 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 // Check if the user has set up the Notion API and database ID
if (notionAPI === "" || databaseID === "") { if (notionAPI === "" || databaseID === "") {
const setAPIMessage = i18nConfig["set-api-id"]; const setAPIMessage = i18nConfig["set-api-id"];
@@ -54,7 +47,7 @@ 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); 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) { if (res.status === 200) {
new Notice(`${i18nConfig["sync-success"]}${basename}`); new Notice(`${i18nConfig["sync-preffix"]} ${basename} ${i18nConfig["sync-success"]}`).noticeEl.style.color = "green";
} else { } else {
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
} }
@@ -88,7 +81,7 @@ export async function uploadCommandGeneral(
const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app); const res = await upload.syncMarkdownToNotionGeneral(basename, cover, tags, markDownData, nowFile, this.app);
if (res.status === 200) { if (res.status === 200) {
new Notice(`${i18nConfig["sync-success"]}${basename}`); new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green";
} else { } else {
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); 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); const res = await upload.syncMarkdownToNotionCustom(cover, customValues, markDownData, nowFile, this.app);
if (res.status === 200) { if (res.status === 200) {
new Notice(`${i18nConfig["sync-success"]}${basename}`); new Notice(`${i18nConfig["sync-success"]}${basename}`).noticeEl.style.color = "green";
} else { } else {
new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000); new Notice(`${i18nConfig["sync-fail"]}${basename}`, 5000);
} }

View File

@@ -99,6 +99,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
app: App, app: App,
): Promise<any> { ): Promise<any> {
const options = { const options = {
strictImageUrls: true,
notionLimits: { notionLimits: {
truncate: false, truncate: false,
} }
@@ -123,7 +124,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
} else { } else {
res = await this.createPage(cover, customValues, file2Block); 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); await updateYamlInfo(markdown, nowFile, res, app, this.plugin, this.dbDetails);
} else { } else {
new Notice(`${res.text}`); new Notice(`${res.text}`);
@@ -228,7 +229,7 @@ export class Upload2NotionCustom extends UploadBaseCustom {
} }
); );
console.log(properties) // console.log(properties)
return { return {
parent: { parent: {