mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
Compare commits
15 Commits
v2.8.0-bet
...
v2.8.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90dcc1aef0 | ||
|
|
7053a74e24 | ||
|
|
5144f10e77 | ||
|
|
5806a2831b | ||
|
|
eeaf7c036d | ||
|
|
3de92d3f54 | ||
|
|
e6b13e5eee | ||
|
|
f4def623bb | ||
|
|
3620505b56 | ||
|
|
e9355aaf92 | ||
|
|
943ec6af6d | ||
|
|
bb4b75c82e | ||
|
|
ae4488546c | ||
|
|
7661bc94c7 | ||
|
|
e8a9594ea1 |
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@@ -2,8 +2,11 @@ name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "*"
|
||||
- "v*.*.*"
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
|
||||
env:
|
||||
PLUGIN_NAME: share-to-notionnext # Change this to match the id of your plugin.
|
||||
|
||||
29
CHANGELOG.md
29
CHANGELOG.md
@@ -1,6 +1,32 @@
|
||||
# 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
|
||||
|
||||
@@ -12,6 +38,7 @@
|
||||
- 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
|
||||
- Added setting to customise the frontmatter key used for auto sync database lists (defaults to `autosync-database`)
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -22,6 +22,21 @@ In the plugin settings, you can add and configure the Notion databases you want
|
||||
- [3️⃣ Custom Database](#3️⃣-custom-database)
|
||||
- [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
|
||||
|
||||
This is the most basic database type and is suitable for most users.
|
||||
@@ -109,4 +124,4 @@ Relation and Rollup types are not supported yet.
|
||||
|
||||
## Finalizing Configuration
|
||||
|
||||
After configuring your database, make sure to save your settings. You can now start syncing your Obsidian notes to the configured Notion database by using the "Share to NotionNext" command from the command palette or the note context menu.
|
||||
After configuring your database, make sure to save your settings. You can now start syncing your Obsidian notes to the configured Notion database by using the "Share to NotionNext" command from the command palette or the note context menu.
|
||||
|
||||
@@ -22,17 +22,38 @@ The plugin supports automatic syncing that monitors your notes for changes and a
|
||||
3. Enable the toggle
|
||||
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
|
||||
|
||||
When auto sync is enabled:
|
||||
- The plugin monitors markdown files for changes
|
||||
- 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
|
||||
- After the first sync, a `NotionID-{database}` will be added to the frontmatter for future updates
|
||||
|
||||
### Auto Sync Scenarios
|
||||
|
||||
#### Scenario A: New Document (Not Yet Synced)
|
||||
#### Scenario A-1: New File Missing Auto Sync Entry
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -42,12 +63,12 @@ tags: [blog, tech]
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
- ✅ Detects no NotionID present
|
||||
- ✅ Shows notice: "⚠️ Auto sync skipped: This document has not been synced to Notion, please upload manually first"
|
||||
- ✅ No sync operation performed
|
||||
- 📝 **Action Required:** Manually sync the document first using the command palette
|
||||
- ✅ Detects that the auto sync key is missing
|
||||
- ✅ Detects no NotionID present (new file)
|
||||
- ✅ Silently skips - no notice shown
|
||||
- 📝 **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
|
||||
---
|
||||
@@ -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:**
|
||||
- ✅ Detects 1 NotionID
|
||||
- ✅ Automatically syncs to the Blog database
|
||||
- ✅ Shows success/failure notification from the upload command
|
||||
- 📝 **No Action Required:** Changes are automatically synced
|
||||
|
||||
#### Scenario C: Synced to Multiple Databases
|
||||
#### Scenario D: Synced to Multiple Databases
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -70,19 +124,35 @@ title: My Article
|
||||
NotionID-blog: abc123
|
||||
NotionID-portfolio: def456
|
||||
NotionID-notes: ghi789
|
||||
autosync-database: [blog, portfolio, notes]
|
||||
---
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
- ✅ Detects 3 NotionIDs
|
||||
- ✅ Detects 3 database targets
|
||||
- ✅ Shows notice: "🔄 Auto sync: Syncing to 3 database(s)..."
|
||||
- ✅ Syncs to all 3 databases sequentially
|
||||
- ✅ Shows individual result notifications for each database
|
||||
- 📝 **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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -6,3 +6,35 @@ description: Release notes and updates for Obsidian to NotionNext
|
||||
# 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.
|
||||
|
||||
## 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
|
||||
|
||||
@@ -22,18 +22,38 @@ description: 如何使用 NotionNext 插件将你的 Obsidian 笔记同步到 No
|
||||
3. 开启该开关
|
||||
4. 配置"自动同步延迟时间"(默认:5秒,最小:2秒)
|
||||
|
||||
### 准备 Frontmatter
|
||||
|
||||
自动同步会读取你在 **设置 → 自动同步 Frontmatter 键名** 中配置的键名(默认为 `autosync-database`)来确定要同步的数据库。要让你的笔记能够自动同步:
|
||||
|
||||
- 在笔记的 frontmatter 中添加配置的键名
|
||||
- 列出一个或多个你在插件设置中定义的数据库简称
|
||||
- 如果修改了笔记要同步的数据库,记得更新列表
|
||||
|
||||
示例(使用默认键名):
|
||||
|
||||
```yaml
|
||||
---
|
||||
title: 我的文章
|
||||
autosync-database: [blog, portfolio]
|
||||
---
|
||||
```
|
||||
|
||||
如果你在设置中修改了键名,记得同时更新你的 frontmatter。
|
||||
|
||||
### 自动同步工作原理
|
||||
|
||||
当自动同步启用后:
|
||||
|
||||
- 插件会监控 Markdown 文件的变化
|
||||
- 在你停止编辑达到配置的延迟时间后,自动触发同步
|
||||
- 只有已经同步过的文件(frontmatter 中有 NotionID)才会被自动同步
|
||||
- **支持首次自动上传**:无需先手动同步,只要添加 frontmatter 键名,插件会自动处理首次上传
|
||||
- 如果文件关联了多个数据库,会自动同步到所有数据库
|
||||
- 首次同步后,会自动在 frontmatter 中添加 `NotionID-{数据库}` 用于后续更新
|
||||
|
||||
### 自动同步场景示例
|
||||
|
||||
#### 场景 A:新文档(未同步)
|
||||
#### 场景 A-1:新文件缺少自动同步配置
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -44,12 +64,12 @@ tags: [博客, 技术]
|
||||
|
||||
**行为:**
|
||||
|
||||
- ✅ 检测到没有 NotionID
|
||||
- ✅ 显示提示:"⚠️ 自动同步跳过:此文档未同步到 Notion,请先手动上传"
|
||||
- ✅ 不执行同步操作
|
||||
- 📝 **需要操作:** 先使用命令面板手动同步文档
|
||||
- ✅ 检测到缺少自动同步配置键
|
||||
- ✅ 检测到没有 NotionID(新文件)
|
||||
- ✅ 静默跳过,不显示任何提示
|
||||
- 📝 **如需启用自动同步:** 在 frontmatter 中添加 `autosync-database: [你的数据库简称]`
|
||||
|
||||
#### 场景 B:已同步到一个数据库
|
||||
#### 场景 A-2:已同步文件缺少自动同步配置
|
||||
|
||||
```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
|
||||
- ✅ 自动同步到 Blog 数据库
|
||||
- ✅ 自动同步更新到 Blog 数据库
|
||||
- ✅ 显示上传命令返回的成功/失败通知
|
||||
- 📝 **无需操作:** 变更会自动同步
|
||||
|
||||
#### 场景 C:同步到多个数据库
|
||||
#### 场景 D:同步到多个数据库
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -73,12 +128,13 @@ title: 我的文章
|
||||
NotionID-blog: abc123
|
||||
NotionID-portfolio: def456
|
||||
NotionID-notes: ghi789
|
||||
autosync-database: [blog, portfolio, notes]
|
||||
---
|
||||
```
|
||||
|
||||
**行为:**
|
||||
|
||||
- ✅ 检测到 3 个 NotionID
|
||||
- ✅ 检测到 3 个数据库目标
|
||||
- ✅ 显示提示:"🔄 自动同步:正在同步到 3 个数据库..."
|
||||
- ✅ 依次同步到所有 3 个数据库
|
||||
- ✅ 为每个数据库显示独立的结果通知
|
||||
@@ -86,7 +142,7 @@ NotionID-notes: ghi789
|
||||
|
||||
### 自动同步最佳实践
|
||||
|
||||
1. **首次手动同步**:始终先手动执行第一次同步以建立 NotionID 链接
|
||||
1. **添加 Frontmatter 配置**:只需添加 `autosync-database: [你的数据库]` 即可启用自动同步,无需手动上传
|
||||
2. **合理配置延迟**:如果你经常编辑,设置较长的延迟时间(5-10 秒)
|
||||
3. **监控同步状态**:注意查看通知以确保同步成功完成
|
||||
4. **查看日志**:打开开发者控制台(Ctrl+Shift+I / Cmd+Option+I)查看详细的同步日志
|
||||
|
||||
@@ -1,96 +1,101 @@
|
||||
export const en = {
|
||||
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",
|
||||
databaseGeneral: "General",
|
||||
databaseCustom: "Custom",
|
||||
databaseFullName: "Database Full Name",
|
||||
databaseFullNameDesc: "Please give a full name for your database",
|
||||
databaseFullNameText: "Enter your database full name",
|
||||
databaseAbbreviateName: "Database Abbreviate Name",
|
||||
databaseAbbreviateNameDesc: "Please give a nick name for your database",
|
||||
databaseAbbreviateNameText: "Enter your database nick name",
|
||||
ribbonIcon: "Share to NotionNext",
|
||||
GeneralSetting: "General information Settings",
|
||||
databaseFullNameDesc: "Set a full name for your database.",
|
||||
databaseFullNameText: "Enter your database's full name",
|
||||
databaseAbbreviateName: "Abbreviated Name",
|
||||
databaseAbbreviateNameDesc: "Set a shorter, abbreviated name for your database.",
|
||||
databaseAbbreviateNameText: "Enter your database's abbreviated name",
|
||||
ribbonIcon: "Sync to NotionNext",
|
||||
GeneralSetting: "General Settings",
|
||||
CommandID: "share-to-notionnext",
|
||||
CommandName: "Share to NotionNext Database",
|
||||
CommandName: "Sync to NotionNext",
|
||||
CommandIDGeneral: "share-to-notion",
|
||||
CommandNameGeneral: "Share to Notion General Database",
|
||||
CommandNameGeneral: "Sync to General Database",
|
||||
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",
|
||||
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",
|
||||
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",
|
||||
BannerUrl: "Banner url (optional)",
|
||||
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)",
|
||||
BannerUrlText: "Enter your banner url",
|
||||
NotionUser: "Notion ID (username, optional)",
|
||||
"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",
|
||||
NotionUser: "Notion Username (optional)",
|
||||
NotionUserDesc:
|
||||
"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",
|
||||
"If your site is username.notion.site, your username is [username].",
|
||||
NotionUserText: "Enter your Notion username",
|
||||
NotionLinkDisplay: "Display Notion Link",
|
||||
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",
|
||||
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)",
|
||||
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",
|
||||
NotionGeneralSettingHeader: "General Notion Database Settings",
|
||||
NotionGeneralButton: "Notion General Sync",
|
||||
NotionGeneralButtonDesc: "Open this option, Sync to Notion General Database command will be displayed in the command palette (default: ON)",
|
||||
NotionTagButton: "Notion Tags Sync",
|
||||
NotionTagButtonDesc: "Sync Tags to Notion General Database (default: ON)",
|
||||
NotionCustomTitle: "Customise title property",
|
||||
NotionCustomTitleDesc: "Modify the column name of the Notion database (default: OFF)",
|
||||
NotionCustomTitleName: "Preferred title name",
|
||||
NotionCustomTitleNameDesc: "Enter the preferred title name for the first column of the Notion database (default: title)",
|
||||
NotionCustomTitleText: "Enter the name",
|
||||
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",
|
||||
PlaceHolder: "Enter database Name",
|
||||
"notion-logo": "Share to NotionNext",
|
||||
"sync-preffix": "Sync to ",
|
||||
"sync-success": "success",
|
||||
"sync-fail": "failed",
|
||||
"open-notion": "Please open the file that needs to be synchronized",
|
||||
NotionGeneralButton: "General Database Sync",
|
||||
NotionGeneralButtonDesc: "Enables the 'Sync to General Database' command in the command palette (default: on).",
|
||||
NotionTagButton: "Sync Tags",
|
||||
NotionTagButtonDesc: "Sync Obsidian tags to the Notion database (default: on).",
|
||||
NotionCustomTitle: "Custom Title Property",
|
||||
NotionCustomTitleDesc: "Customize the title property's name in your Notion database (default: off).",
|
||||
NotionCustomTitleName: "Custom Title Property Name",
|
||||
NotionCustomTitleNameDesc: "Enter the custom name for the title property of your Notion database (default: 'title').",
|
||||
NotionCustomTitleText: "Enter the property name",
|
||||
NotionCustomValues: "Custom Properties",
|
||||
NotionCustomValuesDesc: "Define custom properties to sync to your Notion database, one per line.",
|
||||
NotionCustomValuesText: "Enter all properties you want to sync",
|
||||
NotYetFinish: "This feature will be available in a future version.",
|
||||
PlaceHolder: "Enter database name",
|
||||
"notion-logo": "Sync to NotionNext",
|
||||
"sync-preffix": "📄",
|
||||
"sync-success": "Successfully synced to NotionNext:\n",
|
||||
"sync-fail": "Failed to sync to NotionNext:\n",
|
||||
"open-notion": "Please open a file to sync first.",
|
||||
"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":
|
||||
"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,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:
|
||||
"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":
|
||||
"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",
|
||||
NotionCustomButton: "Notion Customised command switch",
|
||||
NotionCustomButtonDesc: "Open this option, Sync to Notion Customised Database command will be displayed in the command palette",
|
||||
NotionCustomButton: "Enable Custom Database Command",
|
||||
NotionCustomButtonDesc: "If enabled, the 'Sync to Custom Database' command appears in the command palette.",
|
||||
CustomPropertyName: "Property Name",
|
||||
CustomPropertyFirstColumn: "Title Column",
|
||||
CustomPropertyFirstColumnDesc: "The title of the page, must be the first property",
|
||||
CustomPropertyFirstColumn: "Title Property Name",
|
||||
CustomPropertyFirstColumnDesc: "The page title. This must be the first property in the list.",
|
||||
CustomProperty: "Property",
|
||||
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",
|
||||
BlockUploaded: "All blocks uploaded",
|
||||
ExtraBlockUploaded: "Extra blocks uploaded",
|
||||
CheckConsole: "Check the console for more information \n opt+cmd+i/ctrl+shift+i",
|
||||
SettingsMigrated: "✨ Plugin settings updated! Auto sync feature added, check plugin settings",
|
||||
AutoSyncNoNotionID: "⚠️ Auto sync skipped: This document has not been synced to Notion, please upload manually first",
|
||||
AutoSyncMultipleSync: "🔄 Auto sync: Syncing to {count} database(s)...",
|
||||
AutoSyncFailed: "Auto sync to {database} failed: {error}",
|
||||
AutoSyncError: "Auto sync failed for {filename}: {error}",
|
||||
"reach-mobile-limit": "The number of blocks exceeds the limit of 100, please use the desktop plugin",
|
||||
StartUpload: "Start upload {filename}",
|
||||
AddNewPropertyDesc: "Add a new property that matches a property in your Notion database.",
|
||||
CopyErrorMessage: "Auto-copy failed. Please copy the link manually.",
|
||||
BlockUploaded: "All content blocks uploaded successfully.",
|
||||
ExtraBlockUploaded: "Additional blocks uploaded successfully.",
|
||||
CheckConsole: "For more details, open the developer console (opt+cmd+i or ctrl+shift+i).",
|
||||
SettingsMigrated: "✨ Settings updated! Auto-Sync is now available. Check the settings to learn more.",
|
||||
AutoSyncNoNotionID: "🆕 Auto-sync: First upload to Notion",
|
||||
AutoSyncMissingDatabaseList: "⚠️ Auto-sync skipped: Add `{key}: [database_name]` to your frontmatter to specify target databases.",
|
||||
AutoSyncMultipleSync: "🔄 Auto-sync: Syncing to {count} database(s)...",
|
||||
AutoSyncFailed: "Auto-sync to {database} failed: {error}",
|
||||
AutoSyncError: "Auto-sync for {filename} failed: {error}",
|
||||
"reach-mobile-limit": "Block limit (100) reached. For unlimited blocks, please use the desktop version.",
|
||||
StartUpload: "Starting upload for {filename}...",
|
||||
AddNewDatabase: "Add New Database",
|
||||
AddNewDatabaseDesc: "Add a new database configuration",
|
||||
AddNewDatabaseTooltip: "Add New Database",
|
||||
@@ -98,14 +103,14 @@ export const en = {
|
||||
Preview: "Preview",
|
||||
DatabaseFormatLabel: "Database Format",
|
||||
DatabaseFullNameLabel: "Database Full Name",
|
||||
DatabaseAbbreviateNameLabel: "Database Abbreviate Name",
|
||||
DatabaseAbbreviateNameLabel: "Abbreviated Name",
|
||||
NotionAPILabel: "Notion API Key",
|
||||
DatabaseIDLabel: "Database ID",
|
||||
ToggleAPIKeyVisibility: "Toggle API Key Visibility",
|
||||
CopyAPIKey: "Copy API Key",
|
||||
APIKeyCopied: "API Key copied to clipboard",
|
||||
APIKeyCopied: "API key copied to clipboard.",
|
||||
ToggleDatabaseIDVisibility: "Toggle Database ID Visibility",
|
||||
CopyDatabaseID: "Copy Database ID",
|
||||
DatabaseIDCopied: "Database ID copied to clipboard",
|
||||
AddNewDatabaseModal: "Add new database",
|
||||
DatabaseIDCopied: "Database ID copied to clipboard.",
|
||||
AddNewDatabaseModal: "Add New Database",
|
||||
}
|
||||
|
||||
@@ -1,88 +1,94 @@
|
||||
export const ja = {
|
||||
databaseFormat: "データベース形式",
|
||||
databaseFormatDesc: "同期したいデータベース形式を選択してください",
|
||||
databaseFormatDesc: "同期先のデータベース形式を選択してください(NotionNext または 一般)。",
|
||||
databaseNext: "NotionNext",
|
||||
databaseGeneral: "一般的なNotion",
|
||||
databaseGeneral: "一般",
|
||||
databaseCustom: "カスタム",
|
||||
databaseFullName: "データベースの全称",
|
||||
databaseFullNameDesc: "データベースの全称を入力してください",
|
||||
databaseFullNameDesc: "データベースのフルネームを設定します。",
|
||||
databaseFullNameText: "データベースの全称を入力",
|
||||
databaseAbbreviateName: "データベースの略称",
|
||||
databaseAbbreviateNameDesc: "データベースの略称を入力してください",
|
||||
databaseAbbreviateNameDesc: "データベースの略称を設定します。",
|
||||
databaseAbbreviateNameText: "データベースの略称を入力",
|
||||
ribbonIcon: "NotionNextで共有",
|
||||
GeneralSetting: "一般設定",
|
||||
CommandID: "share-to-notionnext",
|
||||
CommandName: "NotionNextデータベースに共有",
|
||||
CommandIDGeneral: "share-to-notion",
|
||||
CommandNameGeneral: "一般的なNotionデータベースに共有",
|
||||
NotionNextButton: "NotionNext同期",
|
||||
NotionNextButtonDesc: "このオプションを開くと、NotionNext同期コマンドがコマンドパレットに表示されます(デフォルト:ON)",
|
||||
NotionNextSettingHeader: "NotionNextデータベース設定",
|
||||
NotionAPI: "Notion API トークン",
|
||||
NotionAPIDesc: "https://www.notion.so/my-integrations から生成してください",
|
||||
NotionAPIText: "Notion API トークンを入力",
|
||||
DatabaseID: "データベースID",
|
||||
DatabaseIDDesc: "右上の共有 --> 公開から取得してください",
|
||||
DatabaseIDText: "データベースIDを入力",
|
||||
BannerUrl: "バナーのURL(任意)",
|
||||
BannerUrlDesc: "デフォルトは空白です。バナーを表示したい場合は、URLを入力してください(例:https://abc.com/b.png)",
|
||||
BannerUrlText: "バナーのURLを入力",
|
||||
NotionUser: "Notion ID(ユーザー名、任意)",
|
||||
NotionUserDesc: "共有リンクから取得(例:https://username.notion.site)。Notion IDは[username]です",
|
||||
NotionUserText: "Notion IDを入力",
|
||||
ribbonIcon: "NotionNextへ同期",
|
||||
GeneralSetting: "一般設定",
|
||||
CommandID: "share-to-notionnext",
|
||||
CommandName: "NotionNextへ同期",
|
||||
CommandIDGeneral: "share-to-notion",
|
||||
CommandNameGeneral: "一般データベースへ同期",
|
||||
NotionNextButton: "NotionNext同期",
|
||||
NotionNextButtonDesc: "有効にすると、コマンドパレットに「NotionNextへ同期」が表示されます(デフォルト:オン)。",
|
||||
NotionNextSettingHeader: "NotionNextデータベース設定",
|
||||
NotionAPI: "Notion API トークン",
|
||||
NotionAPIDesc: "notion.so/my-integrations から取得します。",
|
||||
NotionAPIText: "Notion API トークンを入力",
|
||||
DatabaseID: "データベースID",
|
||||
DatabaseIDDesc: "Notionページの右上「共有」メニューから取得します。",
|
||||
DatabaseIDText: "データベースIDを入力",
|
||||
BannerUrl: "バナーURL(任意)",
|
||||
BannerUrlDesc: "空のままにするとバナーは表示されません。表示するには画像のURLを入力してください(例:https://abc.com/b.png)。",
|
||||
BannerUrlText: "バナーのURLを入力",
|
||||
NotionUser: "Notionユーザー名(任意)",
|
||||
NotionUserDesc: "共有リンクが `username.notion.site` の場合、Notionユーザー名は `[username]` です。",
|
||||
NotionUserText: "Notionユーザー名を入力",
|
||||
NotionLinkDisplay: "Notionリンク表示",
|
||||
NotionLinkDisplayDesc: "デフォルトはONです。front matterにリンクを非表示にしたい場合は、オフにしてください",
|
||||
NotionLinkDisplayDesc: "デフォルトで有効。無効にすると、同期後にfront matterへNotionリンクが追加されません。",
|
||||
AutoCopyNotionLink: "Notionリンクを自動コピー",
|
||||
AutoCopyNotionLinkDesc: "同期完了後、Notionページのリンクをクリップボードに自動コピーします(デフォルト:オン)。",
|
||||
AutoSync: "自動同期",
|
||||
AutoSyncDesc: "frontmatter またはコンテンツが変更されたときに自動的に Notion に同期します(NotionID が必要)",
|
||||
AutoSyncDelay: "自動同期遅延時間(秒)",
|
||||
AutoSyncDelayDesc: "ドキュメントの変更後、自動同期をトリガーするまでの待機時間(デフォルト:5秒、最小:2秒)",
|
||||
AutoSyncDesc: "ファイルの内容(frontmatterまたは本文)が変更されると、自動でNotionに同期します。新規作成と更新の両方に対応。",
|
||||
AutoSyncFrontmatterKey: "自動同期 frontmatter キー",
|
||||
AutoSyncFrontmatterKeyDesc: "自動同期の対象となるデータベースをリストアップするための frontmatterキーを設定します(デフォルト:autosync-database)。",
|
||||
AutoSyncDelay: "自動同期の遅延(秒)",
|
||||
AutoSyncDelayDesc: "変更が検知されてから同期を開始するまでの遅延時間(秒)。同期の頻発を防ぎます(デフォルト:5秒、最小:2秒)。",
|
||||
AutoSyncDelayText: "遅延秒数を入力",
|
||||
NotionGeneralSettingHeader: "一般的なNotionデータベース設定",
|
||||
NotionGeneralButton: "一般的なNotion同期",
|
||||
NotionGeneralButtonDesc: "このオプションを開くと、一般的なNotionデータベース同期コマンドがコマンドパレットに表示されます(デフォルト:ON)",
|
||||
NotionTagButton: "Notionタグ同期",
|
||||
NotionTagButtonDesc: "タグを一般的なNotionデータベースに同期(デフォルト:ON)",
|
||||
NotionCustomTitle: "タイトルのカスタマイズ",
|
||||
NotionCustomTitleDesc: "Notionデータベースの列名を変更(デフォルト:OFF)",
|
||||
NotionCustomTitleName: "希望のタイトル名",
|
||||
NotionCustomTitleNameDesc: "Notionデータベースの最初の列のための希望のタイトル名を入力(デフォルト:title)",
|
||||
NotionCustomTitleText: "名前を入力",
|
||||
NotionCustomValues: "値のカスタマイズ",
|
||||
NotionCustomValuesDesc: "Notionデータベースの列名を変更、1行に1つ",
|
||||
NotionCustomValuesText: "同期したいすべてのプロパティを入力",
|
||||
NotYetFinish: "未完了。この機能は次のバージョンで利用可能になります",
|
||||
PlaceHolder: "データベース名を入力",
|
||||
"notion-logo": "NotionNextで共有",
|
||||
"sync-success": "NotionNextへの同期に成功:\n",
|
||||
"sync-fail": "NotionNextへの同期に失敗:\n",
|
||||
"open-notion": "同期が必要なファイルを開いてください",
|
||||
"config-secrets-notion-api": "設定タブでNotion APIを設定してください",
|
||||
"config-secrets-database-id": "設定タブでデータベースIDを設定してください",
|
||||
"set-tags-fail": "タグの設定に失敗。ファイルのfrontmatterを確認するか、設定タブでタグのスイッチをオフにしてください",
|
||||
NNonMissing: "設定に 'NNon' プロパティがありません。設定してください",
|
||||
"set-api-id": "設定タブでNotion APIおよびデータベースIDを設定してください",
|
||||
NotionCustomSettingHeader: "Notionカスタムデータベース設定",
|
||||
NotionCustomButton: "Notionカスタマイズコマンドの切り替え",
|
||||
NotionCustomButtonDesc: "このオプションを開くと、Notionカスタムデータベース同期コマンドがコマンドパレットに表示されます",
|
||||
CustomPropertyName: "カスタムプロパティ名",
|
||||
CustomPropertyFirstColumn: "最初の列のカスタムプロパティ名",
|
||||
CustomPropertyFirstColumnDesc: "最初の列のカスタムプロパティ名を入力してください",
|
||||
CustomProperty: "カスタムプロパティ",
|
||||
NotionGeneralSettingHeader: "一般Notionデータベース設定",
|
||||
NotionGeneralButton: "一般データベース同期",
|
||||
NotionGeneralButtonDesc: "有効にすると、コマンドパレットに「一般データベースへ同期」が表示されます(デフォルト:オン)。",
|
||||
NotionTagButton: "タグを同期",
|
||||
NotionTagButtonDesc: "ObsidianのタグをNotionデータベースに同期します(デフォルト:オン)。",
|
||||
NotionCustomTitle: "タイトルプロパティをカスタム",
|
||||
NotionCustomTitleDesc: "Notionデータベースのタイトル列の名前をカスタマイズします(デフォルト:オフ)。",
|
||||
NotionCustomTitleName: "カスタムタイトル名",
|
||||
NotionCustomTitleNameDesc: "Notionデータベースのタイトル列に使用するカスタム名を入力してください(デフォルト:「title」)。",
|
||||
NotionCustomTitleText: "プロパティ名を入力",
|
||||
NotionCustomValues: "カスタムプロパティ",
|
||||
NotionCustomValuesDesc: "Notionデータベースに同期するカスタムプロパティを1行に1つずつ定義します。",
|
||||
NotionCustomValuesText: "同期したいすべてのプロパティを入力",
|
||||
NotYetFinish: "この機能は将来のバージョンで利用可能になります。",
|
||||
PlaceHolder: "データベース名を入力",
|
||||
"notion-logo": "NotionNextへ同期",
|
||||
"sync-preffix": "📄",
|
||||
"sync-success": "NotionNextへの同期が成功しました。\n",
|
||||
"sync-fail": "NotionNextへの同期に失敗しました。\n",
|
||||
"open-notion": "同期するファイルを先に開いてください。",
|
||||
"config-secrets-notion-api": "プラグイン設定でNotion APIキーを設定してください。",
|
||||
"config-secrets-database-id": "プラグイン設定でデータベースIDを設定してください。",
|
||||
"set-tags-fail": "タグの設定に失敗しました。frontmatterを確認するか、設定でタグ同期を無効にしてください。",
|
||||
NNonMissing: "'NNon'プロパティが設定されていません。設定でNotionNextデータベースを選択してください。",
|
||||
"set-api-id": "プラグイン設定でNotion APIキーとデータベースIDを設定してください。",
|
||||
NotionCustomSettingHeader: "Notionカスタムデータベース設定",
|
||||
NotionCustomButton: "カスタムデータベースコマンドを有効化",
|
||||
NotionCustomButtonDesc: "有効にすると、「カスタムデータベースへ同期」コマンドがコマンドパレットに表示されます。",
|
||||
CustomPropertyName: "プロパティ名",
|
||||
CustomPropertyFirstColumn: "タイトルプロパティ名",
|
||||
CustomPropertyFirstColumnDesc: "ページのタイトル。これはリストの最初のプロパティである必要があります。",
|
||||
CustomProperty: "プロパティ",
|
||||
AddCustomProperty: "カスタムプロパティを追加",
|
||||
AddNewProperty: "新しいプロパティを追加",
|
||||
AddNewPropertyDesc: "新しいプロパティを追加してください",
|
||||
CopyErrorMessage: "自動コピーに失敗しました",
|
||||
BlockUploaded: "ブロックがアップロードされました",
|
||||
ExtraBlockUploaded: "追加ブロックがアップロードされました",
|
||||
CheckConsole: "詳細情報を確認するには、コンソールを開いてください \n opt+cmd+i/ctrl+shift+i",
|
||||
SettingsMigrated: "✨ プラグイン設定が更新されました!自動同期機能が追加されました。設定を確認してください",
|
||||
AutoSyncNoNotionID: "⚠️ 自動同期をスキップ:このドキュメントは Notion に同期されていません。まず手動でアップロードしてください",
|
||||
AutoSyncMultipleSync: "🔄 自動同期:{count} 個のデータベースに同期中...",
|
||||
AutoSyncFailed: "{database} への自動同期に失敗しました:{error}",
|
||||
AutoSyncError: "{filename} の自動同期に失敗しました:{error}",
|
||||
"reach-mobile-limit": "ブロック数が100の制限を超えています。デスクトップ版プラグインを使用してください",
|
||||
StartUpload: "アップロード開始 {filename}",
|
||||
AddNewPropertyDesc: "Notionデータベースのプロパティと一致する新しいプロパティを追加します。",
|
||||
CopyErrorMessage: "リンクの自動コピーに失敗しました。手動でコピーしてください。",
|
||||
BlockUploaded: "すべてのブロックをアップロードしました",
|
||||
ExtraBlockUploaded: "追加のブロックをアップロードしました",
|
||||
CheckConsole: "詳細は、開発者コンソール(opt+cmd+i または ctrl+shift+i)で確認できます。",
|
||||
SettingsMigrated: "✨ 設定が更新されました!自動同期が利用可能です。詳細は設定画面をご確認ください。",
|
||||
AutoSyncNoNotionID: "🆕 自動同期:Notionへ初めてアップロードします",
|
||||
AutoSyncMissingDatabaseList: "⚠️ 自動同期をスキップ:frontmatterに `{key}: [データベース名]` を追加して同期先を指定してください。",
|
||||
AutoSyncMultipleSync: "🔄 自動同期:{count}個のデータベースに同期しています...",
|
||||
AutoSyncFailed: "{database}への自動同期に失敗しました:{error}",
|
||||
AutoSyncError: "{filename}の自動同期に失敗しました:{error}",
|
||||
"reach-mobile-limit": "ブロック上限(100)に達しました。ブロック数に制限のないデスクトップ版をご利用ください。",
|
||||
StartUpload: "{filename} のアップロードを開始します...",
|
||||
AddNewDatabase: "新しいデータベースを追加",
|
||||
AddNewDatabaseDesc: "新しいデータベース構成を追加",
|
||||
AddNewDatabaseTooltip: "新しいデータベースを追加",
|
||||
@@ -95,9 +101,9 @@ export const ja = {
|
||||
DatabaseIDLabel: "データベース ID",
|
||||
ToggleAPIKeyVisibility: "API キーの表示を切り替え",
|
||||
CopyAPIKey: "API キーをコピー",
|
||||
APIKeyCopied: "API キーをクリップボードにコピーしました",
|
||||
APIKeyCopied: "APIキーをクリップボードにコピーしました。",
|
||||
ToggleDatabaseIDVisibility: "データベース ID の表示を切り替え",
|
||||
CopyDatabaseID: "データベース ID をコピー",
|
||||
DatabaseIDCopied: "データベース ID をクリップボードにコピーしました",
|
||||
DatabaseIDCopied: "データベースIDをクリップボードにコピーしました。",
|
||||
AddNewDatabaseModal: "新しいデータベースを追加",
|
||||
};
|
||||
|
||||
@@ -1,105 +1,111 @@
|
||||
export const zh = {
|
||||
databaseFormat: "数据库格式",
|
||||
databaseFormatDesc: "选择你想要同步的数据库格式Next 或者 普通",
|
||||
databaseFormatDesc: "选择同步的目标数据库格式:NotionNext 或 通用",
|
||||
databaseNext: "NotionNext",
|
||||
databaseGeneral: "普通",
|
||||
databaseGeneral: "通用",
|
||||
databaseCustom: "自定义",
|
||||
databaseFullName: "数据库全称",
|
||||
databaseFullNameDesc: "给你的数据库起一个全称",
|
||||
databaseFullNameText: "输入你的数据库全称",
|
||||
databaseFullName: "数据库全名",
|
||||
databaseFullNameDesc: "为数据库设置一个全名",
|
||||
databaseFullNameText: "输入您的数据库全名",
|
||||
databaseAbbreviateName: "数据库简称",
|
||||
databaseAbbreviateNameDesc: "给你的数据库起一个简称",
|
||||
databaseAbbreviateNameText: "输入你的数据库简称",
|
||||
ribbonIcon: "分享到 NotionNext",
|
||||
databaseAbbreviateNameDesc: "为数据库设置一个简称",
|
||||
databaseAbbreviateNameText: "输入您的数据库简称",
|
||||
ribbonIcon: "同步到 NotionNext",
|
||||
GeneralSetting: "通用设置",
|
||||
CommandID: "share-to-notionnext",
|
||||
CommandName: "分享到 NotionNext",
|
||||
CommandName: "同步到 NotionNext",
|
||||
CommandIDGeneral: "share-to-notion",
|
||||
CommandNameGeneral: "分享到 Notion 普通数据库",
|
||||
CommandNameGeneral: "同步到通用数据库",
|
||||
NotionNextButton: "NotionNext 同步",
|
||||
NotionNextButtonDesc: "打开此选项,NotionNext 同步将显示在命令面板中(默认:开)",
|
||||
NotionNextSettingHeader: "NotionNext 数据库参数设置",
|
||||
NotionNextButtonDesc: "启用后,命令面板中将显示“同步到 NotionNext”命令(默认开启)",
|
||||
NotionNextSettingHeader: "NotionNext 数据库设置",
|
||||
NotionAPI: "Notion API 令牌",
|
||||
NotionAPIDesc: "从 https://www.notion.so/my-integrations 生成",
|
||||
NotionAPIText: "输入你的 Notion API 令牌",
|
||||
NotionAPIDesc: "从 notion.so/my-integrations 获取",
|
||||
NotionAPIText: "输入您的 Notion API 令牌",
|
||||
DatabaseID: "数据库 ID",
|
||||
DatabaseIDDesc: "从右上角的分享 --> 发布中获取",
|
||||
DatabaseIDText: "输入你的数据库 ID",
|
||||
DatabaseIDDesc: "可从 Notion 页面右上角的“分享”菜单中获取",
|
||||
DatabaseIDText: "输入您的数据库 ID",
|
||||
BannerUrl: "封面图片地址(可选)",
|
||||
BannerUrlDesc:
|
||||
"默认为空,如果你想显示封面图片,请输入图片地址(例如:https://abc.com/b.png)",
|
||||
BannerUrlText: "输入你的封面图片地址",
|
||||
NotionUser: "Notion ID(用户名,可选)",
|
||||
"留空则不显示。如需封面,请输入图片地址(例如:https://abc.com/b.png)",
|
||||
BannerUrlText: "输入您的封面图片地址",
|
||||
NotionUser: "Notion 用户名(可选)",
|
||||
NotionUserDesc:
|
||||
"数据库分享链接类似:https://username.notion.site/。你的 Notion ID 是 [username]",
|
||||
NotionUserText: "输入你的 Notion ID",
|
||||
NotionLinkDisplay: "Notion 链接显示",
|
||||
NotionLinkDisplayDesc: "默认开启,如果你不想在front matter中显示链接,请关闭",
|
||||
"若分享链接为 username.notion.site,你的 Notion 用户名即为 [username]",
|
||||
NotionUserText: "输入您的 Notion 用户名",
|
||||
NotionLinkDisplay: "显示 Notion 链接",
|
||||
NotionLinkDisplayDesc: "默认开启。关闭后,同步成功时 frontmatter 中不会出现 Notion 链接",
|
||||
AutoCopyNotionLink: "自动复制 Notion 链接",
|
||||
AutoCopyNotionLinkDesc: "同步后自动将 Notion 链接复制到剪贴板(默认开启)",
|
||||
AutoSync: "自动同步",
|
||||
AutoSyncDesc: "当检测到文档的 frontmatter 或内容发生修改时,自动同步到 Notion(需要文档已有 NotionID)",
|
||||
AutoSyncDelay: "自动同步延迟时间(秒)",
|
||||
AutoSyncDelayDesc: "文档修改后等待多少秒才触发自动同步,避免频繁同步(默认:5秒,最小:2秒)",
|
||||
AutoSyncDesc: "当文档的 frontmatter 或内容修改时,将自动同步到 Notion(支持新建和更新)",
|
||||
AutoSyncFrontmatterKey: "自动同步 Frontmatter 键名",
|
||||
AutoSyncFrontmatterKeyDesc: "设置用于指定自动同步数据库列表的 frontmatter 键名(默认为 autosync-database)。",
|
||||
AutoSyncDelay: "自动同步延迟(秒)",
|
||||
AutoSyncDelayDesc: "文档修改后,等待指定秒数再触发自动同步,以避免频繁操作(默认 5 秒,最少 2 秒)",
|
||||
AutoSyncDelayText: "输入延迟秒数",
|
||||
NotionGeneralSettingHeader: "普通 Notion 数据库设置",
|
||||
NotionGeneralButton: "普通数据库同步",
|
||||
NotionGeneralButtonDesc: "打开此选项,同步到普通数据库命令将显示在命令面板中(默认:开)",
|
||||
NotionTagButton: "标签同步开关",
|
||||
NotionTagButtonDesc: "将标签同步到普通数据库(默认:开)",
|
||||
NotionCustomTitle: "修改 Notion 数据库表头开关",
|
||||
NotionCustomTitleDesc: "自定义Notion 数据库第一列表头名(默认:关)",
|
||||
NotionCustomTitleName: "想要修改的表头名",
|
||||
NotionCustomTitleNameDesc: "输入你想要修改的notion数据库的表头名(默认:title)",
|
||||
NotionCustomTitleText: "输入表头名",
|
||||
NotionCustomValues: "自定义Notion 数据库表头",
|
||||
NotionCustomValuesDesc: "自定义Notion 数据库表头,每行一个",
|
||||
NotionCustomValuesText: "输入你想要同步的所有属性",
|
||||
NotYetFinish: "未完成。此功能将在之后版本中提供",
|
||||
NotionGeneralSettingHeader: "通用 Notion 数据库设置",
|
||||
NotionGeneralButton: "通用数据库同步",
|
||||
NotionGeneralButtonDesc: "启用后,命令面板中将显示“同步到通用数据库”命令(默认开启)",
|
||||
NotionTagButton: "标签同步",
|
||||
NotionTagButtonDesc: "将 Obsidian 标签同步到 Notion 数据库(默认开启)",
|
||||
NotionCustomTitle: "自定义标题属性",
|
||||
NotionCustomTitleDesc: "自定义 Notion 数据库中标题列的名称(默认关闭)",
|
||||
NotionCustomTitleName: "自定义标题名称",
|
||||
NotionCustomTitleNameDesc: "为 Notion 数据库的标题列设置一个自定义名称(默认为 title)",
|
||||
NotionCustomTitleText: "输入标题名称",
|
||||
NotionCustomValues: "自定义属性",
|
||||
NotionCustomValuesDesc: "自定义同步到 Notion 数据库的属性,每行一个。",
|
||||
NotionCustomValuesText: "输入所有你希望同步的属性",
|
||||
NotYetFinish: "此功能将在未来版本中提供",
|
||||
PlaceHolder: "输入数据库名称",
|
||||
"notion-logo": "分享到NotionNext",
|
||||
"sync-success": "同步到NotionNext成功:\n",
|
||||
"sync-fail": "同步到NotionNext失败: \n",
|
||||
"open-file": "请打开需要同步的文件",
|
||||
"config-secrets-notion-api": "请在插件设置中添加notion API",
|
||||
"config-secrets-database-id": "请在插件设置中添加database id",
|
||||
"notion-logo": "同步到 NotionNext",
|
||||
"sync-preffix": "📄",
|
||||
"sync-success": "成功同步到 NotionNext:\n",
|
||||
"sync-fail": "同步到 NotionNext 失败:\n",
|
||||
"open-file": "请先打开要同步的文件。",
|
||||
"config-secrets-notion-api": "请在插件设置中配置 Notion API 密钥。",
|
||||
"config-secrets-database-id": "请在插件设置中配置数据库 ID。",
|
||||
"set-tags-fail":
|
||||
"设置标签失败,请检查文件的frontmatter,或者在插件设置中关闭设置tags开关",
|
||||
NNonMissing: "未设置'NNon'属性,请在插件设置中选择NotionNext数据库。",
|
||||
"set-api-id": "请在插件设置中设置notion API和database ID",
|
||||
"标签设置失败,请检查 frontmatter 或在设置中关闭标签同步。",
|
||||
NNonMissing: "未设置 'NNon' 属性,请在插件设置中选择一个 NotionNext 数据库。",
|
||||
"set-api-id": "请在插件设置中配置 Notion API 和数据库 ID。",
|
||||
NotionCustomSettingHeader: "Notion 自定义数据库设置",
|
||||
NotionCustomButton: "Notion 自定义数据库同步命令开关",
|
||||
NotionCustomButtonDesc: "打开此选项,同步到自定义数据库命令将显示在命令面板中",
|
||||
NotionCustomButton: "启用自定义数据库同步命令",
|
||||
NotionCustomButtonDesc: "启用后,“同步到自定义数据库”的命令将出现在命令面板中。",
|
||||
CustomPropertyName: "自定义属性名",
|
||||
CustomPropertyFirstColumn: "第一列属性名",
|
||||
CustomPropertyFirstColumnDesc: "第一列必须为标题属性名",
|
||||
CustomPropertyFirstColumn: "标题属性",
|
||||
CustomPropertyFirstColumnDesc: "第一列必须为标题属性。",
|
||||
CustomProperty: "自定义属性",
|
||||
AddCustomProperty: "添加自定义属性",
|
||||
AddNewProperty: "添加新属性",
|
||||
AddNewPropertyDesc: "添加一个和Notion数据库匹配的新属性",
|
||||
CopyErrorMessage: "复制链接失败,请手动复制",
|
||||
BlockUploaded: "所有内容已成功上传",
|
||||
ExtraBlockUploaded: "额外内容已成功上传",
|
||||
CheckConsole: "opt+cmd+i/ctrl+shift+i,\n打开控制台查看更多信息",
|
||||
SettingsMigrated: "✨ 插件设置已更新!新增自动同步功能,请在设置中查看",
|
||||
AutoSyncNoNotionID: "⚠️ 自动同步跳过:此文档未同步到 Notion,请先手动上传",
|
||||
AddNewPropertyDesc: "添加一个与您 Notion 数据库中的属性相匹配的新属性。",
|
||||
CopyErrorMessage: "自动复制链接失败,请手动复制。",
|
||||
BlockUploaded: "所有块已上传成功",
|
||||
ExtraBlockUploaded: "额外块已上传成功",
|
||||
CheckConsole: "按 opt+cmd+i / ctrl+shift+i 打开控制台查看详情。",
|
||||
SettingsMigrated: "✨ 插件设置已更新!新增自动同步功能,详情请查看设置。",
|
||||
AutoSyncNoNotionID: "🆕 自动同步:首次上传到 Notion",
|
||||
AutoSyncMissingDatabaseList: "⚠️ 自动同步已跳过:请在 frontmatter 中添加 \"{key}\" 以指定目标数据库。",
|
||||
AutoSyncMultipleSync: "🔄 自动同步:正在同步到 {count} 个数据库...",
|
||||
AutoSyncFailed: "自动同步到 {database} 失败:{error}",
|
||||
AutoSyncError: "自动同步 {filename} 失败:{error}",
|
||||
StartUpload: "开始上传 {filename}",
|
||||
AutoSyncFailed: "同步到 {database} 失败:{error}",
|
||||
AutoSyncError: "同步 {filename} 失败:{error}",
|
||||
StartUpload: "开始上传 {filename}...",
|
||||
AddNewDatabase: "添加新数据库",
|
||||
AddNewDatabaseDesc: "添加新的数据库配置",
|
||||
AddNewDatabaseTooltip: "添加新数据库",
|
||||
EditDatabase: "编辑数据库",
|
||||
Preview: "预览",
|
||||
DatabaseFormatLabel: "数据库格式",
|
||||
DatabaseFullNameLabel: "数据库全称",
|
||||
DatabaseFullNameLabel: "数据库全名",
|
||||
DatabaseAbbreviateNameLabel: "数据库简称",
|
||||
NotionAPILabel: "Notion API 密钥",
|
||||
DatabaseIDLabel: "数据库 ID",
|
||||
ToggleAPIKeyVisibility: "切换 API 密钥可见性",
|
||||
CopyAPIKey: "复制 API 密钥",
|
||||
APIKeyCopied: "API 密钥已复制到剪贴板",
|
||||
APIKeyCopied: "API 密钥已复制到剪贴板。",
|
||||
ToggleDatabaseIDVisibility: "切换数据库 ID 可见性",
|
||||
CopyDatabaseID: "复制数据库 ID",
|
||||
DatabaseIDCopied: "数据库 ID 已复制到剪贴板",
|
||||
DatabaseIDCopied: "数据库 ID 已复制到剪贴板。",
|
||||
AddNewDatabaseModal: "添加新数据库",
|
||||
}
|
||||
|
||||
100
src/main.ts
100
src/main.ts
@@ -4,6 +4,7 @@ import { i18nConfig } from "src/lang/I18n";
|
||||
import ribbonCommands from "src/commands/NotionCommands";
|
||||
import { ObsidianSettingTab, PluginSettings, DEFAULT_SETTINGS, DatabaseDetails } from "src/ui/settingTabs";
|
||||
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!
|
||||
|
||||
@@ -18,6 +19,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
private lastFrontmatterCache: Map<string, any> = new Map();
|
||||
private lastContentHashCache: Map<string, string> = new Map();
|
||||
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
@@ -67,6 +69,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
}
|
||||
this.lastFrontmatterCache.clear();
|
||||
this.lastContentHashCache.clear();
|
||||
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
@@ -89,6 +92,13 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
if (typeof this.settings.NotionLinkDisplay !== 'boolean') {
|
||||
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
|
||||
if (!this.settings.databaseDetails || typeof this.settings.databaseDetails !== 'object') {
|
||||
@@ -99,7 +109,9 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
const needsSave = !loadedData ||
|
||||
loadedData.autoSync === undefined ||
|
||||
loadedData.autoSyncDelay === undefined ||
|
||||
loadedData.NotionLinkDisplay === undefined;
|
||||
loadedData.NotionLinkDisplay === undefined ||
|
||||
loadedData.autoCopyNotionLink === undefined ||
|
||||
loadedData.autoSyncFrontmatterKey === undefined;
|
||||
|
||||
if (needsSave) {
|
||||
const migratedFields = [];
|
||||
@@ -109,6 +121,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
if (loadedData.autoSync === undefined) migratedFields.push('autoSync');
|
||||
if (loadedData.autoSyncDelay === undefined) migratedFields.push('autoSyncDelay');
|
||||
if (loadedData.NotionLinkDisplay === undefined) migratedFields.push('NotionLinkDisplay');
|
||||
if (loadedData.autoCopyNotionLink === undefined) migratedFields.push('autoCopyNotionLink');
|
||||
|
||||
console.log('[Settings] Migrating settings, adding fields:', migratedFields.join(', '));
|
||||
}
|
||||
@@ -131,6 +144,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
autoSync: this.settings.autoSync,
|
||||
autoSyncDelay: this.settings.autoSyncDelay,
|
||||
NotionLinkDisplay: this.settings.NotionLinkDisplay,
|
||||
autoSyncFrontmatterKey: this.settings.autoSyncFrontmatterKey,
|
||||
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');
|
||||
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') {
|
||||
console.warn('[Settings] Invalid databaseDetails, resetting to empty object');
|
||||
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) {
|
||||
@@ -327,25 +357,61 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Find all databases this file belongs to by checking for NotionID-{abName}
|
||||
const foundDatabases: Array<{ dbDetails: DatabaseDetails, notionId: string }> = [];
|
||||
const autoSyncKey = this.getAutoSyncFrontmatterKey();
|
||||
const autoSyncTargets = parseAutoSyncDatabaseList(frontMatter[autoSyncKey]);
|
||||
|
||||
for (const key in this.settings.databaseDetails) {
|
||||
const dbDetails = this.settings.databaseDetails[key];
|
||||
const notionIDKey = `NotionID-${dbDetails.abName}`;
|
||||
// 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 (frontMatter[notionIDKey]) {
|
||||
foundDatabases.push({
|
||||
dbDetails: dbDetails,
|
||||
notionId: String(frontMatter[notionIDKey])
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
// If no NotionID found, notify user to upload manually first
|
||||
|
||||
|
||||
const dbByShortName = new Map<string, DatabaseDetails>();
|
||||
for (const key in this.settings.databaseDetails) {
|
||||
const dbDetails = this.settings.databaseDetails[key];
|
||||
dbByShortName.set(dbDetails.abName.toLowerCase(), dbDetails);
|
||||
}
|
||||
|
||||
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({
|
||||
dbDetails,
|
||||
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 valid databases found in settings, skip
|
||||
if (foundDatabases.length === 0) {
|
||||
console.log(`[AutoSync] No NotionID found in ${file.path}, skipping auto sync`);
|
||||
new Notice(i18nConfig.AutoSyncNoNotionID, 4000);
|
||||
console.log(`[AutoSync] No matching databases found in settings for ${file.path}, skipping auto sync`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -353,12 +419,13 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
if (foundDatabases.length > 1) {
|
||||
const message = i18nConfig.AutoSyncMultipleSync.replace('{count}', String(foundDatabases.length));
|
||||
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
|
||||
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 {
|
||||
// Trigger appropriate upload command based on database format
|
||||
@@ -403,4 +470,3 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { SettingModal } from "./settingModal";
|
||||
import { PreviewModal } from "./PreviewModal";
|
||||
import { EditModal } from "./EditModal";
|
||||
import { DeleteModal } from "./DeleteModal";
|
||||
import { DEFAULT_AUTO_SYNC_DATABASE_KEY } from "src/utils/frontmatter";
|
||||
|
||||
export interface PluginSettings {
|
||||
NextButton: boolean;
|
||||
@@ -13,8 +14,10 @@ export interface PluginSettings {
|
||||
bannerUrl: string;
|
||||
notionUser: string;
|
||||
NotionLinkDisplay: boolean;
|
||||
autoCopyNotionLink: boolean;
|
||||
autoSync: boolean;
|
||||
autoSyncDelay: number;
|
||||
autoSyncFrontmatterKey: string;
|
||||
proxy: string;
|
||||
GeneralButton: boolean;
|
||||
tagButton: boolean;
|
||||
@@ -51,8 +54,10 @@ export const DEFAULT_SETTINGS: PluginSettings = {
|
||||
bannerUrl: "",
|
||||
notionUser: "",
|
||||
NotionLinkDisplay: true,
|
||||
autoCopyNotionLink: true,
|
||||
autoSync: false,
|
||||
autoSyncDelay: 5,
|
||||
autoSyncFrontmatterKey: DEFAULT_AUTO_SYNC_DATABASE_KEY,
|
||||
proxy: "",
|
||||
GeneralButton: 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.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')
|
||||
|
||||
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
|
||||
this.autoSyncDelayContainer = containerEl.createDiv();
|
||||
const delaySetting = new Setting(this.autoSyncDelayContainer)
|
||||
@@ -116,7 +136,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
// Set initial visibility
|
||||
this.updateAutoSyncDelayVisibility();
|
||||
|
||||
@@ -218,7 +238,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings[settingsKey] = value; // Update the plugin settings directly
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
|
||||
|
||||
// If autoSync setting changed, update the listener and visibility
|
||||
if (settingsKey === 'autoSync') {
|
||||
this.plugin.setupAutoSync();
|
||||
@@ -350,4 +370,3 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { App, Notice, TFile } from "obsidian";
|
||||
import ObsidianSyncNotionPlugin from "../main";
|
||||
import { DatabaseDetails } from "../ui/settingTabs";
|
||||
import { i18nConfig } from "src/lang/I18n";
|
||||
import { ensureAutoSyncDatabaseEntry } from "src/utils/frontmatter";
|
||||
|
||||
export async function updateYamlInfo(
|
||||
yamlContent: string,
|
||||
@@ -17,6 +18,7 @@ export async function updateYamlInfo(
|
||||
const { abName } = dbDetails
|
||||
const notionIDKey = `NotionID-${abName}`;
|
||||
const linkKey = `link-${abName}`;
|
||||
const autoSyncKey = plugin.getAutoSyncFrontmatterKey();
|
||||
|
||||
if (notionUser !== "") {
|
||||
// replace url str "www" to notionID
|
||||
@@ -33,12 +35,21 @@ export async function updateYamlInfo(
|
||||
// add new notionID and link
|
||||
yamlContent[notionIDKey] = id;
|
||||
(NotionLinkDisplay) ? yamlContent[linkKey] = url : null;
|
||||
|
||||
// ensure auto sync database list contains current short name
|
||||
yamlContent[autoSyncKey] = ensureAutoSyncDatabaseEntry(
|
||||
yamlContent[autoSyncKey],
|
||||
abName
|
||||
);
|
||||
});
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(url)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
new Notice(`${i18nConfig.CopyErrorMessage}`);
|
||||
// copy url to clipboard only if autoCopyNotionLink is enabled
|
||||
if (plugin.settings.autoCopyNotionLink) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
new Notice(`${i18nConfig.CopyErrorMessage}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
63
src/utils/frontmatter.ts
Normal file
63
src/utils/frontmatter.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user