在Web应用程序中实现撤消 [英] Implementing undo in a web app

查看:186
本文介绍了在Web应用程序中实现撤消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个地图编辑webapp,我们可以在其中创建和编辑折线,多边形等。我在网上找到关于撤消实现的信息时遇到了麻烦,我发现抱怨我们需要撤消和这是我的命令模式使用闭包但我认为在那个和完整的撤销/重做界面之间有相当的道路。

I'm creating a map editing webapp where we can create and edit polylines, polygons etc. I've some trouble finding informations on undo implementation on the web, I find whining about "we need undo" and "here is my Command pattern using closures" but I think between that and a full undo/redo interface there is quite some road.

所以,这是我的问题(维基的好候选人我想):

So, here are my questions (good candidate for wiki I think):


  • 应该管理堆栈,还是有办法将我的命令发送到浏览器堆叠? (以及如何处理本机命令,如本例中的文本编辑中的文本编辑)

  • 当某些命令是浏览器本机时,如何处理命令压缩(命令分组)

  • 如何检测撤消(ctrl + z)键击?

  • 如果我注册了一个keyup事件,我该如何决定是否阻止默认?

  • 如果没有,我可以在某个地方注册一些非事件处理程序吗?

  • 用户不习惯在网上撤消,我该怎样训练他们探索/撤消我的申请?

  • Should I manage the stack, or is there a way to send my commands to the browser's stack ? (and how do I handle native commands, like text edits in textifields in this case)
  • how do I handle "command compression" (command grouping) when some commands are browser native
  • How do I detect the undo (ctrl+z) keystroke?
  • If I register a keyup event, how do I decide if I prevent default or not?
  • If not, can I register some undoevent handler somewhere ?
  • Users are not used to undo on the web, how can I "train" them to explore/undo on my application ?

全部谢谢。

推荐答案

您需要具有对象创建和删除功能。然后将这些函数传递给撤消管理器。请参阅我的javascript撤消管理器的演示文件: https://github.com/ArthurClemens/Javascript-Undo -Manager

You need to have functions for object creation and deletion. Then pass those functions to the undo manager. See the demo file of my javascript undo manager: https://github.com/ArthurClemens/Javascript-Undo-Manager

演示代码显示画布,但代码是不可知的。

The demo code shows canvas, but the code is agnostic.

它没有不包含键绑定,但可以帮助您完成第一步。

It doesn't contain key bindings, but may help you with the first steps.

我自己在Web应用程序中使用了这个,其中包含用于撤消和重做的按钮,旁边是保存。

Myself I have used this in a web application with buttons for undo and redo, next to save.

这篇关于在Web应用程序中实现撤消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆