fix(editor): let image captions be selected as document text - #952
Open
horacioh wants to merge 19 commits into
Open
fix(editor): let image captions be selected as document text#952horacioh wants to merge 19 commits into
horacioh wants to merge 19 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Drop the rebase of fork commits onto main: the sync workflow now force pushes upstream/main straight to main, and lives on custom-images (the default branch) together with every other fork change. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
main is mirrored from upstream every day; custom-images only moves when a new X.Y.Z tag shows up, rebased onto the tag itself so <version>-custom is exactly that release plus the fork commits. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Tags pushed with GITHUB_TOKEN do not trigger workflows, so the GHCR build has to be dispatched explicitly at the new <version>-custom tag. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Image captions render inline content, but BlockSelectionWrapper wrapped the whole image subtree in contenteditable=false, making the caption its own editing host so ProseMirror discarded every caption selection, and the media wrapper's draggable=true turned caption drags into native drags. Fragment actions (Copy Link, Comment) on caption ranges were unreachable. Caption Enter handling moves from a React onKeyDown (which no longer receives the event now that the caption is in the outer editing host) to the Enter keymap, where it was already special-cased as a no-op. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…caption TextSelection.near returns a NodeSelection when the block after the image is an atom (video, file, embed); rewrapping its position in TextSelection.create built a text selection with no textblock to live in. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…vior Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #925: caption text could not be range-selected in edit mode, so the fragment actions built on selections (Copy Link, Comment →
#blk-image[start:end]) were unreachable for captions.Two independent causes, both in the image render path:
BlockSelectionWrapperwrapped the whole image subtree incontentEditable={false}. A ProseMirror view manages a single contenteditable range, so the caption (which is real inline content of the image block) became its own editing host:view.hasFocus()stayed false and prosemirror-view discarded every caption selection.MediaContainer's outer wrapper wasdraggable=true, so caption mouse drags became native drags instead of text selection.The media surface itself stays
contentEditable={false}and draggable, so click-to-select, side-menu drag, and reorder are unchanged.Third change, a consequence of the first: Enter in a caption was handled by a React
onKeyDownon the caption element, and the Enter keymap explicitly no-op'd for image blocks to defer to it. Now that the caption is part of the outer editing host, keydown targetsdiv.ProseMirrorand never reaches that React handler — Enter silently did nothing. The behavior moves into the keymap branch that used to be the no-op:Tests
media-container.test.tsx: new assertions that no caption ancestor iscontenteditable=falseordraggable=true, and that the media surface keeps both. Both failed before the fix. The three unit tests covering the removed React Enter handler are deleted — that behavior now lives in the keymap and is covered end-to-end instead.image-caption.e2e.ts: keyboard selection (asserting a non-emptyTextSelectioninside the image block,view.hasFocus(), and the formatting toolbar appearing), mouse drag selection, bold on a caption range, and Enter with the image as the last block.embed-editor,readonly-viewer-galleryandBlockManipulationExtensionreproduce unchanged on the base branch.docs/projects/image-caption-selection.mdholds the investigation and the remaining phased test plan (media regression sweep, clipboard/SSR, mobile), plus links to the follow-up issues #926–#931.Link to Devin session: https://app.devin.ai/sessions/923dddc749c646c8965bc2110a7d9ab4
Requested by: @horacioh