Feature Request: prependTransaction


#1

Like appendTransaction but happens before the other transforms.

The current issue this would solve for me is w.r.t the GapCursor and inserting nodes when the selection is a GapCursor. Ideally the GapCursor plugin would provide a prependTransaction that would know how to check if selection is a GapCursor, and if so, it could insert an empty paragraph, setup the new selection and then let the other transforms proceed as normal.

Without this, I need to modify my insert commands to account for the GapCursor case. I’m sorta guessing this may be impossible due to how transforms work (can’t prepend). Is there any other generic solution where my insert commands don’t need to know about gap cursor?


#2

Yeah, more or less—a transform depends on the state before it, and you can’t really retroactively change that without introducing all kinds of problems.

If you write your commands to just treat the selection as a set of ranges, and/or make good use of the selection class’s replace and replaceWith methods, you probably don’t need to special-case gap cursor selections.