Skip to content

refactor(editor): extract BlockSelectionWrapper for media block selection#623

Merged
horacioh merged 2 commits into
mainfrom
block-selection-wrapper
May 19, 2026
Merged

refactor(editor): extract BlockSelectionWrapper for media block selection#623
horacioh merged 2 commits into
mainfrom
block-selection-wrapper

Conversation

@horacioh
Copy link
Copy Markdown
Collaborator

@horacioh horacioh commented May 18, 2026

Screen.Recording.2026-05-18.at.18.59.27.mov

Summary

  • Extract BlockSelectionWrapper component from media-render.tsx into block-selection-wrapper.tsx — centralizes selection logic previously duplicated across media blocks
  • Remove selected/setSelected props from DisplayComponentProps, MediaContainer, MediaForm, and all display components (ImageDisplay, VideoDisplay, FileDisplay, WebEmbedDisplay, EmbedDisplay)
  • Add blockSelection.css with .bn-media-selected outline styles and CSS-class-based visibility for .replace-btn and .sel-btn buttons — replaces inline selected && 'opacity-100' conditionals
  • Wrap MediaRender, ButtonBlockView, QueryBlock, and embed render paths in BlockSelectionWrapper
  • Extract selectInsertedBlock helper in slash-menu-items.tsx — deduplicates repeated view.dispatch(state.tr.scrollIntoView()) calls after slash-menu insertions, now uses NodeSelection to auto-select the inserted block
  • Video iframe pointer-events logic simplified: CSS-class toggle replaces four-way selected-dependent conditional
  • Add placeholder:text-foreground/50 to URL inputs in embed and media form for better placeholder contrast

@horacioh horacioh force-pushed the block-selection-wrapper branch from 5b5d50e to a863c52 Compare May 18, 2026 17:15
@horacioh
Copy link
Copy Markdown
Collaborator Author

@GaboHBeaumont

@GaboHBeaumont
Copy link
Copy Markdown
Collaborator

Great! Selecting non-text blocks right now hurts a lot rn!
I took a screenshot of this image from your video. Why does the image below have a green background when you select the image above?
image

@horacioh
Copy link
Copy Markdown
Collaborator Author

@GaboHBeaumont good catch. I fixed that and also another nested selection block issue.

horacioh added 2 commits May 19, 2026 11:21
…tion

Replace inline selected/setSelected state and useEditorSelectionChange
calls in each media block with a shared BlockSelectionWrapper component.
Remove selected/setSelected props from MediaContainer and DisplayComponent
interfaces.
Use position-based content range check for TextSelection instead of
getNodesInSelection utility. Media blocks (image, video, file, embed,
etc.) now skip the full-block-selected background via CSS :has() selector
to avoid double-highlight with bn-media-selected styling.
@horacioh horacioh force-pushed the block-selection-wrapper branch from 4d36fb1 to 1f006b0 Compare May 19, 2026 09:22
@horacioh horacioh merged commit 9c4cc18 into main May 19, 2026
7 checks passed
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.

2 participants