tinymce / tinymce

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular
https://www.tiny.cloud
Other
15.09k stars 2.24k forks source link

I can't find what I'm looking for: api/tinymce/tinymce.undomanager.html #6824

Open brichwin opened 3 years ago

brichwin commented 3 years ago

I've tried to understand how to use the undo manager when authoring a TinyMCE plugin. I don't understand the overall philosophy:

For example, my plugin provides an interface for selecting text and wrapping it with a so they can markup the human language changes in the text. It does that by applying a format. I've tried every combo I can imagine to make it work with undo to no avail.

tylerkelly13 commented 3 years ago

Hi @brichwin,

The TinyMCE developers have better understanding of this. I'll transfer this ticket to tinymce/tinymce so they can answer these questions and transfer the ticket back so I can document the explanation. I'll keep an eye on this ticket in case it gets closed by accident rather than transferred.

Tyler

ericbf commented 1 year ago

Nothing ever came of this? I’m also trying to work with the UndoManager, but can’t seem to get the desired functionality out of it. In my case, I just need to clear the redo stack (as if the user made a change, but without adding anything to the undo stack). Is this possible?

TheSpyder commented 1 year ago

Sadly no, the index (which indicates where in the data array the split from undo to redo begins) is a private variable. https://github.com/tinymce/tinymce/blob/02a9b5480ffd56b4ffda14e5b8d0afb75c76ad3d/modules/tinymce/src/core/main/ts/api/UndoManager.ts#L19

You could possibly monitor for undo events and try to mirror the index, so you can shave off unwanted redo events, but I don't know how well that would work so I can't really recommend it.

tiny-stale-bot commented 1 month ago

This issue is stale because it has been open 365 days with no activity. Please comment if you wish to keep this issue open or it will be closed in 30 days.

ericbf commented 1 month ago

This would still be very useful.