Skip to content

feat: add link embeds and mentions to editor - #140

Merged
h4yfans merged 15 commits into
mainfrom
feat/link-embeds-and-mentions
Apr 4, 2026
Merged

feat: add link embeds and mentions to editor#140
h4yfans merged 15 commits into
mainfrom
feat/link-embeds-and-mentions

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

What

Add YouTube embed blocks, link mentions, and a paste-link menu to the BlockNote editor with full inbox link preview support.

Why

Users paste URLs frequently in notes. Instead of raw links, this adds rich inline previews — YouTube embeds play inline, link mentions show metadata, and the paste menu lets users choose the format (plain URL, mention, or embed).

How

  • YouTube embed block: custom BlockNote block with <iframe> player, markdown round-trip via ![youtube](url) syntax
  • Link mention inline content: custom inline spec resolving URL metadata (title, favicon) via main process IPC
  • Paste link menu: intercepts paste events containing URLs, offers URL/mention/embed selection
  • CSP update: allows frame-src https://www.youtube.com for iframe embeds
  • Inbox link preview: refactored to use mention/embed format; YouTube links get inline player
  • Reddit metadata: JSON API extraction with bot detection bypass for link previews
  • Shared YouTube utility: extractYouTubeVideoId() in packages/shared for cross-package reuse

Type

  • feat — new feature

Test plan

  • Unit tests added/updated
  • Manual testing (describe below)

Manual: pasted YouTube/Reddit/generic URLs in editor, verified embed rendering, markdown round-trip, inbox link previews, paste menu behavior.

Checklist

  • Self-reviewed the diff
  • No hardcoded secrets or credentials
  • Files stay under ~500 LOC
  • Follows immutable data patterns

h4yfans added 15 commits April 4, 2026 19:49
Reddit blocks HTML scrapers aggressively, so use their public JSON API
with old.reddit.com fallback. Also expands bot page title detection for
verification pages.
url-metadata.ts provides extractDomain and cached fetchLinkPreview.
youtube-utils.ts re-exports shared extractor with thumbnail/embed URLs.
Delegates inbox-utils extractDomain to url-metadata.
Rich inline link chip with favicon, domain, and title. Renders as
clickable pill, parses from both data attributes and markdown mention
format. Includes CSS for .link-mention styling.
Custom BlockNote block renders click-to-play YouTube player. Markdown
serializes as \![embed](url) and parser splits by embed markers to
reconstruct blocks.
When pasting a URL, shows a popover to choose: plain URL, rich mention,
or embed (for YouTube). Supports keyboard navigation and click-away
dismiss.
Add frame-src youtube-nocookie.com, broaden img-src to https: for
favicons/thumbnails, and scope CSP header injection to own pages only
so external resource responses aren't broken.
Register linkMention + youtubeEmbed in editor schema. Wire paste link
menu handlers in ContentArea for mention/embed conversion. Hydrate
link mention favicons on document load via use-editor-sync.
Replace [Open Original](url) with rich mention format for links and
\![embed](url) for YouTube when filing inbox items to notes. Updates
tests to match new output format.
Click-to-play YouTube embed in inbox detail view with play button
overlay. Hides excerpt and domain bar for YouTube items to keep
the UI focused on the video.
@h4yfans
h4yfans merged commit ba27ff5 into main Apr 4, 2026
2 checks passed
@h4yfans
h4yfans deleted the feat/link-embeds-and-mentions branch April 4, 2026 18:12
h4yfans added a commit that referenced this pull request May 6, 2026
feat: add link embeds and mentions to editor
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