-
Notifications
You must be signed in to change notification settings - Fork 9
Copy-pasting mentions (embed links) between documents does not work #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GaboHBeaumont
merged 1 commit into
main
from
issue-647-copy-pasting-mentions-embed-links
May 22, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
frontend/packages/editor/src/embed-block.parseHTML.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import {describe, expect, it} from 'vitest' | ||
|
|
||
| import {vi} from 'vitest' | ||
|
|
||
| vi.mock('./blocknote/react', () => ({ | ||
| createReactBlockSpec: (spec: any) => spec, | ||
| })) | ||
|
|
||
| import {EmbedBlock} from './embed-block' | ||
|
|
||
| describe('EmbedBlock.parseHTML', () => { | ||
| it('claims SSR embed card anchors before generic link parsing', () => { | ||
| expect(EmbedBlock.parseHTML).toEqual( | ||
| expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| tag: 'a[data-content-type=embed]', | ||
| priority: 1001, | ||
| }), | ||
| ]), | ||
| ) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import {describe, expect, it} from 'vitest' | ||
| import {createInlineEmbedNode, inlineEmbedClipboardText} from './mentions-plugin' | ||
|
|
||
| describe('inlineEmbedClipboardText', () => { | ||
| it('serializes inline embeds to a non-empty clipboard fallback', () => { | ||
| expect(inlineEmbedClipboardText('hm://uid1/docs/page')).toBe('hm://uid1/docs/page') | ||
| }) | ||
|
|
||
| it('returns empty string when link is missing', () => { | ||
| expect(inlineEmbedClipboardText('')).toBe('') | ||
| }) | ||
|
|
||
| it('parses data-inline-embed anchors before generic links', () => { | ||
| const parseRules = createInlineEmbedNode().config.parseHTML?.() || [] | ||
|
|
||
| expect(parseRules).toEqual( | ||
| expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| tag: 'a[data-inline-embed]', | ||
| priority: 1000, | ||
| }), | ||
| ]), | ||
| ) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
frontend/packages/editor/src/tiptap-extension-link/link.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import {describe, expect, it} from 'vitest' | ||
| import {buildRenderedLinkAttributes, getLinkAttrsFromElement} from './link' | ||
|
|
||
| describe('link DOM round-tripping', () => { | ||
| it('preserves canonical hm href in data-hm-link while rendering a platform href', () => { | ||
| const attrs = buildRenderedLinkAttributes( | ||
| { | ||
| href: 'hm://uid1/docs/page', | ||
| class: 'link', | ||
| }, | ||
| (url) => (url === 'hm://uid1/docs/page' ? 'https://example.com/docs/page' : url), | ||
| ) | ||
|
|
||
| expect(attrs.href).toBe('https://example.com/docs/page') | ||
| expect(attrs['data-hm-link']).toBe('hm://uid1/docs/page') | ||
| expect(attrs.class).toContain('text-link') | ||
| }) | ||
|
|
||
| it('prefers data-hm-link over rendered href while parsing', () => { | ||
| const element = document.createElement('a') | ||
| element.setAttribute('href', 'https://example.com/docs/page') | ||
| element.setAttribute('data-hm-link', 'hm://uid1/docs/page') | ||
| element.setAttribute('class', 'link text-link') | ||
|
|
||
| expect(getLinkAttrsFromElement(element)).toEqual({ | ||
| href: 'hm://uid1/docs/page', | ||
| class: 'link text-link', | ||
| }) | ||
| }) | ||
|
|
||
| it('falls back to href when no canonical raw attr is present', () => { | ||
| const element = document.createElement('a') | ||
| element.setAttribute('href', 'https://example.com/docs/page') | ||
|
|
||
| expect(getLinkAttrsFromElement(element)).toEqual({ | ||
| href: 'https://example.com/docs/page', | ||
| }) | ||
| }) | ||
|
|
||
| it('does not claim inline embed anchors as normal links', () => { | ||
| const element = document.createElement('a') | ||
| element.setAttribute('href', 'https://example.com/docs/page') | ||
| element.setAttribute('data-hm-link', 'hm://uid1/docs/page') | ||
| element.setAttribute('data-inline-embed', 'hm://uid1/docs/page') | ||
|
|
||
| expect(getLinkAttrsFromElement(element)).toBe(false) | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When copy pasting a mention in other platforms other than seed, the pasted text will be a raw hm link. Is this intended?