Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for image selection #1510

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/roosterjs-editor-core/lib/corePlugins/ImageSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ export default class ImageSelection implements EditorPlugin {
} else if (event.rawEvent.button === mouseLeftButton) {
this.editor.select(target);
}
} else if (safeInstanceOf(target, 'HTMLElement')) {
const mouseSelection = this.editor.getSelectionRangeEx();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just let the browser handle the mouse selection?

I think you can check this in MouseDown event instead, and if target element is not current image, just unselect it, then browser should be able to handle the rest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand. I also think we need to check if the last selection is a image to not cause problems with table cell selection.

const range = this.editor.getSelectionRange();
if (
range &&
mouseSelection &&
mouseSelection.type === SelectionRangeTypes.ImageSelection
) {
this.editor.select(range);
event.rawEvent.stopPropagation();
}
}
break;
case PluginEventType.KeyUp:
Expand Down