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

Disable the logic in ImageEdit plugin to set image editing when users click images #1405

Merged

Conversation

haven2world
Copy link
Contributor

We extended this plugin for mobile user and used a custom way to activate image editing. So we need an option to disable the default one.

@JiuqingSong
Copy link
Collaborator

If you extended this class, I think you don't need to add such parameter. Instead, you just need to override onPluginEvent, and don't call super.onPluginEvent() if the event is SelectionChanged event.

@JiuqingSong
Copy link
Collaborator

class MyImageEdit extends ImageEdit {
  onPluginEvent(e) {
    if (e.type != PluginEventType.SelectionChanged) {
       super.onPluginEvent(e);
   }
 }
}

@haven2world
Copy link
Contributor Author

That's our current temporary workaround actually. But the point is, on the one hand, we want to leverage the implementation of ImageEdit as more as possible, we just want to avoid this plugin handling users' click to activate the editing, but we still want to keep other events handling logic implemented in this plugin. On the other hand, before the recent change, we had some workaround, but it was broken due to the latest upgrade. So we'd like to add this parameter to let the people working on this plugin know that they should make sure this option always works. Or we have to patch our workaround again and again.

@JiuqingSong
Copy link
Collaborator

That's our current temporary workaround actually. But the point is, on the one hand, we want to leverage the implementation of ImageEdit as more as possible, we just want to avoid this plugin handling users' click to activate the editing, but we still want to keep other events handling logic implemented in this plugin. On the other hand, before the recent change, we had some workaround, but it was broken due to the latest upgrade. So we'd like to add this parameter to let the people working on this plugin know that they should make sure this option always works. Or we have to patch our workaround again and again.

Ok in that case, we need a better way. You may noticed there are two states of image editing:

  1. resize/rotate
  2. crop
    current the behavior for onclick is always to resize/rotate. You can add a parameter for default behavior when image is selected, and then you pass in ImageEditOperation.None so that it will do nothing.
interface ImageEditOptions {
  ...
  onSelectState: ImageEditOperation; /* default: ImageEditOperation.Resize */
}

@haven2world haven2world force-pushed the haowchen/image-edit-manually branch from 966b2e9 to aff7d0b Compare November 15, 2022 10:21
@haven2world
Copy link
Contributor Author

Updated

@haven2world
Copy link
Contributor Author

Hey @JiuqingSong , could you help merge this PR? I don't have the permission

@JiuqingSong JiuqingSong merged commit c07624c into microsoft:master Nov 16, 2022
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