开发者

How does tinyMCE's undo work?

开发者 https://www.devze.com 2023-02-16 06:48 出处:网络
One of my users has a major frustration with the undo feature in tinyMCE. Instead of undoing the last minor change, it undoes many changes. Is this a timing thing were a snapshot is taken every few se

One of my users has a major frustration with the undo feature in tinyMCE. Instead of undoing the last minor change, it undoes many changes. Is this a timing thing were a snapshot is taken every few seconds? Is this configurable?

Additional Information: The user is copying and pasting information from Word to the editor. Then cleaning up the crud that Word leaves behind. This includes deleting the extra blank lines between bullets, deleting extra garbage that the Paste from Word fu开发者_如何学Cnction leaves behind, etc. What happens is she does an oops and deletes too much. So she hits undo and it'll undo a lot more than the last oops. Making her do everything again. The undo has even completely removed all of the text she has pasted in initially (even though that wasn't the last edit).


Undo works in a special way. There are undo steps (snapshots of the editors content) produced by tinymce when special events occur (return, delete, paste, ... ). There is no interval in what snapshots are taken.

You even may catch events and add your own undo steps. Here is an example (i use in one of my own plugins):

// save undo step when space is pressed
ed.onKeyUp.add(function(ed, evt)
  if (evt.keyCode == 32) {
    ed.undoManager.add();
  }
});

For more information have a look at the undomanager section of the tinymce api.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号