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

Fix for image selection #1510

merged 3 commits into from
Jan 18, 2023

Conversation

juliaroldi
Copy link
Contributor

Bug: if ImageEditPlugin and TableCellSelection are disable, image selection does work properly.
After an image is selected, is not possible unselect it.

Fix: verify if a element was click and if the a image is selected, then if the condition is true, select the element selected.

imageEditBUGTEST

@@ -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.

Comment on lines 69 to 73
const mouseSelection = this.editor.getSelectionRangeEx();
if (
!safeInstanceOf(mouseTarget, 'HTMLImageElement') &&
mouseSelection &&
mouseSelection.type === SelectionRangeTypes.ImageSelection
Copy link
Collaborator

Choose a reason for hiding this comment

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

You just need to check if the target element is same with current selected image:

if (mouseSelection.type != Image || mouseSelection.image != event.rawEvent.target) {
select(null)

@juliaroldi juliaroldi merged commit b30b4f2 into master Jan 18, 2023
@juliaroldi juliaroldi deleted the u/juliaroldi/image-selection-bug branch January 18, 2023 13:04
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.

Images selection does not disappear
2 participants