`).
* **Crucially for Incremental Sync:** For *each* memo found in the HTML, a unique `memoId` is generated. This ID is based on a combination of:
* The memo's exact timestamp.
* A hash of its content (title, body, attachments).
* A counter for memos with the *exact same timestamp* (to differentiate them).
* An overall sequential counter.
* This generated `memoId` is compared against the `syncedMemoIds` list received from the settings.
* **If the ID is NOT in the list:** It's considered a **new memo**. Its `memoId` is added to the *instance's* `syncedMemoIds` list, `newMemosCount` is incremented, and the memo's data is added to the `memos` array to be processed.
* **If the ID IS in the list:** It's skipped.
6. **写入 Obsidian (`FlomoImporter.importFlomoFile`):**
* The method receives the processed data from `FlomoCore`, including the list of *only the newly identified* memos.
* It groups these new memos by date.
* Based on the "Merge Memos by Date" setting, it writes the content of each new memo (or merged content) to the appropriate file path within the specified `Flomo Target` and `Memo Target` folders in your vault.
* It potentially calls `generateMoments` and `generateCanvas` if enabled.
7. **状态保存 (State Saving - `main.ts`):**
* After `importFlomoFile` completes, the plugin calls `saveSettings()`.
* This saves the updated `syncedMemoIds` list (which now includes the IDs of the newly imported memos) and the current `lastSyncTime` back into Obsidian's persistent storage for this plugin. This ensures the *next* sync knows about these newly added memos.
8. **通知 (Notification):** A notice is displayed indicating how many memos were found and how many were newly imported.
This detailed ID generation and checking process is the key to reliable incremental synchronization, ensuring only new content is added to your Obsidian vault.
## 开发与修改指南
### 开发环境设置
1. 克隆仓库
2. 安装依赖:`npm install`
3. 安装Playwright (必需):`npx playwright@1.43.1 install`
### 修改模板和格式
如果需要修改导入的笔记格式或模板:
- 编辑 `lib/flomo/importer.ts` - 负责将Flomo笔记转换为Obsidian格式
- 编辑 `lib/obIntegration/moments.ts` - 修改Moments功能的显示方式
- 编辑 `lib/obIntegration/canvas.ts` - 修改Canvas展示格式
### 修改UI
- UI相关的修改主要集中在 `lib/ui/` 目录下
- 样式修改可以在 `styles.css` 文件中进行
### 构建项目
- 开发模式 (实时编译): `npm run dev`
- 生产构建: `npm run build`
- 构建后的文件为 `main.js`
### 版本管理
- 版本更新: `npm run version`
- 版本信息在 `manifest.json` 和 `versions.json` 中定义
### First time to use it?
#### Install Dependency
- **Playwright (MUST HAVE) :** `npx playwright@1.43.1 install`
- (this plugin was pre-built with version 1.43.1)
#### Install And Enable the plugin
- Install `Flomo Importer` and enable it.

- Use the command `Open Flomo Importer`, or use `Import Button`

#### Auto Sync
- Click on "Auto Sync"

- Authentication is required if the first time syncs or the current sign-in expires.

- Exporting & Importing

#### Adhoc Sync
###### 📦 **Export from Flomo**
- Go to `Account Details`
- Select `Export All (as HTML)`

- Click on `Start to export`
###### 🎯 **Import to Obsidian**
- Choose flomo.zip to Import. The `Flomo & Memo Home` is where to store your memos.
- A Notice pops up when the import is completed.
- Checkout **Flmomo Moments** and **Flomo Canvas** 🌅

## 🔄 Upgrading from Version 1.x to 2.0
If you're upgrading from an older version, the attachment path structure has changed. You have two options:
### Option A: Clean Re-import (Recommended)
1. Open Flomo Importer settings
2. Click the **"Reset Sync History"** button
3. Manually delete these old folders in your vault:
- `[Flomo Home]/memos/` (e.g., `flomo/memos/` or `10 flomo/memos/`)
- `[Flomo Home]/flomo picture/` (if exists)
4. Run sync again
5. All memos and attachments will be re-imported with the new, cleaner structure
### Option B: Keep Existing Memos
1. Just sync normally
2. Only new memos will be imported with the new attachment structure
3. Old memos keep their old attachment paths
4. Result: Mixed structure, but nothing breaks
**Note:** Content update detection works automatically. If you edit a memo in Flomo after upgrading, it will be detected and re-imported.
## Plugin Settings
You can customize the following options in the plugin settings page:
- **Auto Sync On Startup**: Automatically sync when Obsidian is launched.
- **Auto Sync Interval**: Automatically sync every hour.
- **Incremental Sync**: Skip already imported memos and only import new ones.
- **Merge Memos by Date**: Merge multiple memos from the same day into a single file.
- **Flomo Target**: Folder in Obsidian vault to store Flomo memos (default: `flomo`).
- **Memo Target**: Subfolder under Flomo folder to store individual memos (default: `memos`).
- **Canvas & Moments Options**: Select display options for Flomo Canvas and Moments.
- **Reset Sync History**: Clear all synced memo IDs to re-import all memos (useful after changing paths).