Commit graph

111 commits

Author SHA1 Message Date
Moy
6b7bca0bc7 chore: update pnpm lockfile 2026-05-13 19:20:50 +08:00
Moy
37a490d777 ci: fix duplicate separators in release notes extraction 2026-05-12 13:01:01 +08:00
Moy
aa73736d9f build: 1.6.1 2026-05-12 12:56:21 +08:00
Moy
f59fd09cd2 docs: restructure CHANGELOG with details blocks and update release workflow for minor-series aggregation 2026-05-12 12:48:52 +08:00
Moy
d693e59061 docs: add emoji to CHANGELOG section headings 2026-05-12 12:46:38 +08:00
Moy
3418e9ae4f feat: add code block copy with configurable behavior setting
- Add CodeBlockBehavior enum: COPY_CONTENT / COPY_WITH_FENCES / GENERATE_BLOCK_LINK / DISABLED
- Add CODEBLOCK ContextType, detectCodeBlock() method in main.ts
- Code block detection runs before block ID generation (conflict resolution)
- Add Code Block settings group in settingTab.ts with dropdown
- Add CHANGELOG.md with full version history
- Update release workflow to extract notes from CHANGELOG.md
2026-05-12 12:42:27 +08:00
Moy
63c636de7b build: 1.6.0 2026-05-09 19:08:04 +08:00
Moy
d13b66a69c
Merge pull request #35 from lightmotive/feat/follow-obsidian-paste-resolution
feat: paste-time link resolution + heading-link polish
2026-05-09 14:05:43 +08:00
Moy
3143de6edf fix: add console warning when paste is preempted, add community-plugins.json hint to tooltip, inline info icon 2026-05-08 14:40:30 +08:00
Moy
a34ce4648a refine: split paste-resolution desc into short text + info tooltip, remove re-enable suggestion 2026-05-08 14:35:25 +08:00
Moy
8e1b6058bd fix: restore defaultPrevented check, always show simplifiedHeadingToNoteLink setting, update i18n with load-order note 2026-05-08 14:18:46 +08:00
Moy
fbd9547bf8 fix: restore simplifiedHeadingToNoteLink in OBSIDIAN mode, remove defaultPrevented check, update i18n descriptions 2026-05-08 13:37:26 +08:00
Andre Light
7c6aa950af chore: translate user-authored comments to Simplified Chinese
The maintainer reviews and writes comments in Chinese. To minimize
review friction and maximize merge likelihood, translate all
user-authored English comments across src/ into Simplified Chinese,
matching the upstream comment style. Test files included; describe/it
strings stay English (functional test names). Pre-existing English
comments authored by upstream contributors are left untouched.

Adds CONTRIBUTING-zh.md as a sibling translation of CONTRIBUTING.md
(matching the README.md / README-zh.md cross-linked convention).

Also corrects one Chinese comment in type.ts that became stale after
extending paste-time path resolution to all three Link format options.

No behavior change. 184 tests pass; typecheck and lint clean (the
pre-existing unrelated lint error in detectBlockId remains as before).

Designed, carefully reviewed, and edited by @lightmotive in collaboration with Claude Code.
2026-04-28 22:27:48 -06:00
Andre Light
1e06fa7229 refactor: extract helpers from buildHeadingLink
Pull out computeDisplayText, shouldSimplifyHeading,
formatWikiHeadingLink, formatMarkdownHeadingLink as private helpers.
buildHeadingLink becomes a thin orchestrator: stripWikiBrackets →
computeDisplayText → shouldSimplifyHeading → wikiExactMatch policy →
formatX. Formatters are pure string-producers; the orchestrator owns
the WIKI [[filename]] exact-match policy (the A1.5 exception).

Pure refactor — no behavior change, all 184 existing tests pass without
modification.

Also extract stripWikiBrackets to its own export and reuse in
buildHeadingCopyMetadata (removes duplicated [[…]] stripping).

Designed, carefully reviewed, and edited by @lightmotive in collaboration with Claude Code.
2026-04-28 20:55:48 -06:00
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
Andre Light
7e467f389c feat: drop redundant alias on same-file OBSIDIAN paste
When pasting a heading link into the same file it was copied from, the
paste handler now produces [[#Heading]] instead of [[#Heading|Heading]].
The alias was redundant — Obsidian's natural rendering of [[#Heading]]
already shows just "Heading" since there's no file portion to
disambiguate.

Cross-file pastes keep the alias (without it, Obsidian renders
"Filename > Heading" instead of just "Heading"). Markdown-format pastes
also keep the alias (it IS the visible link text in markdown). The
omission is wiki-only, same-file-only, useHeadingAsDisplayText-only.

Adds shouldOmitAliasForSameFile pure helper in pasteResolution.ts with
truth-table tests; handlePaste consults it before calling
generateMarkdownLink.

Designed, carefully reviewed, and edited by @lightmotive in collaboration with Claude Code.
2026-04-28 20:48:15 -06:00
Andre Light
eca6c94ae9 feat: gate simplifiedHeadingToNoteLink to non-OBSIDIAN formats
Under "Follow Obsidian settings", defer link format/path choice to
Obsidian's vault config — but Obsidian's own generateMarkdownLink would
never auto-collapse a heading link to a file link when the filename
matches the heading. Keeping simplifiedHeadingToNoteLink active under
OBSIDIAN injects an Easy Copy opinion that conflicts with that intent.

Hide the toggle (and its strict-match child) from settings UI when
linkFormat is OBSIDIAN, and gate simplification inert at the call site
in copyHeadingLink. Stored values persist across format changes,
matching the precedent set by resolveLinkPathOnPaste.

Designed, carefully reviewed, and edited by @lightmotive in collaboration with Claude Code.
2026-04-28 20:46:55 -06:00
Andre Light
b29a70084b feat: gate simplifiedHeadingToNoteLink on useHeadingAsDisplayText (A1.5)
When useHeadingAsDisplayText is false, the user has chosen to see
"filename#heading" in the link display. Auto-simplifying the link
target to just the filename in that case produces a misleading
[filename#heading](filename) — display promises a heading link the
target doesn't deliver.

Add useHeadingAsDisplayText to the simplification gate. The WIKI
exact-match special case [[filename]] is intentionally exempt —
Obsidian renders it cleanly as just the filename, no alias, no
mismatch.

4 new MD A1.5 tests + 5 WIKI A1.5 tests covering the gate and the
exact-match exception. One existing test (frontmatterTitle +
note-link simplification, wiki) renamed to reflect gated behavior.

161 tests pass; typecheck clean.

Designed, carefully reviewed, and edited by @lightmotive in
collaboration with Claude Code.
2026-04-28 02:06:48 -06:00
Andre Light
8f0f26a535 feat: apply simplifiedHeadingToNoteLink to markdown links
The MDLINK branch in buildHeadingLink now uses linkContent (which the
early simplification block already computes), so a matching filename
and heading collapses [foo](foo#foo) → [foo](foo) just like the wiki
form already did. Was effectively a no-op for MD before — the toggle
existed but didn't affect markdown output.

10 new tests covering exact / case-insens / space-removed / substring /
strict-mode simplification cases. The MDLINK + matching-filename test
and the noSimplify MD sanity test are renamed to reflect their actual
intent now that simplification works for both formats.

107 tests pass; typecheck clean.

Designed, carefully reviewed, and edited by @lightmotive in
collaboration with Claude Code.
2026-04-28 02:04:56 -06:00
Andre Light
4ac623b1bd feat: opt-in toggle, editor-paste cooperation, and orphaned-setting fix
Addresses #35 maintainer feedback: gate paste-time resolution behind a
default-off toggle with 5-min TTL on lastCopyMeta. Switch from DOM
paste (capture phase) to editor-paste workspace event with documented
defaultPrevented yield protocol; register only when active.

Also fixes a pre-existing bug where simplifiedHeadingToNoteLink was
never read — the simplification fired unconditionally when filename
matched heading.

Designed, carefully reviewed, and edited by @lightmotive in collaboration with Claude Code.
2026-04-27 20:46:42 -06:00
Andre Light
3c3c20800f test: extract copy-metadata builders and add unit tests
Move the inline metadata-construction logic from the three copy paths
(block/heading/file) into pure helpers in src/copyMetadata.ts, matching
the project's pure-function test style. Adds 25 unit tests covering
alias, subpath, and embed computation for each copy type.
2026-04-22 04:06:58 -06:00
Andre Light
2c51e4e52d feat: paste-time path resolution using Obsidian's link format settings
Intercept paste (DOM capture phase) to regenerate Easy Copy links via
generateMarkdownLink(), resolving shortest/relative/absolute paths based
on the destination file. Metadata is cleared on manual copy to prevent
false interception of non-Easy-Copy content.
2026-04-22 03:23:24 -06:00
Moy
f93ad24367 build: 1.5.3 2026-04-22 14:32:47 +08:00
Moy
d327b5013a build: 1.5.3 2026-04-22 13:22:01 +08:00
Moy
46723f1cd0 build: 1.5.3 2026-04-22 13:03:37 +08:00
Moy
f646ba8196 ci: fix release workflow for vitest compatibility 2026-04-22 13:00:28 +08:00
Moy
a07b499f4a build: 1.5.3 2026-04-22 12:58:16 +08:00
Andre Light
60e451db9f fix: sanitize heading link targets and fix substring matching
Strip # | ^ : %% [[ ]] from heading link targets to match Obsidian's
autocomplete behavior. Fix compareIgnoreCase to use strict equality
instead of includes(), preventing false-positive note-link simplification.
2026-04-22 12:55:29 +08:00
Andre Light
d6f6678b38 docs: add CONTRIBUTING.md with development and testing instructions 2026-04-22 12:38:52 +08:00
Andre Light
87692e012f test: add vitest harness with pure function extraction for link builders 2026-04-22 12:38:52 +08:00
Andre Light
7be3eee3b3 Fix: encode spaces as %20 in generated Markdown link URLs
Obsidian doesn't parse Markdown links with literal spaces in the URL
portion (e.g. `[text](file#My Heading)`). This encodes spaces as `%20`
in the URL part of all Markdown-format links — heading links, block
links, and file links — so they render correctly.

Closes #29

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:04:29 +08:00
Moy
f8c341c51b build: 1.5.2 2026-04-02 20:18:08 +08:00
Moy
14a98fa8e1 build: 1.5.2 2026-04-02 20:11:11 +08:00
Moy
68f239900b build: 1.5.1 2025-12-12 00:21:09 +08:00
Moy
d1b4aa4587 chore: add icon for plugin 2025-12-12 00:20:33 +08:00
Moy
5d977b8197 build: update the dependencies 2025-11-05 19:21:02 +08:00
Moy
23cc7622b1 refactor: lint 2025-11-05 17:24:02 +08:00
Moy
2278508ed6 build: add obsidian eslint 2025-11-05 17:08:41 +08:00
Moy
d716806092 build: 1.5.0 2025-11-05 13:54:17 +08:00
Moy
a20a9911f9 feat: support configurable block ID insertion position 2025-11-05 13:52:43 +08:00
Moy
bf98aeaa09 bump version to 1.4.0 2025-10-21 17:15:20 +08:00
Moy
cd9c1e06bd feat: add simplified-heading-to-note-link setting
Introduce a new boolean setting simplifiedHeadingToNoteLink to
allow simplifying heading links into note links when the filename
matches the heading. Update default settings to enable the option.

Add related i18n keys and translations across en/zh/zh-tw:
- note-link-simplified
- simplified-heading-to-note-link
- simplified-heading-to-note-link-desc

Update settings UI to expose the toggle with description and save
behavior, and re-render the settings panel when toggled.

These changes improve UX by letting users copy a simpler note link
instead of a filename#heading link when the filename corresponds to
the heading (commonly for top-level headings).
2025-10-21 17:15:20 +08:00
Moy
faba964011 build: 1.3.5 2025-09-15 20:21:55 +08:00
Moy
265eadae41 feat: add block display text limit settings
Add configurable limits for generated block display text and wire them
through UI, defaults, localization, and usage logic.

- Add blockDisplayWordLimit and blockDisplayCharLimit to settings with
  defaults (3 words, 5 chars).
- Expose new settings in the Settings tab show the two limit inputs
  only when autoBlockDisplayText is enabled and save changes.
- Use the configured limits in main generation logic (fall back to
  defaults if unset) to trim English-like text by words and other
  languages by characters.
- Add i18n keys and translations for labels and descriptions in all
  languages.

This allows users to control how much text is included when the plugin
auto-generates display text for block links.
2025-09-15 20:17:59 +08:00
Moy
e2d1ff6270 feat: prefer frontmatter title for heading link display
Update copyHeading to use frontmatter when configured.
 useFrontmatterAsDisplay is enabled, read the active file's
frontmatter key (configurable via frontmatterKey, default 'title')
and use that value as the filename portion of the display text.
Preserve existing behavior when frontmatter is absent.

Also adjust heading link generation to avoid redundant display
text: if the computed display text exactly equals
"filename#heading", emit a simple [[filename#heading]] link
instead of including an identical pipe-qualified label.

These changes make generated heading links respect a frontmatter
display name and produce cleaner links when the label would
duplicate the target.
2025-09-15 19:43:02 +08:00
Moy
df9494ed7d Bump version to 1.3.4 2025-09-15 18:42:16 +08:00
Moy
f4bb658d63 feat: add heading-link-separator setting and UI support
Introduce a new setting `headingLinkSeparator (default '#')
customize the separator used between filename and heading when the
"Use heading as display text" option is disabled.

- Add `headingLinkSeparator` to settings type and defaults.
- Add localization keys and translations (en/zh/zh-TW) for the new
  setting and its description.
- Update settings UI to render a text input for the separator and
  re-render when "use heading as display text" toggles so the control
  shows/hides correctly.
- Use the configured separator when composing display text for heading
  links.
- Simplify a Wiki-link conditional to avoid redundant `useHeadingAsDisplayText`
  check when filename equals selected heading.

This allows users to customize the filename-heading delimiter for copied
heading links.
2025-09-15 18:40:49 +08:00
Moy
3fe3eb81be fix: full filename+heading copy
Fix #18
2025-09-15 18:29:49 +08:00
Moy
5571b258c4 chore(release): bump version to 1.3.3 2025-09-15 11:56:10 +08:00
Moy
83db9a82d4 feat(parser): support _ and __ markup and fix capture selection
Closes #16
2025-09-15 11:56:10 +08:00