Skip to content

Fix image selection for context menu on Shift+F10 - #3418

Merged
juliaroldi merged 4 commits into
masterfrom
u/juliaroldi/keyboard-selection
Jul 29, 2026
Merged

Fix image selection for context menu on Shift+F10#3418
juliaroldi merged 4 commits into
masterfrom
u/juliaroldi/keyboard-selection

Conversation

@juliaroldi

@juliaroldi juliaroldi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

When a range selection contains a single image, pressing Shift+F10 (the keyboard shortcut that opens the context menu) now promotes the selection to an image selection before the menu opens. This ensures the context menu operates on the image rather than the surrounding text range. Implemented in SelectionPlugin.ts by detecting Shift+F10 on a range selection and, when isSingleImageInSelection returns an image, calling setDOMSelection with an image selection.

ImageContextMenuF10

The demo MainPane.tsx change moves imageEditPlugin initialization into render() so it reflects current init state.

How to test

  1. Manual check: In the demo editor, click just before/around a single image so it's within a range selection, then press Shift+F10.
    • Before this fix: the context menu opens against the text range.
    • After this fix: the image becomes selected (image selection) before the context menu opens.

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-29 17:49 UTC

@juliaroldi
juliaroldi marked this pull request as ready for review July 28, 2026 18:49

render() {
const theme = getTheme(this.state.isDarkMode);
this.imageEditPlugin = this.state.initState.pluginList.imageEditPlugin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can recreate plugin in getToggleablePlugins

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recreate the plugin in getToggleablePlugins will make the ribbons buttons lose the plugin reference. I added a change to reset the plugin when we reset the editor, so the plugin will be reset in the editor and for ribbon buttons.

@juliaroldi
juliaroldi merged commit 82f273d into master Jul 29, 2026
8 checks passed
@juliaroldi
juliaroldi deleted the u/juliaroldi/keyboard-selection branch July 29, 2026 17:49
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