This is my first question on here. So.. I apologize if I ask this poorly.
I've written a syntax highlighted text editor that extends the spark TextArea. The highlighting works by applying ApplyFormatOperations to the various different sections of text. However, as soon as I apply any format operations, I lose all the built in undo/redo functionality. I turn off the colorizing and undo redo comes back.
Here's a simplified version of what I'm doing that wipes out undo/redo. Imagine this gets triggered every time you type a character.
//select everything
var operationState:SelectionState = new SelectionState(textFlow, 0, text.length);
//make an example format.
var exampleFormat:TextLayoutFormat = new TextLayoutFormat();
//everytime we run change the color of all the the text.
m_undoTest = !m_undoTest;
if (m_undoTest) {
exampleFormat.color = "#0839ff"; //make all text bluish.
} else {
exampleFormat.color = "#ff0839"; //make all text redish.
}
//make an operation to apply my formatting.
var formatOperation:ApplyFormatOperation = new ApplyFormatOperation(operationState, exampleFormat, null);
//apply the operation to the text area.
formatOperation.doOperation();
Now my text toggles from red to blue as I type and I can no longer undo. Interestingly if I do the same steps but don't change any properties in the new format. IE don't toggle the color everytime we run. Undo Redo does still work.
Any help would be greatly appreciated, thanks :)