-
Notifications
You must be signed in to change notification settings - Fork 167
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
Fix for image selection #1510
Conversation
@@ -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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 mouseSelection = this.editor.getSelectionRangeEx(); | ||
if ( | ||
!safeInstanceOf(mouseTarget, 'HTMLImageElement') && | ||
mouseSelection && | ||
mouseSelection.type === SelectionRangeTypes.ImageSelection |
There was a problem hiding this comment.
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)
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.