WIP: feat: ignore transactions which were not added to history #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "phikes/ignore-transactions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
prosemirror-historyreads a metadata fieldaddToHistoryand doesn'tallow to undo changes if a transactions sets it to
false. I think itsreasonable that this plugin ignores these transactions as well as they
are not undoable by the undo command anyways.
Why?
If your questions targets the reasoning why the plugin should ignore transactions with
addToHistoryset tofalsethe reasoning is in the second part of the sentence. My scenario is as follows:undoInputRulecommandBtw since this is probably a breaking change I could also add a configuration option to
inputRulesso it's opt-in behaviour:Ah, right, you're trying to avoid clearing the undo logic when something like a collaborative change comes in. But as it is, this patch isn't correct—if, for example, a non-history change inserts or deletes content before the last inputrules change, the positions in that stored change no longer align with the current document.
Thanks for the response! Makes total sense. I am fairly new to Prosemirror and am trying to figure out how to solve the problem you mentioned. As soon as there is a change that affects not only the position of an original input rule change, but also maybe it's contents and that change is not added to history I think we could not recover. As such I'd think of two options:
Look into position mapping—it is probably possible to update the undoable data in a safe way.
This is what I thought about, however we would still need to discard the transactions as soon as another transaction comes along which modifies inside of the (mapped) range of the original transaction, no?
So in pseudo-code something like this?
This is the same case as step rebasing for history or collab editing. You can map steps through anything. Sometimes the result will be null (the changed content was deleted) and sometimes the step can't be applied anymore (
maybeStepwill return failure), so this becomes a bit more tricky to manage (probably don't want to store the plain transaction anymore, but rather an array of steps), but should be doable.Thanks for the response, really appreciate it. I will see if I can make sense out of it and build it into my patch.
Pull request closed