Auto-link Story Bible mentions in the draft, with a hover card to the entry

Bare proper nouns in prose ("Bixby walked in") now resolve against the
Story Bible automatically, the same as the existing [[wiki-links]] and
@mentions markup — no manual linking required. Matching is case-sensitive
and requires a capitalized, 3+ character match to a sheet's name or alias,
which is what keeps a character named "Hope" or "Will" from lighting up
on every unrelated use of the word; the longest phrase wins an overlap
("Bixby Reynolds" over "Bixby"), and a bare match never overrides the
author's own explicit markup.

Hovering a highlighted mention shows a card with the item's name, type
(Person/Place/Thing) and a summary (from a new summary:/description:
frontmatter field), with a link that opens the entry in the Story Bible
editor. The card appears after a short delay and stays open while the
pointer crosses onto it to reach the link.

Along the way:
- StoryBibleReference now carries absolute byte offsets (start/end) and
  the resolved item_id, replacing column/length, which were actually
  per-line and were being used as whole-buffer offsets — every reference
  past a file's first line highlighted and jumped-to in the wrong place.
  find_references() also now walks the buffer one char at a time rather
  than one byte, which could previously land mid-character and panic on
  any manuscript with accented letters or an em dash.
- build_story_bible_index() had its own, separately hardcoded list of
  Story Bible directory names that had drifted from
  find_story_bible_directory()'s list and no longer included
  03-Story-Bible, the bundled template's actual folder — so the index,
  and everything built on it, was silently empty for every project made
  from that template. It now reuses the one list.
- Story Bible Editor window: its tree and content ScrollAreas (and the
  content TextEdit) had no id_salt, so egui treated them as the same
  widget — fixed with explicit salts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 11:01:54 -05:00
parent ef8032b300
commit ab9aa2afce
6 changed files with 436 additions and 84 deletions
+16
View File
@@ -383,6 +383,18 @@ pub struct App {
selected_bible_item: Option<String>,
/// References found in the current draft file.
current_references: Vec<crate::story_bible::StoryBibleReference>,
/// The Story Bible item whose hover card is (or was just) showing over the
/// editor, so the card can stay open while the pointer crosses from the
/// mentioned word onto the card itself to click its link.
bible_hover_item: Option<String>,
/// When the current hover began, so the card only appears after a short
/// delay rather than flickering across every name the pointer passes over.
bible_hover_since: Option<Instant>,
/// On-screen rect of the mentioned word, to anchor the hover card under.
bible_hover_anchor: egui::Rect,
/// On-screen rect the hover card itself occupied last frame, so hovering
/// the card (to reach its link) counts as still hovering the reference.
bible_hover_card_rect: Option<egui::Rect>,
/// Whether the Story Bible breakout editor window is open.
show_story_bible_editor: bool,
/// The content being edited in the Story Bible editor.
@@ -502,6 +514,10 @@ impl App {
show_story_bible: false,
selected_bible_item: None,
current_references: Vec::new(),
bible_hover_item: None,
bible_hover_since: None,
bible_hover_anchor: egui::Rect::NOTHING,
bible_hover_card_rect: None,
show_story_bible_editor: false,
story_bible_editor_content: String::new(),
story_bible_editor_path: None,