Line Breaks using span.splitAt
I am trying to implement a function that inserts BreakElements at a given position when the user presses the Shift+Enter keys. In order to prevent the default behavior of the EditManager (splitParagraph), i tweaked the keyDownHandler to differenciate between Enter and Shift-Enter).
It works fine, but i would like to define an operation for inserting breaks, so the user can undo it, just like undoing any TextOperation, I started making my own class that extends FlowTextOperation and filled in this code in the doOperation method
public override function doOperation():Boolean
{
var span:SpanElement = textFlow.findLeaf(textFlow.interactionManager.activePosition);
var p:ParagrahElement = span.getParagraph();
span.splitAtPosition((textFlow.interactionManager.activePosition - span.getAbsoluteStart());
var br:BreakElement = new BreakElement();
var index:int = p.getChildIndex(span);
p.addChildAt(index+1,br);
return true;
}
Any ideas on how to implement the undo method?
Is it impossible because inserting a FlowElement is not managed by the EditManager and so the stack of operations is flushed?
thanks!
