Skip to content

feat: hyperlinks - #200

Merged
anderix merged 2 commits into
mainfrom
161-hyperlinks
Nov 24, 2026
Merged

anderix merged 2 commits into
mainfrom
161-hyperlinks

Conversation

@anderix

@anderix anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closes #161

  • edit/link.rs provides make_link, set_link, remove_link, link_at and followable.
    • A text:a with xlink:type="simple" is made by cutting the paragraph at both ends of the range, so spans split there keep their formatting on both sides.
    • Refused: a range across paragraphs, an empty one, one reaching into a link (Refused::Structure), and an address that isn't followable (new Refused::Address).
    • set_link keeps the formatting when the text is unchanged. remove_link keeps the text and formatting.
  • The address policy now lives in core (followable): http(s), mailto, or #place. odox_ui::links::target calls it, so the addresses accepted and the addresses followed are one list.
  • odox_ui::link_dialog has LinkDialog, with text, address and a place picker, plus Remove link when editing. LinkQuestion asks and acts, and both apps share it.
  • FlowModel gains link_here, put_link, take_link and places. Each change is one undo step.
  • Ctrl+K and Format > Link… open the dialog. It offers headings and bookmarks in xodt, and slides in xodp.
  • Checked in Xephyr: in xodt, editing a link's address to a heading, then removing it; in xodp, making a link from a selection to a slide.
  • Known gap: xodp's slide labels don't draw links in link colour. That predates this PR, and I've recorded it as deferred.

…t's headings, bookmarks or slides to pick from
…differs, take Ctrl+K only from the page, and refuse a question left behind
@anderix

anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Review fixes are in the second commit.

Important

  • 1: a selection counts as the link only where it lies inside one. A caret where two links meet is in the second (a_selection_beside_a_link_is_a_new_link_not_that_one, at_the_meeting_of_two_links_the_caret_is_in_the_second).
  • 2: Ctrl+K is taken only while the page editor has focus.
  • 3: refusals go through t with link-specific sentences, translated into German.
  • 4: places name headings by plain_text, as the follower matches them.
  • 5: make_link now cuts the paragraph three ways with cut and merges text, rather than going through the normalizing split. remove_link merges text rather than normalizing. No space is rewritten (making_a_link_leaves_the_spaces_beside_it_as_written, removing_a_link_in_a_span_leaves_the_span_as_written).
  • 6: only the characters that differ are replaced, in both set_link and a new link's text (changing_part_of_a_links_text_keeps_the_rest_formatted, through the new edit::difference).
  • 7: before acting, the answer checks that the text, and for a link its address, are still where the question started, and refuses otherwise (a_question_left_behind_by_an_edit_is_refused).

Minors fixed

  • 1: a mark just after the range stays outside the link.
  • 3: the undo caret is where the change began.
  • 4: OK with nothing changed records nothing.
  • 5: tracked deletions and __ bookmarks are left out of the picker.
  • 6: an unrenamed slide shows as "Slide N", while the address stays #pageN.
  • 7: with no caret, the notice says "Put the caret where the link goes."

Every fix that has a test fails on the reviewed code.

Deferred

  • 2: text:meta ids copied by a cut, and a href-less text:a nested.
  • 8: spaces in addresses kept as typed.
  • 9: the entry is under Format, which DESIGN and the README describe.
  • 10: quadratic copies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xodt and xodp: insert and edit hyperlinks

1 participant