Commit graph

4 commits

Author SHA1 Message Date
William Nurmi
04402c8298 fix: block link display text covers the whole multi-line block
A soft-wrapped multi-line item is ONE block in Obsidian (the block id sits
at the end of its last line and the cache span covers every line), but the
auto display text was built from a single line: the range's first line when
inserting a new id, the id-bearing last line when copying an existing one.
Multi-line blocks therefore got truncated aliases.

- new EasyCopy.getBlockText(): walks up to the block's first line (bullet
  or paragraph start, also from a continuation line under the cursor),
  extends through the soft-wrapped continuation lines, strips per-line
  trailing block ids, and joins with newlines
- both copy paths pass the full block text; extractBlockDisplayText joins
  the lines with single spaces (blank lines dropped) before applying the
  existing word/char limits
- the trailing-id strip is now ^[a-zA-Z0-9_-]+$ per line instead of the
  greedy /\^.*$/, so a mid-line caret (e.g. 2^10) survives
- firstLine renamed blockText through the pipeline; 5 new tests
2026-06-12 11:42:28 +03: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
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