Skip to content

2.30.0 regression: clipboard.insert of a hyperlink fragment inside an existing hyperlink creates a nested link (2.23.0 rejected it) #4151

Open

Description

@Nathaniel-260

What happened?

Thanks for 2.30.0.

In 2.30.0, clipboard.insert with a fragment that contains a hyperlink succeeds when the target caret is inside an existing hyperlink, and the result is a hyperlink nested inside another one. hyperlinks.list() then reports two overlapping links (the outer one and the inner one). Word has no nested hyperlinks, so the document can no longer round-trip cleanly.

In 2.23.0 (the version we ship) the same call was rejected with an overlap failure; we did not re-test 2.24–2.29, and hyperlinks.insert in 2.30.0 still rejects the same position with INVALID_CONTEXT. Only the clipboard path lets it through.

Steps to reproduce

  1. Type alpha beta gamma in a new document.
  2. doc.hyperlinks.wrap({ target: { kind: 'text', blockId, range: { start: 0, end: 10 } }, link: { destination: { href: 'https://example.org/a' } } })
  3. With the caret point at offset 3 (inside that link):
    await doc.clipboard.insert({
      fragment: {
        kind: 'superdoc.clipboard.fragment', version: 'v2.2',
        blocks: [{ kind: 'paragraph', runs: [{ text: 'X' }],
          inlines: [{ kind: 'hyperlink', target: { kind: 'external', url: 'https://example.org/b' }, inlines: [{ kind: 'text', text: 'X' }] }] }],
      },
      formattingMode: 'match-destination',
      target: { kind: 'selection', start: point, end: point },
    });
  4. Call doc.hyperlinks.list().

Expected (as in 2.23.0): the insert fails with an overlap failure, and the document is unchanged.

Actual (2.30.0): success: true, the text becomes alpXha beta gamma, and hyperlinks.list() returns the outer link over the whole range and a second link over the inserted X, inside it.

SuperDoc version

Works: 2.23.0. Broken: 2.30.0. (2.24–2.29 not tested.)

Browser

Chrome (Windows 10).

Additional context

We use the clipboard fragment to insert a link and its text in one transaction (it keeps the run formatting at the caret). On our side we now check hyperlinks.list({ within }) for the caret's block before inserting, but a check in the engine would protect every integration, including a plain paste of a link into a link.

Activity

  1. added
    status: triage
    on Nov 12, 2026
  2. changed the title [-]2.30.0 regression: clipboard.insert of a hyperlink fragment inside an existing hyperlink creates a nested link (2.29.0 rejected it)[/-] [+]2.30.0 regression: clipboard.insert of a hyperlink fragment inside an existing hyperlink creates a nested link (2.23.0 rejected it)[/+] on Nov 12, 2026
  3. added theissue type on Nov 12, 2026
  4. caio-pizzol commented on Nov 12, 2026

    @caio-pizzol
    Contributor

    Thanks, confirmed. This broke in 2.30.0 (2.29.0 still refuses it), and hyperlinks.wrap and hyperlinks.insert can nest links too. For your own check, count the link's start and end as inside it. Pasting at the very start is the worst case: the existing link text gets the new URL. We're working on an engine-side fix.

  5. added
    status: queued
    and removed
    status: triage
    on Nov 12, 2026
  6. self-assigned this
    on Nov 12, 2026
  7. added
    status: in-progress
    and removed
    status: queued
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: in-progress

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions