Skip to content

feat(xlsx): links of cells, in a card under the selected cell - #62

Merged
pierreneter merged 1 commit into
mainfrom
feat/xlsx-cell-links
Dec 3, 2026
Merged

pierreneter merged 1 commit into
mainfrom
feat/xlsx-cell-links

Conversation

@pierreneter

Copy link
Copy Markdown
Member

A workbook's links were not read at all: a cell with a <hyperlink> showed its text and led nowhere. Cells now have links, and the selected cell's links show in a card under it, as in Google Sheets.

Where a cell's link comes from (src/core/xlsx/links.ts)

The first that applies:

  1. The file's <hyperlink>: to an address outside the file (its relationship, a location added as a fragment), or to a place in the workbook ('Sheet 2'!B3, a defined name). The links are kept as read, and where each is now is worked out with the same shifts and renames that followSheetTail applies when the sheet is saved. Inserted / deleted rows and columns, undo and renamed sheets give the same cell in the view as in the saved file.
  2. A formula calling HYPERLINK with a text: =HYPERLINK("https://…", "name"), or "#Sheet2!A1" for a place.
  3. Web and mail addresses in the text (findLinks in src/core/url.ts): https://, ftp://, www., mailto: and name@host.tld. A stop, a comma or a closing bracket the address did not open is not part of it.

xlsx.cell returns them as CellDetail.links. The bulk Replace leaves them out: it reads only the value.

In the view (src/react/xlsx/XlsxView.tsx)

  • Addresses in a text are underlined in --de-sheet-link (#1155cc, a new paper token). A cell with its own text color keeps it. The file's links look as their cell style says, as in Excel.
  • The card sits under the selected cell, or above it when there is no room. For each link it has:
    • an address that opens: a page in a new tab (noopener noreferrer), or a place in the workbook (selected and scrolled to, on its sheet);
    • a Copy button;
    • an Edit button, which opens the cell editor. It shows only for a link of the text or of a formula, since editing the cell doesn't change where a file's link goes.
  • Only safe schemes are clickable (safeHref, with a scheme required). javascript: and another file's relative path are shown as text, and can still be copied.
  • The card shows once a cell is selected, by a click or the keyboard, not when the sheet opens. Escape hides it until another cell is selected or a click. Like Google Sheets, it covers the cells under it. A mouse-down on it selects nothing and keeps the keyboard with the grid.
  • No site icon. It would be fetched from the linked site's server, which would then learn the sheet was being looked at.

Not in this PR

Inserting, editing or removing a file's link (Ctrl+K, unlink) means writing <hyperlinks> and the sheet's relationships, with undo and collaboration ops. That is left for a follow-up.

Tests

  • test/xlsx-links.test.ts (11): findLinks cases and non-links; file links on a cell and on a range, with tooltip and fragment; links following inserted / deleted rows and undo; a renamed sheet and a defined name as the place; a relative or missing relationship; HYPERLINK; addresses typed in; the saved <hyperlink ref> matching the view.
  • e2e/xlsx-links.spec.ts (4):
    • underline and color only on the addresses;
    • the card under the cell; a click on the link opens a new tab and the selection stays;
    • keyboard moves; Escape;
    • copy to the clipboard; the jump to 'Other Sheet'!C5;
    • Edit, and no Edit in a read-only view.
  • The rest of the unit suite and the xlsx, comments, security and collab e2e suites pass. theme.ts lists the new token.

🤖 Generated with Claude Code

… in a text, in a card under the selected cell

- the file's <hyperlink>s are read (to a web address, to a place in the workbook): they follow the rows / columns
  inserted and deleted and the sheets renamed, as the sheet is saved
- a formula calling HYPERLINK with a text links where it says
- web and mail addresses written in a text (https://…, www.…, name@host) are underlined, in the color of links
  (`--de-sheet-link`), unless the cell has a color of its own
- the selected cell's links show in a card under it: each opens (a page in a new tab, a place in the workbook), is
  copied, and a link of the text or of a formula is edited with the cell; Escape puts the card away
- no icon of the site: it would be fetched from the site's server, which would learn the sheet was looked at

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pierreneter
pierreneter merged commit 79115e2 into main Dec 3, 2026
2 checks passed
@pierreneter
pierreneter deleted the feat/xlsx-cell-links branch December 3, 2026 06:26
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.

1 participant