Compare commits

...

15 Commits

Author SHA1 Message Date
Jiaxin Peng
90dcc1aef0 chore: release v2.8.0-beta.3 2025-12-10 23:15:18 +00:00
Jiaxin Peng
7053a74e24 feat: Add 'sync-preffix' translation key to multiple locales. 2025-12-10 23:05:07 +00:00
Jiaxin Peng
5144f10e77 feat: Add auto-copy Notion link setting 2025-12-10 23:04:58 +00:00
Jiaxin Peng
5806a2831b fix: remove unnecessary resetAutoSyncNoticeCache call when autoSyncFrontmatterKey changes 2025-12-10 22:51:08 +00:00
Jiaxin Peng
eeaf7c036d feat: Enable first-time auto-upload for new documents with autosync-database key and refine auto-sync notice logic. 2025-12-10 21:51:04 +00:00
Jiaxin Peng
3de92d3f54 feat: Enable first-time auto-upload for new documents and update documentation. 2025-12-10 21:32:25 +00:00
Jiaxin Peng
e6b13e5eee feat: auto copy after upload 2025-12-10 21:32:06 +00:00
Jiaxin Peng
f4def623bb styles: improve the translation 2025-12-10 21:30:49 +00:00
Jiaxin Peng
3620505b56 update beta version 2.8.0-beta.2 2025-11-06 16:51:42 +00:00
Jiaxin Peng
e9355aaf92 docs: enhance auto sync documentation with frontmatter key configuration and examples 2025-11-06 16:50:50 +00:00
Jiaxin Peng
943ec6af6d Merge pull request #68 from jxpeng98/autosync-filter
Autosync filter
2025-11-06 16:44:58 +00:00
Jiaxin Peng
bb4b75c82e feat: add auto sync frontmatter key configuration and update related messages 2025-11-06 16:43:24 +00:00
Jiaxin Peng
ae4488546c feat: add auto sync database list handling and notifications for missing entries 2025-11-06 16:27:24 +00:00
Jiaxin Peng
7661bc94c7 fix: update changelog to reflect version v2.8.0-beta.1 release 2025-11-01 00:44:35 +00:00
Jiaxin Peng
e8a9594ea1 fix: refine tag patterns for release triggers in workflow 2025-11-01 00:42:01 +00:00
13 changed files with 635 additions and 256 deletions

View File

@@ -2,8 +2,11 @@ name: Release
on: on:
push: push:
branches:
- main
tags: tags:
- "*" - "v*.*.*"
- "[0-9]+.[0-9]+.[0-9]+"
env: env:
PLUGIN_NAME: share-to-notionnext # Change this to match the id of your plugin. PLUGIN_NAME: share-to-notionnext # Change this to match the id of your plugin.

View File

@@ -1,6 +1,32 @@
# Changelog # Changelog
## [Unreleased] ## v2.8.0-beta.3 (2025-12-10)
### Added
- **Auto-copy Notion Link setting**: New toggle to automatically copy the Notion page link to clipboard after syncing (defaults to on)
- **Smart auto-sync notice**: Show notice only for files that were previously synced but missing `autosync-database` field; new files are silently skipped
### Fixed
- Fixed `undefined` appearing in sync success notification by adding missing `sync-preffix` i18n key
- Fixed build error caused by removed `resetAutoSyncNoticeCache()` method reference
- Added `autoCopyNotionLink` to settings migration logic for seamless upgrades
### Changed
- Improved auto-sync behavior: files without `autosync-database` are now silently ignored unless they have an existing NotionID
- Updated documentation with new auto-sync scenarios (A-1 and A-2)
---
## v2.8.0-beta.2 (2025-11-05)
### Featured
- Added setting to customise the frontmatter key used for auto sync database lists (defaults to `autosync-database`)
## v2.8.0-beta.1 (2025-10-31)
### Added ### Added
@@ -12,6 +38,7 @@
- Works on both desktop and mobile platforms - Works on both desktop and mobile platforms
- Added comprehensive i18n support for all UI elements and notifications - Added comprehensive i18n support for all UI elements and notifications
- Added prerelease workflow for beta testing via GitHub Actions and BRAT - Added prerelease workflow for beta testing via GitHub Actions and BRAT
- Added setting to customise the frontmatter key used for auto sync database lists (defaults to `autosync-database`)
### Changed ### Changed

View File

@@ -22,6 +22,21 @@ In the plugin settings, you can add and configure the Notion databases you want
- [3⃣ Custom Database](#3⃣-custom-database) - [3⃣ Custom Database](#3⃣-custom-database)
- [Finalizing Configuration](#finalizing-configuration) - [Finalizing Configuration](#finalizing-configuration)
## Auto Sync Frontmatter Entry
If you enable auto sync, the plugin needs a frontmatter entry that lists which configured databases should receive updates. You can customise the name of this entry in **Settings → Auto Sync Frontmatter Key** (default: `autosync-database`). Use any text you like—letters, numbers, emojis, or other scripts are all supported.
In your note's frontmatter, add the configured key and list the database abbreviations you created in the settings:
```yaml
---
title: My Article
autosync-database: [blog, ideas]
---
```
The entry can be a YAML list or comma-separated string, and manual uploads will automatically add the current database abbreviation if it is missing. If you change the key name in settings, update your frontmatter to match the new value.
## 1⃣ General Database ## 1⃣ General Database
This is the most basic database type and is suitable for most users. This is the most basic database type and is suitable for most users.

View File

@@ -22,17 +22,38 @@ The plugin supports automatic syncing that monitors your notes for changes and a
3. Enable the toggle 3. Enable the toggle
4. Configure the "Auto Sync Delay" (default: 5 seconds, minimum: 2 seconds) 4. Configure the "Auto Sync Delay" (default: 5 seconds, minimum: 2 seconds)
### Prepare the Frontmatter
Auto sync reads the database list from the frontmatter key you configured in **Settings → Auto Sync Frontmatter Key** (default: `autosync-database`). To make sure your notes can sync automatically:
- Add the configured key to your note's frontmatter
- List one or more database abbreviations that you defined in the plugin settings
- Keep the list updated if you change the databases a note should sync to
Example with the default key:
```yaml
---
title: My Article
autosync-database: [blog, portfolio]
---
```
If you change the key name in the settings, update your frontmatter to match.
### How Auto Sync Works ### How Auto Sync Works
When auto sync is enabled: When auto sync is enabled:
- The plugin monitors markdown files for changes - The plugin monitors markdown files for changes
- After you stop editing for the configured delay period, auto sync is triggered - After you stop editing for the configured delay period, auto sync is triggered
- Only files that have already been synced to Notion (have a NotionID in frontmatter) will be auto-synced - Files with the `autosync-database` key in frontmatter will be automatically synced
- **First-time upload is supported**: No need to manually sync first - just add the frontmatter key and the plugin will handle the initial upload
- If a file is linked to multiple databases, it will sync to all of them automatically - If a file is linked to multiple databases, it will sync to all of them automatically
- After the first sync, a `NotionID-{database}` will be added to the frontmatter for future updates
### Auto Sync Scenarios ### Auto Sync Scenarios
#### Scenario A: New Document (Not Yet Synced) #### Scenario A-1: New File Missing Auto Sync Entry
```yaml ```yaml
--- ---
@@ -42,12 +63,12 @@ tags: [blog, tech]
``` ```
**Behavior:** **Behavior:**
- ✅ Detects no NotionID present - ✅ Detects that the auto sync key is missing
-Shows notice: "⚠️ Auto sync skipped: This document has not been synced to Notion, please upload manually first" -Detects no NotionID present (new file)
-No sync operation performed -Silently skips - no notice shown
- 📝 **Action Required:** Manually sync the document first using the command palette - 📝 **To enable auto sync:** Add `autosync-database: [your-db-abbreviation]` to the frontmatter
#### Scenario B: Synced to One Database #### Scenario A-2: Synced File Missing Auto Sync Entry
```yaml ```yaml
--- ---
@@ -56,13 +77,46 @@ NotionID-blog: abc123
--- ---
``` ```
**Behavior:**
- ✅ Detects that the auto sync key is missing
- ✅ Detects existing NotionID (file was synced before)
- ✅ Shows notice: "⚠️ Auto-sync skipped: Add autosync-database to your frontmatter to specify target databases"
- ✅ No sync operation performed
- 📝 **Action Required:** Add `autosync-database: [blog]` to the frontmatter
#### Scenario B: New Document (First-Time Auto Upload)
```yaml
---
title: My New Article
autosync-database: [blog]
---
```
**Behavior:**
- ✅ Detects no NotionID present but `autosync-database` is configured
- ✅ Automatically performs first-time upload to the Blog database
- ✅ Adds `NotionID-blog: xxx` to the frontmatter after successful upload
- ✅ Shows success/failure notification
- 📝 **No Action Required:** The plugin handles the initial upload automatically
#### Scenario C: Synced to One Database
```yaml
---
title: My Article
NotionID-blog: abc123
autosync-database: [blog]
---
```
**Behavior:** **Behavior:**
- ✅ Detects 1 NotionID - ✅ Detects 1 NotionID
- ✅ Automatically syncs to the Blog database - ✅ Automatically syncs to the Blog database
- ✅ Shows success/failure notification from the upload command - ✅ Shows success/failure notification from the upload command
- 📝 **No Action Required:** Changes are automatically synced - 📝 **No Action Required:** Changes are automatically synced
#### Scenario C: Synced to Multiple Databases #### Scenario D: Synced to Multiple Databases
```yaml ```yaml
--- ---
@@ -70,19 +124,35 @@ title: My Article
NotionID-blog: abc123 NotionID-blog: abc123
NotionID-portfolio: def456 NotionID-portfolio: def456
NotionID-notes: ghi789 NotionID-notes: ghi789
autosync-database: [blog, portfolio, notes]
--- ---
``` ```
**Behavior:** **Behavior:**
- ✅ Detects 3 NotionIDs - ✅ Detects 3 database targets
- ✅ Shows notice: "🔄 Auto sync: Syncing to 3 database(s)..." - ✅ Shows notice: "🔄 Auto sync: Syncing to 3 database(s)..."
- ✅ Syncs to all 3 databases sequentially - ✅ Syncs to all 3 databases sequentially
- ✅ Shows individual result notifications for each database - ✅ Shows individual result notifications for each database
- 📝 **No Action Required:** Changes are automatically synced to all linked databases - 📝 **No Action Required:** Changes are automatically synced to all linked databases
#### Scenario E: Custom Frontmatter Key
```yaml
---
title: My Article
NotionID-blog: abc123
NotionID-portfolio: def456
🚀-sync-targets: [blog, portfolio]
---
```
**Behavior:**
- ✅ Uses your custom key (for example `🚀-sync-targets`) configured in settings
- ✅ Syncs to the listed databases when NotionIDs are present
- 📝 **Remember:** Update both the setting and your frontmatter if you rename the key
### Auto Sync Best Practices ### Auto Sync Best Practices
1. **First Sync Manually**: Always perform the first sync manually to establish the NotionID link 1. **Add Frontmatter Key**: Just add `autosync-database: [your-db]` to enable auto sync - no manual upload needed
2. **Configure Delay Appropriately**: Set a longer delay (5-10 seconds) if you make frequent edits 2. **Configure Delay Appropriately**: Set a longer delay (5-10 seconds) if you make frequent edits
3. **Monitor Sync Status**: Check the notifications to ensure syncs complete successfully 3. **Monitor Sync Status**: Check the notifications to ensure syncs complete successfully
4. **Check Logs**: Open the developer console (Ctrl+Shift+I / Cmd+Option+I) to view detailed sync logs 4. **Check Logs**: Open the developer console (Ctrl+Shift+I / Cmd+Option+I) to view detailed sync logs

View File

@@ -6,3 +6,35 @@ description: Release notes and updates for Obsidian to NotionNext
# Changelog # Changelog
Welcome to the Changelog for Obsidian to NotionNext! Here you'll find a detailed list of all the updates, improvements, and bug fixes made to the plugin over time from the version `2.7.0` onwards. Welcome to the Changelog for Obsidian to NotionNext! Here you'll find a detailed list of all the updates, improvements, and bug fixes made to the plugin over time from the version `2.7.0` onwards.
## v2.8.0-beta.2 (2025-11-05)
### Featured
- Added setting to customise the frontmatter key used for auto sync database lists (defaults to `autosync-database`)
## v2.8.0-beta.1 (2025-10-31)
### Added
- **Auto Sync Feature**: Automatically sync notes to Notion when content or frontmatter changes
- Configurable delay (default: 5 seconds, minimum: 2 seconds)
- Support for multiple database syncing
- Smart detection to avoid sync loops when only NotionID is updated
- Content hash comparison to detect body text changes
- Works on both desktop and mobile platforms
- Added comprehensive i18n support for all UI elements and notifications
- Added prerelease workflow for beta testing via GitHub Actions and BRAT
### Changed
- Enhanced settings tab with auto-sync configuration options
- Improved debug logging for better troubleshooting
- Updated documentation with auto-sync usage guide and troubleshooting section
### Fixed
- Fixed mobile compatibility issues by using `window.setTimeout` instead of `NodeJS.Timeout`
- Fixed sync loop prevention logic to properly handle frontmatter and content changes
- Fixed cache update timing to ensure accurate change detection

View File

@@ -22,18 +22,38 @@ description: 如何使用 NotionNext 插件将你的 Obsidian 笔记同步到 No
3. 开启该开关 3. 开启该开关
4. 配置"自动同步延迟时间"默认5秒最小2秒 4. 配置"自动同步延迟时间"默认5秒最小2秒
### 准备 Frontmatter
自动同步会读取你在 **设置 → 自动同步 Frontmatter 键名** 中配置的键名(默认为 `autosync-database`)来确定要同步的数据库。要让你的笔记能够自动同步:
- 在笔记的 frontmatter 中添加配置的键名
- 列出一个或多个你在插件设置中定义的数据库简称
- 如果修改了笔记要同步的数据库,记得更新列表
示例(使用默认键名):
```yaml
---
title: 我的文章
autosync-database: [blog, portfolio]
---
```
如果你在设置中修改了键名,记得同时更新你的 frontmatter。
### 自动同步工作原理 ### 自动同步工作原理
当自动同步启用后: 当自动同步启用后:
- 插件会监控 Markdown 文件的变化 - 插件会监控 Markdown 文件的变化
- 在你停止编辑达到配置的延迟时间后,自动触发同步 - 在你停止编辑达到配置的延迟时间后,自动触发同步
- 只有已经同步过的文件frontmatter 中有 NotionID才会被自动同步 - **支持首次自动上传**:无需先手动同步,只要添加 frontmatter 键名,插件会自动处理首次上传
- 如果文件关联了多个数据库,会自动同步到所有数据库 - 如果文件关联了多个数据库,会自动同步到所有数据库
- 首次同步后,会自动在 frontmatter 中添加 `NotionID-{数据库}` 用于后续更新
### 自动同步场景示例 ### 自动同步场景示例
#### 场景 A新文档(未同步) #### 场景 A-1:新文件缺少自动同步配置
```yaml ```yaml
--- ---
@@ -44,12 +64,12 @@ tags: [博客, 技术]
**行为:** **行为:**
- ✅ 检测到没有 NotionID - ✅ 检测到缺少自动同步配置键
-显示提示:"⚠️ 自动同步跳过:此文档未同步到 Notion请先手动上传" -检测到没有 NotionID新文件
-不执行同步操作 -静默跳过,不显示任何提示
- 📝 **需要操作:** 先使用命令面板手动同步文档 - 📝 **如需启用自动同步:** 在 frontmatter 中添加 `autosync-database: [你的数据库简称]`
#### 场景 B:已同步到一个数据库 #### 场景 A-2:已同步文件缺少自动同步配置
```yaml ```yaml
--- ---
@@ -60,12 +80,47 @@ NotionID-blog: abc123
**行为:** **行为:**
- ✅ 检测到缺少自动同步配置键
- ✅ 检测到已存在 NotionID说明之前同步过
- ✅ 显示提示:"⚠️ 自动同步已跳过:请在 frontmatter 中添加 autosync-database 以指定目标数据库"
- ✅ 不执行同步操作
- 📝 **需要操作:** 在 frontmatter 中添加 `autosync-database: [blog]`
#### 场景 B新文档首次自动上传
```yaml
---
title: 我的新文章
autosync-database: [blog]
---
```
**行为:**
- ✅ 检测到没有 NotionID但配置了 `autosync-database`
- ✅ 自动执行首次上传到 Blog 数据库
- ✅ 上传成功后自动添加 `NotionID-blog: xxx` 到 frontmatter
- ✅ 显示成功/失败通知
- 📝 **无需操作:** 插件会自动处理首次上传
#### 场景 C已同步到一个数据库更新
```yaml
---
title: 我的文章
NotionID-blog: abc123
autosync-database: [blog]
---
```
**行为:**
- ✅ 检测到 1 个 NotionID - ✅ 检测到 1 个 NotionID
- ✅ 自动同步到 Blog 数据库 - ✅ 自动同步更新到 Blog 数据库
- ✅ 显示上传命令返回的成功/失败通知 - ✅ 显示上传命令返回的成功/失败通知
- 📝 **无需操作:** 变更会自动同步 - 📝 **无需操作:** 变更会自动同步
#### 场景 C:同步到多个数据库 #### 场景 D:同步到多个数据库
```yaml ```yaml
--- ---
@@ -73,12 +128,13 @@ title: 我的文章
NotionID-blog: abc123 NotionID-blog: abc123
NotionID-portfolio: def456 NotionID-portfolio: def456
NotionID-notes: ghi789 NotionID-notes: ghi789
autosync-database: [blog, portfolio, notes]
--- ---
``` ```
**行为:** **行为:**
- ✅ 检测到 3 个 NotionID - ✅ 检测到 3 个数据库目标
- ✅ 显示提示:"🔄 自动同步:正在同步到 3 个数据库..." - ✅ 显示提示:"🔄 自动同步:正在同步到 3 个数据库..."
- ✅ 依次同步到所有 3 个数据库 - ✅ 依次同步到所有 3 个数据库
- ✅ 为每个数据库显示独立的结果通知 - ✅ 为每个数据库显示独立的结果通知
@@ -86,7 +142,7 @@ NotionID-notes: ghi789
### 自动同步最佳实践 ### 自动同步最佳实践
1. **首次手动同步**:始终先手动执行第一次同步以建立 NotionID 链接 1. **添加 Frontmatter 配置**:只需添加 `autosync-database: [你的数据库]` 即可启用自动同步,无需手动上传
2. **合理配置延迟**如果你经常编辑设置较长的延迟时间5-10 秒) 2. **合理配置延迟**如果你经常编辑设置较长的延迟时间5-10 秒)
3. **监控同步状态**:注意查看通知以确保同步成功完成 3. **监控同步状态**:注意查看通知以确保同步成功完成
4. **查看日志**打开开发者控制台Ctrl+Shift+I / Cmd+Option+I查看详细的同步日志 4. **查看日志**打开开发者控制台Ctrl+Shift+I / Cmd+Option+I查看详细的同步日志

View File

@@ -1,96 +1,101 @@
export const en = { export const en = {
databaseFormat: "Database Format", databaseFormat: "Database Format",
databaseFormatDesc: "Select the database format you want to sync to NotionNext or General", databaseFormatDesc: "Select the database format to sync to: NotionNext or General.",
databaseNext: "NotionNext", databaseNext: "NotionNext",
databaseGeneral: "General", databaseGeneral: "General",
databaseCustom: "Custom", databaseCustom: "Custom",
databaseFullName: "Database Full Name", databaseFullName: "Database Full Name",
databaseFullNameDesc: "Please give a full name for your database", databaseFullNameDesc: "Set a full name for your database.",
databaseFullNameText: "Enter your database full name", databaseFullNameText: "Enter your database's full name",
databaseAbbreviateName: "Database Abbreviate Name", databaseAbbreviateName: "Abbreviated Name",
databaseAbbreviateNameDesc: "Please give a nick name for your database", databaseAbbreviateNameDesc: "Set a shorter, abbreviated name for your database.",
databaseAbbreviateNameText: "Enter your database nick name", databaseAbbreviateNameText: "Enter your database's abbreviated name",
ribbonIcon: "Share to NotionNext", ribbonIcon: "Sync to NotionNext",
GeneralSetting: "General information Settings", GeneralSetting: "General Settings",
CommandID: "share-to-notionnext", CommandID: "share-to-notionnext",
CommandName: "Share to NotionNext Database", CommandName: "Sync to NotionNext",
CommandIDGeneral: "share-to-notion", CommandIDGeneral: "share-to-notion",
CommandNameGeneral: "Share to Notion General Database", CommandNameGeneral: "Sync to General Database",
NotionNextButton: "NotionNext Sync", NotionNextButton: "NotionNext Sync",
NotionNextButtonDesc: "Open this option, Sync to NotionNext command will be displayed in the command palette (default: ON)", NotionNextButtonDesc: "Enables the 'Sync to NotionNext' command in the command palette (default: on).",
NotionNextSettingHeader: "NotionNext Database Settings", NotionNextSettingHeader: "NotionNext Database Settings",
NotionAPI: "Notion API Token", NotionAPI: "Notion API Token",
NotionAPIDesc: "Generate from https://www.notion.so/my-integrations", NotionAPIDesc: "Get yours from notion.so/my-integrations.",
NotionAPIText: "Enter your Notion API Token", NotionAPIText: "Enter your Notion API Token",
DatabaseID: "Database ID", DatabaseID: "Database ID",
DatabaseIDDesc: "Collect from the top-right Share --> Publish", DatabaseIDDesc: "Find this in your Notion page's top-right 'Share' menu.",
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)", "Leave empty for no banner. If you want a banner, enter an image URL (e.g., https://abc.com/b.png).",
BannerUrlText: "Enter your banner url", BannerUrlText: "Enter your banner URL",
NotionUser: "Notion ID (username, optional)", NotionUser: "Notion Username (optional)",
NotionUserDesc: NotionUserDesc:
"Collect from share link likes:https://username.notion.site. Your notion id is [username]", "If your site is username.notion.site, your username is [username].",
NotionUserText: "Enter your notion ID", NotionUserText: "Enter your Notion username",
NotionLinkDisplay: "Notion Link Display", NotionLinkDisplay: "Display Notion Link",
NotionLinkDisplayDesc: "Default is ON, if you want to hide the link in the front matter, please turn it off", NotionLinkDisplayDesc: "If disabled, the Notion link won't be added to the front matter after syncing (default: on).",
AutoCopyNotionLink: "Auto-copy Notion Link",
AutoCopyNotionLinkDesc: "Automatically copy the Notion page link to the clipboard after syncing (default: on).",
AutoSync: "Auto Sync", AutoSync: "Auto Sync",
AutoSyncDesc: "Automatically sync to Notion when frontmatter or content is modified (requires existing NotionID)", AutoSyncDesc: "Automatically syncs changes to Notion when the file's frontmatter or content is modified. Supports creating and updating pages.",
AutoSyncFrontmatterKey: "Auto Sync Frontmatter Key",
AutoSyncFrontmatterKeyDesc: "Specify the frontmatter key used to list the databases this file should auto-sync to (defaults to 'autosync-database').",
AutoSyncDelay: "Auto Sync Delay (seconds)", AutoSyncDelay: "Auto Sync Delay (seconds)",
AutoSyncDelayDesc: "How many seconds to wait after document modification before triggering auto sync (default: 5 seconds, minimum: 2 seconds)", AutoSyncDelayDesc: "Delay in seconds to wait before syncing after a change. Prevents excessive syncs (default: 5s, min: 2s).",
AutoSyncDelayText: "Enter delay in seconds", AutoSyncDelayText: "Enter delay in seconds",
NotionGeneralSettingHeader: "General Notion Database Settings", NotionGeneralSettingHeader: "General Notion Database Settings",
NotionGeneralButton: "Notion General Sync", NotionGeneralButton: "General Database Sync",
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette (default: ON)", NotionGeneralButtonDesc: "Enables the 'Sync to General Database' command in the command palette (default: on).",
NotionTagButton: "Notion Tags Sync", NotionTagButton: "Sync Tags",
NotionTagButtonDesc: "Sync Tags to Notion General Database (default: ON)", NotionTagButtonDesc: "Sync Obsidian tags to the Notion database (default: on).",
NotionCustomTitle: "Customise title property", NotionCustomTitle: "Custom Title Property",
NotionCustomTitleDesc: "Modify the column name of the Notion database (default: OFF)", NotionCustomTitleDesc: "Customize the title property's name in your Notion database (default: off).",
NotionCustomTitleName: "Preferred title name", NotionCustomTitleName: "Custom Title Property Name",
NotionCustomTitleNameDesc: "Enter the preferred title name for the first column of the Notion database (default: title)", NotionCustomTitleNameDesc: "Enter the custom name for the title property of your Notion database (default: 'title').",
NotionCustomTitleText: "Enter the name", NotionCustomTitleText: "Enter the property name",
NotionCustomValues: "Customise values property", NotionCustomValues: "Custom Properties",
NotionCustomValuesDesc: "Modify the column name of the Notion databaseone per line", NotionCustomValuesDesc: "Define custom properties to sync to your Notion database, one per line.",
NotionCustomValuesText: "Enter all properties that you want to sync", NotionCustomValuesText: "Enter all properties you want to sync",
NotYetFinish: "Not finished. This function will be available in the next version", NotYetFinish: "This feature will be available in a future version.",
PlaceHolder: "Enter database Name", PlaceHolder: "Enter database name",
"notion-logo": "Share to NotionNext", "notion-logo": "Sync to NotionNext",
"sync-preffix": "Sync to ", "sync-preffix": "📄",
"sync-success": "success", "sync-success": "Successfully synced to NotionNext:\n",
"sync-fail": "failed", "sync-fail": "Failed to sync to NotionNext:\n",
"open-notion": "Please open the file that needs to be synchronized", "open-notion": "Please open a file to sync first.",
"config-secrets-notion-api": "config-secrets-notion-api":
"Please set up the notion API in the settings tab.", "Please configure your Notion API key in the plugin settings.",
"config-secrets-database-id": "config-secrets-database-id":
"Please set up the database id in the settings tab.", "Please configure your Database ID in the plugin settings.",
"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.", "Failed to set tags. Check the frontmatter or disable tag sync in settings.",
NNonMissing: NNonMissing:
"The 'NNon' property is missing in the settings. Please set it up.", "The 'NNon' property is not set. Please select a NotionNext database in settings.",
"set-api-id": "set-api-id":
"Please set up the notion API and database ID in the settings tab.", "Please configure your Notion API key and Database ID in the plugin settings.",
NotionCustomSettingHeader: "Notion Custom Database Settings", NotionCustomSettingHeader: "Notion Custom Database Settings",
NotionCustomButton: "Notion Customised command switch", NotionCustomButton: "Enable Custom Database Command",
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette", NotionCustomButtonDesc: "If enabled, the 'Sync to Custom Database' command appears in the command palette.",
CustomPropertyName: "Property Name", CustomPropertyName: "Property Name",
CustomPropertyFirstColumn: "Title Column", CustomPropertyFirstColumn: "Title Property Name",
CustomPropertyFirstColumnDesc: "The title of the page, must be the first property", CustomPropertyFirstColumnDesc: "The page title. This must be the first property in the list.",
CustomProperty: "Property", CustomProperty: "Property",
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 a new property that matches a property in your Notion database.",
CopyErrorMessage: "Auto copy failed, please copy it manually", CopyErrorMessage: "Auto-copy failed. Please copy the link manually.",
BlockUploaded: "All blocks uploaded", BlockUploaded: "All content blocks uploaded successfully.",
ExtraBlockUploaded: "Extra blocks uploaded", ExtraBlockUploaded: "Additional blocks uploaded successfully.",
CheckConsole: "Check the console for more information \n opt+cmd+i/ctrl+shift+i", CheckConsole: "For more details, open the developer console (opt+cmd+i or ctrl+shift+i).",
SettingsMigrated: "✨ Plugin settings updated! Auto sync feature added, check plugin settings", SettingsMigrated: "✨ Settings updated! Auto-Sync is now available. Check the settings to learn more.",
AutoSyncNoNotionID: "⚠️ Auto sync skipped: This document has not been synced to Notion, please upload manually first", AutoSyncNoNotionID: "🆕 Auto-sync: First upload to Notion",
AutoSyncMultipleSync: "🔄 Auto sync: Syncing to {count} database(s)...", AutoSyncMissingDatabaseList: "⚠️ Auto-sync skipped: Add `{key}: [database_name]` to your frontmatter to specify target databases.",
AutoSyncFailed: "Auto sync to {database} failed: {error}", AutoSyncMultipleSync: "🔄 Auto-sync: Syncing to {count} database(s)...",
AutoSyncError: "Auto sync failed for {filename}: {error}", AutoSyncFailed: "Auto-sync to {database} failed: {error}",
"reach-mobile-limit": "The number of blocks exceeds the limit of 100, please use the desktop plugin", AutoSyncError: "Auto-sync for {filename} failed: {error}",
StartUpload: "Start upload {filename}", "reach-mobile-limit": "Block limit (100) reached. For unlimited blocks, please use the desktop version.",
StartUpload: "Starting upload for {filename}...",
AddNewDatabase: "Add New Database", AddNewDatabase: "Add New Database",
AddNewDatabaseDesc: "Add a new database configuration", AddNewDatabaseDesc: "Add a new database configuration",
AddNewDatabaseTooltip: "Add New Database", AddNewDatabaseTooltip: "Add New Database",
@@ -98,14 +103,14 @@ export const en = {
Preview: "Preview", Preview: "Preview",
DatabaseFormatLabel: "Database Format", DatabaseFormatLabel: "Database Format",
DatabaseFullNameLabel: "Database Full Name", DatabaseFullNameLabel: "Database Full Name",
DatabaseAbbreviateNameLabel: "Database Abbreviate Name", DatabaseAbbreviateNameLabel: "Abbreviated Name",
NotionAPILabel: "Notion API Key", NotionAPILabel: "Notion API Key",
DatabaseIDLabel: "Database ID", DatabaseIDLabel: "Database ID",
ToggleAPIKeyVisibility: "Toggle API Key Visibility", ToggleAPIKeyVisibility: "Toggle API Key Visibility",
CopyAPIKey: "Copy API Key", CopyAPIKey: "Copy API Key",
APIKeyCopied: "API Key copied to clipboard", APIKeyCopied: "API key copied to clipboard.",
ToggleDatabaseIDVisibility: "Toggle Database ID Visibility", ToggleDatabaseIDVisibility: "Toggle Database ID Visibility",
CopyDatabaseID: "Copy Database ID", CopyDatabaseID: "Copy Database ID",
DatabaseIDCopied: "Database ID copied to clipboard", DatabaseIDCopied: "Database ID copied to clipboard.",
AddNewDatabaseModal: "Add new database", AddNewDatabaseModal: "Add New Database",
} }

View File

@@ -1,88 +1,94 @@
export const ja = { export const ja = {
databaseFormat: "データベース形式", databaseFormat: "データベース形式",
databaseFormatDesc: "同期したいデータベース形式を選択してください", databaseFormatDesc: "同期先のデータベース形式を選択してくださいNotionNext または 一般)。",
databaseNext: "NotionNext", databaseNext: "NotionNext",
databaseGeneral: "一般的なNotion", databaseGeneral: "一般",
databaseCustom: "カスタム", databaseCustom: "カスタム",
databaseFullName: "データベースの全称", databaseFullName: "データベースの全称",
databaseFullNameDesc: "データベースの全称を入力してください", databaseFullNameDesc: "データベースのフルネームを設定します。",
databaseFullNameText: "データベースの全称を入力", databaseFullNameText: "データベースの全称を入力",
databaseAbbreviateName: "データベースの略称", databaseAbbreviateName: "データベースの略称",
databaseAbbreviateNameDesc: "データベースの略称を入力してください", databaseAbbreviateNameDesc: "データベースの略称を設定します。",
databaseAbbreviateNameText: "データベースの略称を入力", databaseAbbreviateNameText: "データベースの略称を入力",
ribbonIcon: "NotionNextで共有", ribbonIcon: "NotionNextへ同期",
GeneralSetting: "一般設定", GeneralSetting: "一般設定",
CommandID: "share-to-notionnext", CommandID: "share-to-notionnext",
CommandName: "NotionNextデータベースに共有", CommandName: "NotionNextへ同期",
CommandIDGeneral: "share-to-notion", CommandIDGeneral: "share-to-notion",
CommandNameGeneral: "一般的なNotionデータベースに共有", CommandNameGeneral: "一般データベースへ同期",
NotionNextButton: "NotionNext同期", NotionNextButton: "NotionNext同期",
NotionNextButtonDesc: "このオプションを開くと、NotionNext同期コマンドがコマンドパレットに表示されます(デフォルト:ON", NotionNextButtonDesc: "有効にすると、コマンドパレットに「NotionNext同期」が表示されます(デフォルト:オン)。",
NotionNextSettingHeader: "NotionNextデータベース設定", NotionNextSettingHeader: "NotionNextデータベース設定",
NotionAPI: "Notion API トークン", NotionAPI: "Notion API トークン",
NotionAPIDesc: "https://www.notion.so/my-integrations から生成してください", NotionAPIDesc: "notion.so/my-integrations から取得します。",
NotionAPIText: "Notion API トークンを入力", NotionAPIText: "Notion API トークンを入力",
DatabaseID: "データベースID", DatabaseID: "データベースID",
DatabaseIDDesc: "右上共有 --> 公開から取得してください", DatabaseIDDesc: "Notionページの右上共有」メニューから取得します。",
DatabaseIDText: "データベースIDを入力", DatabaseIDText: "データベースIDを入力",
BannerUrl: "バナーURL任意", BannerUrl: "バナーURL任意",
BannerUrlDesc: "デフォルトは空白です。バナーを表示したい場合は、URLを入力してくださいhttps://abc.com/b.png", BannerUrlDesc: "空のままにするとバナーは表示されません。表示するには画像のURLを入力してくださいhttps://abc.com/b.png",
BannerUrlText: "バナーのURLを入力", BannerUrlText: "バナーのURLを入力",
NotionUser: "Notion IDユーザー名任意)", NotionUser: "Notionユーザー名任意)",
NotionUserDesc: "共有リンクから取得https://username.notion.site。Notion IDは[username]です", NotionUserDesc: "共有リンクが `username.notion.site` の場合、Notionユーザー名は `[username]` です",
NotionUserText: "Notion IDを入力", NotionUserText: "Notionユーザー名を入力",
NotionLinkDisplay: "Notionリンク表示", NotionLinkDisplay: "Notionリンク表示",
NotionLinkDisplayDesc: "デフォルトはONです。front matterにリンクを非表示にしたい場合は、オフにしてください", NotionLinkDisplayDesc: "デフォルトで有効。無効にすると、同期後にfront matterへNotionリンクが追加されません。",
AutoCopyNotionLink: "Notionリンクを自動コピー",
AutoCopyNotionLinkDesc: "同期完了後、Notionページのリンクをクリップボードに自動コピーしますデフォルトオン。",
AutoSync: "自動同期", AutoSync: "自動同期",
AutoSyncDesc: "frontmatter またはコンテンツが変更されたときに自動的に Notion に同期しますNotionID が必要)", AutoSyncDesc: "ファイルの内容(frontmatterまたは本文)が変更されると、自動でNotionに同期します。新規作成と更新の両方に対応。",
AutoSyncDelay: "自動同期遅延時間(秒)", AutoSyncFrontmatterKey: "自動同期 frontmatter キー",
AutoSyncDelayDesc: "ドキュメントの変更後、自動同期をトリガーするまでの待機時間デフォルト5秒、最小2秒", AutoSyncFrontmatterKeyDesc: "自動同期の対象となるデータベースをリストアップするための frontmatterキーを設定しますデフォルトautosync-database",
AutoSyncDelay: "自動同期の遅延(秒)",
AutoSyncDelayDesc: "変更が検知されてから同期を開始するまでの遅延時間。同期の頻発を防ぎますデフォルト5秒、最小2秒。",
AutoSyncDelayText: "遅延秒数を入力", AutoSyncDelayText: "遅延秒数を入力",
NotionGeneralSettingHeader: "一般的なNotionデータベース設定", NotionGeneralSettingHeader: "一般Notionデータベース設定",
NotionGeneralButton: "一般的なNotion同期", NotionGeneralButton: "一般データベース同期",
NotionGeneralButtonDesc: "このオプションを開くと、一般的なNotionデータベース同期コマンドがコマンドパレットに表示されます(デフォルト:ON", NotionGeneralButtonDesc: "有効にすると、コマンドパレットに「一般データベース同期」が表示されます(デフォルト:オン)。",
NotionTagButton: "Notionタグ同期", NotionTagButton: "タグ同期",
NotionTagButtonDesc: "タグを一般的なNotionデータベースに同期デフォルトON", NotionTagButtonDesc: "ObsidianのタグをNotionデータベースに同期します(デフォルト:オン)。",
NotionCustomTitle: "タイトルのカスタマイズ", NotionCustomTitle: "タイトルプロパティをカスタム",
NotionCustomTitleDesc: "Notionデータベースの列名を変更(デフォルト:OFF", NotionCustomTitleDesc: "Notionデータベースのタイトル列の名前をカスタマイズします(デフォルト:オフ)。",
NotionCustomTitleName: "希望のタイトル名", NotionCustomTitleName: "カスタムタイトル名",
NotionCustomTitleNameDesc: "Notionデータベースの最初の列のための希望のタイトル名を入力デフォルトtitle", NotionCustomTitleNameDesc: "Notionデータベースのタイトル列に使用するカスタム名を入力してください(デフォルト:title」)。",
NotionCustomTitleText: "名を入力", NotionCustomTitleText: "プロパティ名を入力",
NotionCustomValues: "値のカスタマイズ", NotionCustomValues: "カスタムプロパティ",
NotionCustomValuesDesc: "Notionデータベースの列名を変更、1行に1つ", NotionCustomValuesDesc: "Notionデータベースに同期するカスタムプロパティを1行に1つずつ定義します。",
NotionCustomValuesText: "同期したいすべてのプロパティを入力", NotionCustomValuesText: "同期したいすべてのプロパティを入力",
NotYetFinish: "未完了。この機能はのバージョンで利用可能になります", NotYetFinish: "この機能は将来のバージョンで利用可能になります",
PlaceHolder: "データベース名を入力", PlaceHolder: "データベース名を入力",
"notion-logo": "NotionNextで共有", "notion-logo": "NotionNextへ同期",
"sync-success": "NotionNextへの同期に成功\n", "sync-preffix": "📄",
"sync-fail": "NotionNextへの同期に失敗:\n", "sync-success": "NotionNextへの同期が成功しました。\n",
"open-notion": "同期が必要なファイルを開いてください", "sync-fail": "NotionNextへの同期に失敗しました。\n",
"config-secrets-notion-api": "設定タブでNotion APIを設定してください", "open-notion": "同期するファイルを先に開いてください",
"config-secrets-database-id": "設定タブでデータベースIDを設定してください", "config-secrets-notion-api": "プラグイン設定でNotion APIキーを設定してください",
"set-tags-fail": "タグの設定に失敗。ファイルのfrontmatterを確認するか、設定タブでタグのスイッチをオフにしてください", "config-secrets-database-id": "プラグイン設定でデータベースIDを設定してください",
NNonMissing: "設定に 'NNon' プロパティがありません。設定してください", "set-tags-fail": "タグの設定に失敗しました。frontmatterを確認するか、設定でタグ同期を無効にしてください",
"set-api-id": "設定タブでNotion APIおよびデータベースIDを設定してください", NNonMissing: "'NNon'プロパティが設定されていません。設定でNotionNextデータベースを選択してください",
"set-api-id": "プラグイン設定でNotion APIキーとデータベースIDを設定してください。",
NotionCustomSettingHeader: "Notionカスタムデータベース設定", NotionCustomSettingHeader: "Notionカスタムデータベース設定",
NotionCustomButton: "Notionカスタマイズコマンドの切り替え", NotionCustomButton: "カスタムデータベースコマンドを有効化",
NotionCustomButtonDesc: "このオプションを開くと、Notionカスタムデータベース同期コマンドがコマンドパレットに表示されます", NotionCustomButtonDesc: "有効にすると、「カスタムデータベース同期コマンドがコマンドパレットに表示されます",
CustomPropertyName: "カスタムプロパティ名", CustomPropertyName: "プロパティ名",
CustomPropertyFirstColumn: "最初の列のカスタムプロパティ名", CustomPropertyFirstColumn: "タイトルプロパティ名",
CustomPropertyFirstColumnDesc: "最初の列のカスタムプロパティ名を入力してください", CustomPropertyFirstColumnDesc: "ページのタイトル。これはリストの最初のプロパティである必要があります。",
CustomProperty: "カスタムプロパティ", CustomProperty: "プロパティ",
AddCustomProperty: "カスタムプロパティを追加", AddCustomProperty: "カスタムプロパティを追加",
AddNewProperty: "新しいプロパティを追加", AddNewProperty: "新しいプロパティを追加",
AddNewPropertyDesc: "新しいプロパティを追加してください", AddNewPropertyDesc: "Notionデータベースのプロパティと一致する新しいプロパティを追加します。",
CopyErrorMessage: "自動コピーに失敗しました", CopyErrorMessage: "リンクの自動コピーに失敗しました。手動でコピーしてください。",
BlockUploaded: "ブロックアップロードされました", BlockUploaded: "すべてのブロックアップロードました",
ExtraBlockUploaded: "追加ブロックアップロードされました", ExtraBlockUploaded: "追加ブロックアップロードました",
CheckConsole: "詳細情報を確認するには、コンソールを開いてください \n opt+cmd+i/ctrl+shift+i", CheckConsole: "詳細は、開発者コンソール(opt+cmd+i または ctrl+shift+i)で確認できます。",
SettingsMigrated: "✨ プラグイン設定が更新されました!自動同期機能が追加されました。設定を確認してください", SettingsMigrated: "✨ 設定が更新されました!自動同期が利用可能です。詳細は設定画面をご確認ください",
AutoSyncNoNotionID: "⚠️ 自動同期をスキップ:このドキュメントは Notion に同期されていません。まず手動でアップロードしてください", AutoSyncNoNotionID: "🆕 自動同期Notionへ初めてアップロードします",
AutoSyncMultipleSync: "🔄 自動同期{count} 個のデータベースに同期中...", AutoSyncMissingDatabaseList: "⚠️ 自動同期をスキップfrontmatterに `{key}: [データベース名]` を追加して同期先を指定してください。",
AutoSyncFailed: "{database} への自動同期に失敗しました:{error}", AutoSyncMultipleSync: "🔄 自動同期:{count}個のデータベースに同期しています...",
AutoSyncError: "{filename} の自動同期に失敗しました:{error}", AutoSyncFailed: "{database}の自動同期に失敗しました:{error}",
"reach-mobile-limit": "ブロック数が100の制限を超えています。デスクトップ版プラグインを使用してください", AutoSyncError: "{filename}の自動同期に失敗しました:{error}",
StartUpload: "アップロード開始 {filename}", "reach-mobile-limit": "ブロック上限100に達しました。ブロック数に制限のないデスクトップ版をご利用ください。",
StartUpload: "{filename} のアップロードを開始します...",
AddNewDatabase: "新しいデータベースを追加", AddNewDatabase: "新しいデータベースを追加",
AddNewDatabaseDesc: "新しいデータベース構成を追加", AddNewDatabaseDesc: "新しいデータベース構成を追加",
AddNewDatabaseTooltip: "新しいデータベースを追加", AddNewDatabaseTooltip: "新しいデータベースを追加",
@@ -95,9 +101,9 @@ export const ja = {
DatabaseIDLabel: "データベース ID", DatabaseIDLabel: "データベース ID",
ToggleAPIKeyVisibility: "API キーの表示を切り替え", ToggleAPIKeyVisibility: "API キーの表示を切り替え",
CopyAPIKey: "API キーをコピー", CopyAPIKey: "API キーをコピー",
APIKeyCopied: "API キーをクリップボードにコピーしました", APIKeyCopied: "APIキーをクリップボードにコピーしました",
ToggleDatabaseIDVisibility: "データベース ID の表示を切り替え", ToggleDatabaseIDVisibility: "データベース ID の表示を切り替え",
CopyDatabaseID: "データベース ID をコピー", CopyDatabaseID: "データベース ID をコピー",
DatabaseIDCopied: "データベース ID をクリップボードにコピーしました", DatabaseIDCopied: "データベースIDをクリップボードにコピーしました",
AddNewDatabaseModal: "新しいデータベースを追加", AddNewDatabaseModal: "新しいデータベースを追加",
}; };

View File

@@ -1,105 +1,111 @@
export const zh = { export const zh = {
databaseFormat: "数据库格式", databaseFormat: "数据库格式",
databaseFormatDesc: "选择你想要同步的数据库格式Next 或者 普通", databaseFormatDesc: "选择同步的目标数据库格式NotionNext 或 通用",
databaseNext: "NotionNext", databaseNext: "NotionNext",
databaseGeneral: "通", databaseGeneral: "通",
databaseCustom: "自定义", databaseCustom: "自定义",
databaseFullName: "数据库全", databaseFullName: "数据库全",
databaseFullNameDesc: "给你的数据库一个全", databaseFullNameDesc: "数据库设置一个全",
databaseFullNameText: "输入的数据库全", databaseFullNameText: "输入的数据库全",
databaseAbbreviateName: "数据库简称", databaseAbbreviateName: "数据库简称",
databaseAbbreviateNameDesc: "给你的数据库一个简称", databaseAbbreviateNameDesc: "数据库设置一个简称",
databaseAbbreviateNameText: "输入的数据库简称", databaseAbbreviateNameText: "输入的数据库简称",
ribbonIcon: "分享到 NotionNext", ribbonIcon: "同步到 NotionNext",
GeneralSetting: "通用设置", GeneralSetting: "通用设置",
CommandID: "share-to-notionnext", CommandID: "share-to-notionnext",
CommandName: "分享到 NotionNext", CommandName: "同步到 NotionNext",
CommandIDGeneral: "share-to-notion", CommandIDGeneral: "share-to-notion",
CommandNameGeneral: "分享到 Notion 普通数据库", CommandNameGeneral: "同步到通用数据库",
NotionNextButton: "NotionNext 同步", NotionNextButton: "NotionNext 同步",
NotionNextButtonDesc: "打开此选项NotionNext 同步将显示在命令面板中(默认开)", NotionNextButtonDesc: "启用后,命令面板中将显示“同步到 NotionNext”命令(默认开",
NotionNextSettingHeader: "NotionNext 数据库参数设置", NotionNextSettingHeader: "NotionNext 数据库设置",
NotionAPI: "Notion API 令牌", NotionAPI: "Notion API 令牌",
NotionAPIDesc: "从 https://www.notion.so/my-integrations 生成", NotionAPIDesc: "从 notion.so/my-integrations 获取",
NotionAPIText: "输入的 Notion API 令牌", NotionAPIText: "输入的 Notion API 令牌",
DatabaseID: "数据库 ID", DatabaseID: "数据库 ID",
DatabaseIDDesc: "右上角的分享 --> 发布中获取", DatabaseIDDesc: "可从 Notion 页面右上角的分享”菜单中获取",
DatabaseIDText: "输入的数据库 ID", DatabaseIDText: "输入的数据库 ID",
BannerUrl: "封面图片地址(可选)", BannerUrl: "封面图片地址(可选)",
BannerUrlDesc: BannerUrlDesc:
"默认为空,如果你想显示封面图片请输入图片地址例如https://abc.com/b.png", "留空则不显示。如需封面请输入图片地址例如https://abc.com/b.png",
BannerUrlText: "输入的封面图片地址", BannerUrlText: "输入的封面图片地址",
NotionUser: "Notion ID用户名可选)", NotionUser: "Notion 用户名可选)",
NotionUserDesc: NotionUserDesc:
"数据库分享链接类似https://username.notion.site/。你的 Notion ID 是 [username]", "分享链接username.notion.site你的 Notion 用户名即为 [username]",
NotionUserText: "输入的 Notion ID", NotionUserText: "输入的 Notion 用户名",
NotionLinkDisplay: "Notion 链接显示", NotionLinkDisplay: "显示 Notion 链接",
NotionLinkDisplayDesc: "默认开启,如果你不想在front matter中显示链接,请关闭", NotionLinkDisplayDesc: "默认开启。关闭后,同步成功时 frontmatter 中不会出现 Notion 链接",
AutoCopyNotionLink: "自动复制 Notion 链接",
AutoCopyNotionLinkDesc: "同步后自动将 Notion 链接复制到剪贴板(默认开启)",
AutoSync: "自动同步", AutoSync: "自动同步",
AutoSyncDesc: "当检测到文档的 frontmatter 或内容发生修改时,自动同步到 Notion需要文档已有 NotionID", AutoSyncDesc: "当文档的 frontmatter 或内容修改时,自动同步到 Notion支持新建和更新",
AutoSyncDelay: "自动同步延迟时间(秒)", AutoSyncFrontmatterKey: "自动同步 Frontmatter 键名",
AutoSyncDelayDesc: "文档修改后等待多少秒才触发自动同步避免频繁同步默认5秒最小2秒", AutoSyncFrontmatterKeyDesc: "设置用于指定自动同步数据库列表的 frontmatter 键名(默认为 autosync-database",
AutoSyncDelay: "自动同步延迟(秒)",
AutoSyncDelayDesc: "文档修改后,等待指定秒数再触发自动同步,以避免频繁操作(默认 5 秒,最少 2 秒)",
AutoSyncDelayText: "输入延迟秒数", AutoSyncDelayText: "输入延迟秒数",
NotionGeneralSettingHeader: "通 Notion 数据库设置", NotionGeneralSettingHeader: "通 Notion 数据库设置",
NotionGeneralButton: "通数据库同步", NotionGeneralButton: "通数据库同步",
NotionGeneralButtonDesc: "打开此选项,同步到通数据库命令将显示在命令面板中(默认开)", NotionGeneralButtonDesc: "启用后,命令面板中将显示“同步到通数据库命令(默认开",
NotionTagButton: "标签同步开关", NotionTagButton: "标签同步",
NotionTagButtonDesc: "将标签同步到普通数据库(默认开)", NotionTagButtonDesc: "将 Obsidian 标签同步到 Notion 数据库(默认开",
NotionCustomTitle: "修改 Notion 数据库表头开关", NotionCustomTitle: "自定义标题属性",
NotionCustomTitleDesc: "自定义Notion 数据库第一列表头名(默认关)", NotionCustomTitleDesc: "自定义 Notion 数据库中标题列的名称(默认关",
NotionCustomTitleName: "想要修改的表头名", NotionCustomTitleName: "自定义标题名称",
NotionCustomTitleNameDesc: "输入你想要修改的notion数据库的表头名(默认title", NotionCustomTitleNameDesc: "为 Notion 数据库的标题列设置一个自定义名称(默认title",
NotionCustomTitleText: "输入表头名", NotionCustomTitleText: "输入标题名称",
NotionCustomValues: "自定义Notion 数据库表头", NotionCustomValues: "自定义属性",
NotionCustomValuesDesc: "自定义Notion 数据库表头,每行一个", NotionCustomValuesDesc: "自定义同步到 Notion 数据库的属性,每行一个",
NotionCustomValuesText: "输入你想要同步的所有属性", NotionCustomValuesText: "输入所有你希望同步的属性",
NotYetFinish: "未完成。此功能将在之后版本中提供", NotYetFinish: "此功能将在未来版本中提供",
PlaceHolder: "输入数据库名称", PlaceHolder: "输入数据库名称",
"notion-logo": "分享到NotionNext", "notion-logo": "同步到 NotionNext",
"sync-success": "同步到NotionNext成功:\n", "sync-preffix": "📄",
"sync-fail": "同步到NotionNext失败: \n", "sync-success": "成功同步到 NotionNext\n",
"open-file": "请打开需要同步的文件", "sync-fail": "同步到 NotionNext 失败:\n",
"config-secrets-notion-api": "请在插件设置中添加notion API", "open-file": "请先打开要同步的文件。",
"config-secrets-database-id": "请在插件设置中添加database id", "config-secrets-notion-api": "请在插件设置中配置 Notion API 密钥。",
"config-secrets-database-id": "请在插件设置中配置数据库 ID。",
"set-tags-fail": "set-tags-fail":
"设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关", "标签设置失败请检查 frontmatter 或在设置中关闭标签同步。",
NNonMissing: "未设置'NNon'属性请在插件设置中选择NotionNext数据库。", NNonMissing: "未设置 'NNon' 属性,请在插件设置中选择一个 NotionNext 数据库。",
"set-api-id": "请在插件设置中设置notion API和database ID", "set-api-id": "请在插件设置中配置 Notion API 和数据库 ID",
NotionCustomSettingHeader: "Notion 自定义数据库设置", NotionCustomSettingHeader: "Notion 自定义数据库设置",
NotionCustomButton: "Notion 自定义数据库同步命令开关", NotionCustomButton: "启用自定义数据库同步命令",
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中", NotionCustomButtonDesc: "启用后,“同步到自定义数据库”的命令将出现在命令面板中",
CustomPropertyName: "自定义属性名", CustomPropertyName: "自定义属性名",
CustomPropertyFirstColumn: "第一列属性", CustomPropertyFirstColumn: "标题属性",
CustomPropertyFirstColumnDesc: "第一列必须为标题属性", CustomPropertyFirstColumnDesc: "第一列必须为标题属性",
CustomProperty: "自定义属性", CustomProperty: "自定义属性",
AddCustomProperty: "添加自定义属性", AddCustomProperty: "添加自定义属性",
AddNewProperty: "添加新属性", AddNewProperty: "添加新属性",
AddNewPropertyDesc: "添加一个Notion数据库匹配的新属性", AddNewPropertyDesc: "添加一个与您 Notion 数据库中的属性相匹配的新属性",
CopyErrorMessage: "复制链接失败,请手动复制", CopyErrorMessage: "自动复制链接失败,请手动复制",
BlockUploaded: "所有内容已成功上传", BlockUploaded: "所有块已上传成功",
ExtraBlockUploaded: "额外内容已成功上传", ExtraBlockUploaded: "额外块已上传成功",
CheckConsole: "opt+cmd+i/ctrl+shift+i\n打开控制台查看更多信息", CheckConsole: "opt+cmd+i / ctrl+shift+i 打开控制台查看详情。",
SettingsMigrated: "✨ 插件设置已更新!新增自动同步功能,请在设置中查看", SettingsMigrated: "✨ 插件设置已更新!新增自动同步功能,详情请查看设置。",
AutoSyncNoNotionID: "⚠️ 自动同步跳过:此文档未同步到 Notion,请先手动上传", AutoSyncNoNotionID: "🆕 自动同步:首次上传到 Notion",
AutoSyncMissingDatabaseList: "⚠️ 自动同步已跳过:请在 frontmatter 中添加 \"{key}\" 以指定目标数据库。",
AutoSyncMultipleSync: "🔄 自动同步:正在同步到 {count} 个数据库...", AutoSyncMultipleSync: "🔄 自动同步:正在同步到 {count} 个数据库...",
AutoSyncFailed: "自动同步到 {database} 失败:{error}", AutoSyncFailed: "同步到 {database} 失败:{error}",
AutoSyncError: "自动同步 {filename} 失败:{error}", AutoSyncError: "同步 {filename} 失败:{error}",
StartUpload: "开始上传 {filename}", StartUpload: "开始上传 {filename}...",
AddNewDatabase: "添加新数据库", AddNewDatabase: "添加新数据库",
AddNewDatabaseDesc: "添加新的数据库配置", AddNewDatabaseDesc: "添加新的数据库配置",
AddNewDatabaseTooltip: "添加新数据库", AddNewDatabaseTooltip: "添加新数据库",
EditDatabase: "编辑数据库", EditDatabase: "编辑数据库",
Preview: "预览", Preview: "预览",
DatabaseFormatLabel: "数据库格式", DatabaseFormatLabel: "数据库格式",
DatabaseFullNameLabel: "数据库全", DatabaseFullNameLabel: "数据库全",
DatabaseAbbreviateNameLabel: "数据库简称", DatabaseAbbreviateNameLabel: "数据库简称",
NotionAPILabel: "Notion API 密钥", NotionAPILabel: "Notion API 密钥",
DatabaseIDLabel: "数据库 ID", DatabaseIDLabel: "数据库 ID",
ToggleAPIKeyVisibility: "切换 API 密钥可见性", ToggleAPIKeyVisibility: "切换 API 密钥可见性",
CopyAPIKey: "复制 API 密钥", CopyAPIKey: "复制 API 密钥",
APIKeyCopied: "API 密钥已复制到剪贴板", APIKeyCopied: "API 密钥已复制到剪贴板",
ToggleDatabaseIDVisibility: "切换数据库 ID 可见性", ToggleDatabaseIDVisibility: "切换数据库 ID 可见性",
CopyDatabaseID: "复制数据库 ID", CopyDatabaseID: "复制数据库 ID",
DatabaseIDCopied: "数据库 ID 已复制到剪贴板", DatabaseIDCopied: "数据库 ID 已复制到剪贴板",
AddNewDatabaseModal: "添加新数据库", AddNewDatabaseModal: "添加新数据库",
} }

View File

@@ -4,6 +4,7 @@ import { i18nConfig } from "src/lang/I18n";
import ribbonCommands from "src/commands/NotionCommands"; import ribbonCommands from "src/commands/NotionCommands";
import { ObsidianSettingTab, PluginSettings, DEFAULT_SETTINGS, DatabaseDetails } from "src/ui/settingTabs"; import { ObsidianSettingTab, PluginSettings, DEFAULT_SETTINGS, DatabaseDetails } from "src/ui/settingTabs";
import { uploadCommandNext, uploadCommandGeneral, uploadCommandCustom } from "src/upload/uploadCommand"; import { uploadCommandNext, uploadCommandGeneral, uploadCommandCustom } from "src/upload/uploadCommand";
import { DEFAULT_AUTO_SYNC_DATABASE_KEY, parseAutoSyncDatabaseList, resolveAutoSyncKey } from "src/utils/frontmatter";
// Remember to rename these classes and interfaces! // Remember to rename these classes and interfaces!
@@ -18,6 +19,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
private lastFrontmatterCache: Map<string, any> = new Map(); private lastFrontmatterCache: Map<string, any> = new Map();
private lastContentHashCache: Map<string, string> = new Map(); private lastContentHashCache: Map<string, string> = new Map();
async onload() { async onload() {
await this.loadSettings(); await this.loadSettings();
@@ -67,6 +69,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
} }
this.lastFrontmatterCache.clear(); this.lastFrontmatterCache.clear();
this.lastContentHashCache.clear(); this.lastContentHashCache.clear();
} }
async loadSettings() { async loadSettings() {
@@ -89,6 +92,13 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
if (typeof this.settings.NotionLinkDisplay !== 'boolean') { if (typeof this.settings.NotionLinkDisplay !== 'boolean') {
this.settings.NotionLinkDisplay = DEFAULT_SETTINGS.NotionLinkDisplay; this.settings.NotionLinkDisplay = DEFAULT_SETTINGS.NotionLinkDisplay;
} }
if (typeof this.settings.autoCopyNotionLink !== 'boolean') {
this.settings.autoCopyNotionLink = DEFAULT_SETTINGS.autoCopyNotionLink;
}
if (typeof this.settings.autoSyncFrontmatterKey !== 'string') {
this.settings.autoSyncFrontmatterKey = DEFAULT_AUTO_SYNC_DATABASE_KEY;
}
this.settings.autoSyncFrontmatterKey = resolveAutoSyncKey(this.settings.autoSyncFrontmatterKey);
// Ensure databaseDetails exists // Ensure databaseDetails exists
if (!this.settings.databaseDetails || typeof this.settings.databaseDetails !== 'object') { if (!this.settings.databaseDetails || typeof this.settings.databaseDetails !== 'object') {
@@ -99,7 +109,9 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
const needsSave = !loadedData || const needsSave = !loadedData ||
loadedData.autoSync === undefined || loadedData.autoSync === undefined ||
loadedData.autoSyncDelay === undefined || loadedData.autoSyncDelay === undefined ||
loadedData.NotionLinkDisplay === undefined; loadedData.NotionLinkDisplay === undefined ||
loadedData.autoCopyNotionLink === undefined ||
loadedData.autoSyncFrontmatterKey === undefined;
if (needsSave) { if (needsSave) {
const migratedFields = []; const migratedFields = [];
@@ -109,6 +121,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
if (loadedData.autoSync === undefined) migratedFields.push('autoSync'); if (loadedData.autoSync === undefined) migratedFields.push('autoSync');
if (loadedData.autoSyncDelay === undefined) migratedFields.push('autoSyncDelay'); if (loadedData.autoSyncDelay === undefined) migratedFields.push('autoSyncDelay');
if (loadedData.NotionLinkDisplay === undefined) migratedFields.push('NotionLinkDisplay'); if (loadedData.NotionLinkDisplay === undefined) migratedFields.push('NotionLinkDisplay');
if (loadedData.autoCopyNotionLink === undefined) migratedFields.push('autoCopyNotionLink');
console.log('[Settings] Migrating settings, adding fields:', migratedFields.join(', ')); console.log('[Settings] Migrating settings, adding fields:', migratedFields.join(', '));
} }
@@ -131,6 +144,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
autoSync: this.settings.autoSync, autoSync: this.settings.autoSync,
autoSyncDelay: this.settings.autoSyncDelay, autoSyncDelay: this.settings.autoSyncDelay,
NotionLinkDisplay: this.settings.NotionLinkDisplay, NotionLinkDisplay: this.settings.NotionLinkDisplay,
autoSyncFrontmatterKey: this.settings.autoSyncFrontmatterKey,
databaseCount: Object.keys(this.settings.databaseDetails || {}).length databaseCount: Object.keys(this.settings.databaseDetails || {}).length
}); });
} }
@@ -149,10 +163,26 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
console.warn('[Settings] Invalid NotionLinkDisplay value, resetting to default'); console.warn('[Settings] Invalid NotionLinkDisplay value, resetting to default');
this.settings.NotionLinkDisplay = DEFAULT_SETTINGS.NotionLinkDisplay; this.settings.NotionLinkDisplay = DEFAULT_SETTINGS.NotionLinkDisplay;
} }
if (typeof this.settings.autoCopyNotionLink !== 'boolean') {
console.warn('[Settings] Invalid autoCopyNotionLink value, resetting to default');
this.settings.autoCopyNotionLink = DEFAULT_SETTINGS.autoCopyNotionLink;
}
if (!this.settings.databaseDetails || typeof this.settings.databaseDetails !== 'object') { if (!this.settings.databaseDetails || typeof this.settings.databaseDetails !== 'object') {
console.warn('[Settings] Invalid databaseDetails, resetting to empty object'); console.warn('[Settings] Invalid databaseDetails, resetting to empty object');
this.settings.databaseDetails = {}; this.settings.databaseDetails = {};
} }
if (typeof this.settings.autoSyncFrontmatterKey !== 'string' || this.settings.autoSyncFrontmatterKey.trim().length === 0) {
console.warn('[Settings] Invalid autoSyncFrontmatterKey, resetting to default');
this.settings.autoSyncFrontmatterKey = DEFAULT_AUTO_SYNC_DATABASE_KEY;
} else {
this.settings.autoSyncFrontmatterKey = resolveAutoSyncKey(this.settings.autoSyncFrontmatterKey);
}
}
getAutoSyncFrontmatterKey(): string {
return resolveAutoSyncKey(this.settings.autoSyncFrontmatterKey);
} }
async addDatabaseDetails(dbDetails: DatabaseDetails) { async addDatabaseDetails(dbDetails: DatabaseDetails) {
@@ -327,25 +357,61 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
} }
} }
// Find all databases this file belongs to by checking for NotionID-{abName} const autoSyncKey = this.getAutoSyncFrontmatterKey();
const foundDatabases: Array<{ dbDetails: DatabaseDetails, notionId: string }> = []; const autoSyncTargets = parseAutoSyncDatabaseList(frontMatter[autoSyncKey]);
// If no autosync-database field specified
if (autoSyncTargets.length === 0) {
// Check if file has any existing NotionID (meaning it was synced before)
const hasExistingNotionID = Object.keys(frontMatter).some(key =>
key.startsWith('NotionID-') || key === 'NotionID'
);
if (hasExistingNotionID) {
// User likely forgot to add autosync-database - show a notice
const message = i18nConfig.AutoSyncMissingDatabaseList.replace('{key}', autoSyncKey);
new Notice(message, 8000);
console.log(`[AutoSync] File ${file.path} has NotionID but missing autosync-database - showing notice`);
}
// Silently skip files without NotionID (new files that don't need auto-sync)
return;
}
const dbByShortName = new Map<string, DatabaseDetails>();
for (const key in this.settings.databaseDetails) { for (const key in this.settings.databaseDetails) {
const dbDetails = this.settings.databaseDetails[key]; const dbDetails = this.settings.databaseDetails[key];
const notionIDKey = `NotionID-${dbDetails.abName}`; dbByShortName.set(dbDetails.abName.toLowerCase(), dbDetails);
}
if (frontMatter[notionIDKey]) { const foundDatabases: Array<{ dbDetails: DatabaseDetails, notionId: string | undefined }> = [];
const unresolvedTargets: string[] = [];
for (const target of autoSyncTargets) {
const lookupKey = target.toLowerCase();
const dbDetails = dbByShortName.get(lookupKey);
if (!dbDetails) {
unresolvedTargets.push(target);
continue;
}
const notionIDKey = `NotionID-${dbDetails.abName}`;
// Include database even if no NotionID exists (for first-time upload)
foundDatabases.push({ foundDatabases.push({
dbDetails: dbDetails, dbDetails,
notionId: String(frontMatter[notionIDKey]) notionId: frontMatter[notionIDKey] ? String(frontMatter[notionIDKey]) : undefined
}); });
} }
if (unresolvedTargets.length > 0) {
console.log(`[AutoSync] Frontmatter auto sync targets not found in settings: ${unresolvedTargets.join(", ")}`);
} }
// If no NotionID found, notify user to upload manually first // If no valid databases found in settings, skip
if (foundDatabases.length === 0) { if (foundDatabases.length === 0) {
console.log(`[AutoSync] No NotionID found in ${file.path}, skipping auto sync`); console.log(`[AutoSync] No matching databases found in settings for ${file.path}, skipping auto sync`);
new Notice(i18nConfig.AutoSyncNoNotionID, 4000);
return; return;
} }
@@ -353,12 +419,13 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
if (foundDatabases.length > 1) { if (foundDatabases.length > 1) {
const message = i18nConfig.AutoSyncMultipleSync.replace('{count}', String(foundDatabases.length)); const message = i18nConfig.AutoSyncMultipleSync.replace('{count}', String(foundDatabases.length));
new Notice(message, 3000); new Notice(message, 3000);
console.log(`[AutoSync] Found ${foundDatabases.length} NotionIDs in ${file.path}`); console.log(`[AutoSync] Found ${foundDatabases.length} database targets in ${file.path}`);
} }
// Sync to all found databases // Sync to all found databases
for (const { dbDetails, notionId } of foundDatabases) { for (const { dbDetails, notionId } of foundDatabases) {
console.log(`[AutoSync] ${new Date().toISOString()} Auto syncing ${file.basename} to ${dbDetails.fullName} (${dbDetails.abName})`); const isFirstSync = !notionId;
console.log(`[AutoSync] ${new Date().toISOString()} Auto syncing ${file.basename} to ${dbDetails.fullName} (${dbDetails.abName})${isFirstSync ? ' [First Upload]' : ''}`);
try { try {
// Trigger appropriate upload command based on database format // Trigger appropriate upload command based on database format
@@ -403,4 +470,3 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
} }
} }
} }

View File

@@ -5,6 +5,7 @@ import { SettingModal } from "./settingModal";
import { PreviewModal } from "./PreviewModal"; import { PreviewModal } from "./PreviewModal";
import { EditModal } from "./EditModal"; import { EditModal } from "./EditModal";
import { DeleteModal } from "./DeleteModal"; import { DeleteModal } from "./DeleteModal";
import { DEFAULT_AUTO_SYNC_DATABASE_KEY } from "src/utils/frontmatter";
export interface PluginSettings { export interface PluginSettings {
NextButton: boolean; NextButton: boolean;
@@ -13,8 +14,10 @@ export interface PluginSettings {
bannerUrl: string; bannerUrl: string;
notionUser: string; notionUser: string;
NotionLinkDisplay: boolean; NotionLinkDisplay: boolean;
autoCopyNotionLink: boolean;
autoSync: boolean; autoSync: boolean;
autoSyncDelay: number; autoSyncDelay: number;
autoSyncFrontmatterKey: string;
proxy: string; proxy: string;
GeneralButton: boolean; GeneralButton: boolean;
tagButton: boolean; tagButton: boolean;
@@ -51,8 +54,10 @@ export const DEFAULT_SETTINGS: PluginSettings = {
bannerUrl: "", bannerUrl: "",
notionUser: "", notionUser: "",
NotionLinkDisplay: true, NotionLinkDisplay: true,
autoCopyNotionLink: true,
autoSync: false, autoSync: false,
autoSyncDelay: 5, autoSyncDelay: 5,
autoSyncFrontmatterKey: DEFAULT_AUTO_SYNC_DATABASE_KEY,
proxy: "", proxy: "",
GeneralButton: true, GeneralButton: true,
tagButton: true, tagButton: true,
@@ -92,8 +97,23 @@ export class ObsidianSettingTab extends PluginSettingTab {
this.createSettingEl(containerEl, i18nConfig.NotionLinkDisplay, i18nConfig.NotionLinkDisplayDesc, 'toggle', i18nConfig.NotionLinkDisplay, this.plugin.settings.NotionLinkDisplay, 'NotionLinkDisplay') this.createSettingEl(containerEl, i18nConfig.NotionLinkDisplay, i18nConfig.NotionLinkDisplayDesc, 'toggle', i18nConfig.NotionLinkDisplay, this.plugin.settings.NotionLinkDisplay, 'NotionLinkDisplay')
this.createSettingEl(containerEl, i18nConfig.AutoCopyNotionLink, i18nConfig.AutoCopyNotionLinkDesc, 'toggle', i18nConfig.AutoCopyNotionLink, this.plugin.settings.autoCopyNotionLink, 'autoCopyNotionLink')
this.createSettingEl(containerEl, i18nConfig.AutoSync, i18nConfig.AutoSyncDesc, 'toggle', i18nConfig.AutoSync, this.plugin.settings.autoSync, 'autoSync') this.createSettingEl(containerEl, i18nConfig.AutoSync, i18nConfig.AutoSyncDesc, 'toggle', i18nConfig.AutoSync, this.plugin.settings.autoSync, 'autoSync')
new Setting(containerEl)
.setName(i18nConfig.AutoSyncFrontmatterKey)
.setDesc(i18nConfig.AutoSyncFrontmatterKeyDesc)
.addText((text) =>
text
.setPlaceholder(DEFAULT_AUTO_SYNC_DATABASE_KEY)
.setValue(this.plugin.settings.autoSyncFrontmatterKey ?? "")
.onChange(async (value) => {
this.plugin.settings.autoSyncFrontmatterKey = value;
await this.plugin.saveSettings();
})
);
// Auto Sync Delay setting - only visible when autoSync is enabled // Auto Sync Delay setting - only visible when autoSync is enabled
this.autoSyncDelayContainer = containerEl.createDiv(); this.autoSyncDelayContainer = containerEl.createDiv();
const delaySetting = new Setting(this.autoSyncDelayContainer) const delaySetting = new Setting(this.autoSyncDelayContainer)
@@ -350,4 +370,3 @@ export class ObsidianSettingTab extends PluginSettingTab {
} }
} }

View File

@@ -2,6 +2,7 @@ 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"; import { i18nConfig } from "src/lang/I18n";
import { ensureAutoSyncDatabaseEntry } from "src/utils/frontmatter";
export async function updateYamlInfo( export async function updateYamlInfo(
yamlContent: string, yamlContent: string,
@@ -17,6 +18,7 @@ export async function updateYamlInfo(
const { abName } = dbDetails const { abName } = dbDetails
const notionIDKey = `NotionID-${abName}`; const notionIDKey = `NotionID-${abName}`;
const linkKey = `link-${abName}`; const linkKey = `link-${abName}`;
const autoSyncKey = plugin.getAutoSyncFrontmatterKey();
if (notionUser !== "") { if (notionUser !== "") {
// replace url str "www" to notionID // replace url str "www" to notionID
@@ -33,12 +35,21 @@ export async function updateYamlInfo(
// add new notionID and link // add new notionID and link
yamlContent[notionIDKey] = id; yamlContent[notionIDKey] = id;
(NotionLinkDisplay) ? yamlContent[linkKey] = url : null; (NotionLinkDisplay) ? yamlContent[linkKey] = url : null;
// ensure auto sync database list contains current short name
yamlContent[autoSyncKey] = ensureAutoSyncDatabaseEntry(
yamlContent[autoSyncKey],
abName
);
}); });
// copy url to clipboard only if autoCopyNotionLink is enabled
if (plugin.settings.autoCopyNotionLink) {
try { try {
await navigator.clipboard.writeText(url) await navigator.clipboard.writeText(url);
} catch (error) { } catch (error) {
console.log(error) console.log(error);
new Notice(`${i18nConfig.CopyErrorMessage}`); new Notice(`${i18nConfig.CopyErrorMessage}`);
} }
}
} }

63
src/utils/frontmatter.ts Normal file
View File

@@ -0,0 +1,63 @@
export const DEFAULT_AUTO_SYNC_DATABASE_KEY = "autosync-database";
export function resolveAutoSyncKey(rawKey: unknown): string {
if (typeof rawKey === "string") {
const trimmed = rawKey.trim();
if (trimmed.length > 0) {
return trimmed;
}
}
return DEFAULT_AUTO_SYNC_DATABASE_KEY;
}
function toCandidateList(value: unknown): string[] {
if (Array.isArray(value)) {
return value.map(item => String(item ?? "").trim());
}
if (typeof value === "string") {
if (value.includes(",")) {
return value.split(",").map(item => item.trim());
}
return [value.trim()];
}
return [];
}
export function parseAutoSyncDatabaseList(value: unknown): string[] {
const candidates = toCandidateList(value)
.map(name => name.replace(/^\[|\]$/g, "").trim()) // strip stray brackets
.filter(Boolean);
const seen = new Map<string, string>();
for (const name of candidates) {
const key = name.toLowerCase();
if (!seen.has(key)) {
seen.set(key, name);
}
}
return Array.from(seen.values());
}
export function ensureAutoSyncDatabaseEntry(value: unknown, abName: string): string[] {
const current = parseAutoSyncDatabaseList(value);
const lower = abName.toLowerCase();
let contains = false;
const updated = current.map(name => {
if (name.toLowerCase() === lower) {
contains = true;
return abName;
}
return name;
});
if (!contains) {
updated.push(abName);
}
return updated;
}