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

Undo/Redo Options #320

Closed
agrimgupta92 opened this issue Jul 18, 2018 · 3 comments · May be fixed by #741
Closed

Undo/Redo Options #320

agrimgupta92 opened this issue Jul 18, 2018 · 3 comments · May be fixed by #741

Comments

@agrimgupta92
Copy link

agrimgupta92 commented Jul 18, 2018

Is there any plan to add the option to undo/redo in polygons/polylines? I see from previous issues that you plan to add them. Can you please tell when the feature will be ready or suggest a temporary/hacky way to get it to work?
Update: I was able to get "undo" working as this pull request does this: #284
Is it possible to add redo also?

@codeofsumit
Copy link
Contributor

@agrimgupta92 I can't give any timelines, I work on leaflet.pm when I find the time.
a solution to add redo is to do this inside your application. Whenever the user changes something, or "undoes" something, save the layer and show a "redo" button. When the user clicks it, overwrite the layer with the saved one.

I will add #284 soon, I'm not sure about redo though.

I will mark this issue as a feature request, especially for Redo. Anyone who is also interested in this, please give it an upvote 👍

@Falke-Design
Copy link
Collaborator

Hey guys,
let us discuss how this should work.

  1. For which modes / shapes should be undo / redo able to called?
  2. Should be undo / redo called per layer / mode or on the complete project? The problem will be, that if undo is called over the project, we need to save the order when which layer was changed, this is not so easy
  3. How often should be undo able to call?
    ...

@henrikmaa
Copy link
Contributor

henrikmaa commented Nov 6, 2020

This is my idea of how it should work

Modes:

Edit: cancel was not in this feature request, but i think also cancel editing should be included in this.

This is my cancel edit just for inspiration

//this code is not perfect
//currentLayer  = e.target
//restoreLayer = e.target from pm:enable
//restoreLatLng = restoreLayer.getLatLng()

static cancelEditOnLayer = (map, currentLayer, restoreLayer, restoreLatLng) => {
    if (!(restoreLayer instanceof L.Polyline)) {
      restoreLayer.setLatLng(restoreLatLng)
    } else {
      restoreLayer.setLatLngs(restoreLatLng)
    }
    currentLayer.pm.disable()
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants