Hosted ongabo.esvia theHypermedia Protocol

Copy-pasting mentions (embed links) between documents does not workhttps://github.com/seed-hypermedia/seed/issues/647

Problem

When a user copies a mention or embedded link from one document and pastes it into another document, the pasted content does not preserve the original mention/embed behavior.

Expected behavior

Mentions and embedded links should remain functional when copied from one document to another. After pasting, they should still resolve to the same referenced Seed document, block, or resource.

Actual behavior

The pasted mention/embed link does not work correctly in the destination document.

Impact

This makes it difficult to reuse references across documents and breaks an expected workflow for linking related content. It also reduces trust in copy/paste behavior because links that appear valid may stop functioning after being moved.

Plans

Plan 1

Findings:

    Primary breakage is in frontend/packages/editor/src/ssr-render.ts.

      inline mentions render as visual HTML only; no data-inline-embed

      embed cards render data-content-type="embed" but omit data-url / data-view

      copied SSR HTML therefore pastes back as plain links / empty embeds

    Secondary breakage is in frontend/packages/editor/src/tiptap-extension-link/link.ts.

      copied link marks serialize only the rendered href

      canonical hm://... source is not preserved on web copy paths

Proposed fix:

    frontend/packages/editor/src/tiptap-extension-link/link.ts

      on render, keep visible href as today

      also emit canonical raw link in data-hm-link

      on parse, prefer data-hm-link over href

    frontend/packages/editor/src/ssr-render.ts

      inline embed output: include data-inline-embed="<raw hm url>"

      annotated hypermedia links: include data-hm-link="<raw hm url>"

      embed block/card output: include data-url and data-view

      keep resolved web/site href for UX; add raw attrs only for round-trip paste fidelity

Tests

    extend frontend/packages/editor/src/ssr-render.test.ts

      resolved href still used

      raw attrs (data-inline-embed, data-hm-link, data-url, data-view) present

    add a focused parser/serialization test, likely new frontend/packages/editor/src/tiptap-extension-link/link.test.ts

      parsing <a data-hm-link="hm://..."> restores mark href to canonical hm URL

    optional later: unskip/add copy-paste coverage in frontend/packages/editor/e2e/tests/copy-paste.e2e.ts once embed harness context exists

Recommended scope choice:

    Do the broad fix, not SSR-only.

    Reason: SSR fixes web initial-load copy; data-hm-link also fixes hydrated web/editor copy paths and is low-risk.

Files to modify:

    frontend/packages/editor/src/ssr-render.ts

    frontend/packages/editor/src/tiptap-extension-link/link.ts

    frontend/packages/editor/src/ssr-render.test.ts

    likely new: frontend/packages/editor/src/tiptap-extension-link/link.test.ts

Recap

Proposed solution: make copied HTML round-trippable by preserving canonical hypermedia metadata in the DOM. The core changes are to add raw hm:// data attributes during serialization/render (data-inline-embed, data-hm-link, data-url, data-view) and teach link parsing to prefer those raw attrs over rendered web hrefs. This should fix copy-pasting mentions and embed links between documents, especially from the web SSR path where the current HTML is presentation-only.

    Root cause is frontend-only; no backend/proto change needed.

    Most important file is frontend/packages/editor/src/ssr-render.ts; second is frontend/packages/editor/src/tiptap-extension-link/link.ts.

    Recommended implementation is the broader serializer fix, because it covers both SSR and hydrated web copy paths.

    Best validation is with targeted SSR/link parser tests first; E2E embed paste can be added after harness support.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime