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

Shadow dom image wrapper #1520

Merged
merged 10 commits into from
Jan 23, 2023
Merged

Conversation

juliaroldi
Copy link
Contributor

@juliaroldi juliaroldi commented Jan 19, 2023

Instead of insert the image wrapper with a cloned image outside the editor and overlay the image wrapper, add the image wrapper with a cloned image into shadow dom and let it handle hiding the original image. After this change, the code to handle zoom issues and image overlaying the toolbar above the editor will be not needed. Also, code to add auto low to the rotator handle, remove the wrapper before dispose the editor and avoid drop image while in editing mode was added.

shadowDomFix

@juliaroldi juliaroldi marked this pull request as ready for review January 19, 2023 21:24
@JiuqingSong
Copy link
Collaborator

  1. We only need to disable drag when in editing state. If image is not in editing (editing wrapper not shown), drag and drop can should still work.

image

Create a long rectangle image, insert it. Then rotate, I think the size of wrapper SPAN is wrong (or incorrectly rotated?) That causes the image float higher than other text. Maybe not a new issue, but better also fix it.

this.disposer = editor.addDomEventHandler('blur', this.onBlur);
this.disposer = editor.addDomEventHandler({
blur: () => this.onBlur,
drop: e => e.preventDefault(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should disable onDrag instead, and only disable when image is in editing.

@JiuqingSong
Copy link
Collaborator

#1503

@juliaroldi juliaroldi marked this pull request as draft January 20, 2023 22:56
@juliaroldi juliaroldi marked this pull request as ready for review January 23, 2023 15:02
@juliaroldi juliaroldi changed the title U/juliaroldi/shadow dom image wrapper Shadow dom image wrapper Jan 23, 2023
Comment on lines 200 to 211
// When left click in a image that already in editing mode, do not quit edit mode
// This will avoid another image into the editor after drag
const mouseTarget = e.rawEvent.target;
const button = e.rawEvent.button;
if (
this.shadowSpan !== mouseTarget ||
(this.shadowSpan === mouseTarget && button !== 0) ||
this.isCropping
) {
this.setEditingImage(null);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually the issue still happens after this fix:
dragimage

I suggest we handle ondrag event, and if the dragging is happened when this.image is not null, always do preventDefault() so drag will not happen at all.

@juliaroldi juliaroldi force-pushed the u/juliaroldi/shadow-dom-image-wrapper branch from 6795fc4 to 4aca7d0 Compare January 23, 2023 19:15
@juliaroldi juliaroldi merged commit af3d4ea into master Jan 23, 2023
@juliaroldi juliaroldi deleted the u/juliaroldi/shadow-dom-image-wrapper branch January 23, 2023 20:32
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.

[Image Resize] It exits the image editing mode automatically on scrolling
2 participants