moyf_easy-copy/src
Andre Light adef562ef6 feat: extend paste-time path resolution to explicit Wiki/Markdown
Previously the paste handler only fired when linkFormat was "Follow
Obsidian settings". Users on explicit Wiki or Markdown got no
paste-time cleanup — pasting a heading into the same file produced the
verbose [[Filename#Heading|Heading]] instead of [[#Heading]].

Drop the OBSIDIAN-only gate in shouldRegisterPasteHandler and
decidePasteResolution. handlePaste branches by linkFormat: OBSIDIAN
keeps using app.fileManager.generateMarkdownLink (full newLinkFormat
support); explicit Wiki/Markdown uses app.metadataCache.fileToLinktext
(shortest-unique paths only). The same-file alias-redundancy fix from
the previous commit applies to both branches.

Add buildExplicitPasteLink in linkBuilder.ts as a pure string-producer
for the explicit-format branch — caller decides omitAlias via
shouldOmitAliasForSameFile, formatter consumes the boolean. Toggle now
shown for all three linkFormat options; description updated to reflect
format-aware behavior across en/zh/zh-tw.

Tests: new buildExplicitPasteLink suite covering wiki/md, same-file
vs cross-file, block links, and encoding behavior. pasteResolution
tests updated for the broadened gate (linkFormat field removed from
PasteResolutionInput; OBSIDIAN-only assertions dropped).

Trade-off: explicit Wiki/Markdown get shortest-path-only resolution;
users wanting relative/absolute path styles keep using "Follow
Obsidian settings" (which honors the vault's newLinkFormat config).

Designed, carefully reviewed, and edited by @lightmotive in collaboration with Claude Code.
2026-04-28 20:53:07 -06:00
..
blockIdModal.ts refactor: lint 2025-11-05 17:24:02 +08:00
copyMetadata.test.ts feat: opt-in toggle, editor-paste cooperation, and orphaned-setting fix 2026-04-27 20:46:42 -06:00
copyMetadata.ts feat: opt-in toggle, editor-paste cooperation, and orphaned-setting fix 2026-04-27 20:46:42 -06:00
i18n.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
linkBuilder.test.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
linkBuilder.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
main.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
pasteResolution.test.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
pasteResolution.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
settingTab.ts feat: extend paste-time path resolution to explicit Wiki/Markdown 2026-04-28 20:53:07 -06:00
type.ts feat: opt-in toggle, editor-paste cooperation, and orphaned-setting fix 2026-04-27 20:46:42 -06:00