-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(text): support Link Mention format
- Fixed an issue where the newly introduced "Link Mention" feature in Notion was unsupported, causing an "unsupported text format" error. - Now, it's correctly rendered in a way similar to Notion's functionality.
- Loading branch information
Showing
4 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,72 @@ | ||
import * as React from 'react' | ||
|
||
export type LinkMentionData = { | ||
href: string | ||
title: string | ||
icon_url: string | ||
description: string | ||
link_provider: string | ||
thumbnail_url: string | ||
} | ||
|
||
export function LinkMention({ metadata }: { metadata: LinkMentionData }) { | ||
return ( | ||
<span className='notion-link-mention'> | ||
<LinkMentionInline metadata={metadata} /> | ||
<LinkMentionPreview metadata={metadata} /> | ||
</span> | ||
) | ||
} | ||
|
||
function LinkMentionInline({ metadata }: { metadata: LinkMentionData }) { | ||
return ( | ||
<a | ||
href={metadata.href} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
className='notion-link-mention-link' | ||
> | ||
<img | ||
className='notion-link-mention-icon' | ||
src={metadata.icon_url} | ||
alt={metadata.link_provider} | ||
/> | ||
{metadata.link_provider && ( | ||
<span className='notion-link-mention-provider'> | ||
{metadata.link_provider} | ||
</span> | ||
)} | ||
<span className='notion-link-mention-title'>{metadata.title}</span> | ||
</a> | ||
) | ||
} | ||
|
||
function LinkMentionPreview({ metadata }: { metadata: LinkMentionData }) { | ||
return ( | ||
<div className='notion-link-mention-preview'> | ||
<article className='notion-link-mention-card'> | ||
<img | ||
className='notion-link-mention-preview-thumbnail' | ||
src={metadata.thumbnail_url} | ||
alt={metadata.title} | ||
/> | ||
<div className='notion-link-mention-preview-content'> | ||
<p className='notion-link-mention-preview-title'>{metadata.title}</p> | ||
<p className='notion-link-mention-preview-description'> | ||
{metadata.description} | ||
</p> | ||
<div className='notion-link-mention-preview-footer'> | ||
<img | ||
className='notion-link-mention-preview-icon' | ||
src={metadata.icon_url} | ||
alt={metadata.link_provider} | ||
/> | ||
<span className='notion-link-mention-preview-provider'> | ||
{metadata.link_provider} | ||
</span> | ||
</div> | ||
</div> | ||
</article> | ||
</div> | ||
) | ||
} |
This file contains 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 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