Now Verbosio can delete a range of nodes and undo that deletion.
I actually was scratching my head last night trying to figure out how I’d break this thorny problem down into manageable pieces. This morning, it occurred to me mozilla.org’s
editor code had already solved this problem in the old Composer application in SeaMonkey, with a DeleteRangeTxn class. If I could create instances of that class from chrome or JS-based component code, I’d be in business.
Unfortunately, nobody seems to have done that before, either. So I filed bug 363290 for that. The patch is in the review pipeline.
I also found out, from reading the code behind this old transaction class, that I needed a nsIEditor object… something I’ve been avoiding until now in Verbosio. So I wrote up a quick & dirty nsIEditor component with most of the methods and properties not implemented. I expect, right now, to use it only as a placeholder for other calls into native transaction code.
If ETNA and Verbosio merge, hopefully ETNA will have a more complete nsIEditor implementation, and use it better than I do. For now, it’ll work, though.
I estimate that it would have taken me at least a week to implement deleting a selection from the document before I thought of Composer. By reusing that code, I reduced my implementation time down to about four hours (nine to ten if you count the long breaks I took today.) That sort of time savings makes me a happy coder.