What's Changed
- feat: resolve link path format for "Follow Obsidian settings" by @lightmotive in #35
Thanks @lightmotive for contributions! 🎉
✨ New Feature: Paste-time Link Path Resolution
When "Resolve link path on paste" is enabled, Easy Copy will regenerate link paths at paste time based on the destination file's location.
Example 1 — Same-note heading paste:
- Copy heading "Setup" from
projects/MyProject.md - Paste in the same file →
[[#Setup]](simplified, no redundant filename)
Example 2 — Cross-folder relative path:
- Obsidian path setting: "Relative path to current file"
- Copy heading from
docs/guide/Setup.md - Paste in
notes/daily/2024-01-01.md→[[../../docs/guide/Setup#Setup|Setup]]
Under "Follow Obsidian settings", uses your vault's path style (shortest/relative/absolute).
Under explicit Wiki/Markdown format, uses shortest-unique paths only.
♻️ Refactor
- Extracted
copyMetadata.tsandpasteResolution.tsas pure-function modules with full test coverage - Extracted helpers from
buildHeadingLinkfor better testability simplifiedHeadingToNoteLinknow properly gates the link simplification logic (previously was a dead setting)
🧪 Tests
- Added 98 new tests (total: 184), covering paste resolution logic and copy metadata building
改动内容
展开中文说明
✨ 新功能:粘贴时解析链接路径
启用"粘贴时解析链接路径"后,Easy Copy 会在粘贴时根据目标文件位置重新生成链接路径。
示例 1 — 同笔记内粘贴标题:
- 从
projects/MyProject.md复制标题 "Setup" - 在同一文件中粘贴 →
[[#Setup]](简化,无冗余文件名)
示例 2 — 跨文件夹相对路径:
- Obsidian 路径设置:"基于当前文件的相对路径"
- 从
docs/guide/Setup.md复制标题 - 粘贴到
notes/daily/2024-01-01.md→[[../../docs/guide/Setup#Setup|Setup]]
使用"跟随 Obsidian 设置"时,沿用软件设置中的路径风格(最短/相对/绝对);
使用明确的 Wiki/Markdown 格式时,仅使用最短唯一路径。
♻️ 重构
- 提取
copyMetadata.ts和pasteResolution.ts为纯函数模块,完整测试覆盖 - 从
buildHeadingLink中提取辅助函数 simplifiedHeadingToNoteLink设置现在正确控制链接简化逻辑(之前是无效设置)
🧪 测试
- 新增 98 个测试(总计 184 个),覆盖粘贴解析逻辑和复制元数据构建
Full Changelog: 1.5.3...1.6.0