Skip to main content
Participating Frequently
February 8, 2010
Answered

Undo removes styleName attribute

  • February 8, 2010
  • 1 reply
  • 726 views

Is the the bug in my test case or in the TLF code (Flex 4.0.0.13555)?

public class UndoBugTest extends TestCase
{

    //==========================================================================
    //
    //  set up and tear down
    //
    //--------------------------------------------------------------------------
    private var app:Application
    private var container:UIComponent
    private const ANY_URL:String = "http://livedocs.adobe.com/"
       
    protected function get initialImport():XML {
        return <TextFlow color="#000000" fontFamily="Tahoma" fontSize="14" fontStyle="normal" fontWeight="normal" lineHeight="130%" textDecoration="none" whiteSpaceCollapse="preserve" xmlns="http://ns.adobe.com/textLayout/2008">
                              <p>
                                <span>aaa</span>
                              </p>
                              <p styleName="h1">
                                <span>bbb</span>
                              </p>
                            </TextFlow>
    }
   
    protected function get initialImportString():String {
        return null
    }
   
    protected var initialImportXMLString:String = initialImport.normalize().toXMLString()
   
    protected var editManager:IEditManager
    protected var undoManager:IUndoManager
    protected var textFlow:TextFlow
   
   
    override public function setUp(): void
    {
        container = new UIComponent()
        var controllerOne:ContainerController = new ContainerController(container, 500, 500)
        app = Application(FlexGlobals.topLevelApplication)
        app.addElement(container)
       
        textFlow = TextConverter.importToFlow(initialImport, TextConverter.TEXT_LAYOUT_FORMAT)
       
        undoManager = new UndoManager()
        editManager = new EditManager(undoManager)
        textFlow.interactionManager = editManager
       
        textFlow.flowComposer.addController(controllerOne);
        textFlow.flowComposer.updateAllControllers();
    }
   
    override public function tearDown():void
    {
        app.removeElement(container)
    }
   
    //==========================================================================
    //
    //  tests
    //
    //--------------------------------------------------------------------------   
    public function test_crossing_paragraphs(): void
    {
        editManager.selectRange(1,5)
        editManager.applyLink(ANY_URL, "_self", true)
       
        undoManager.undo()
        assertEquals(initialImport, exportXMLString())
    }

     protected function exportXMLString():String {
        var export:XML = TextConverter.export(textFlow, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.XML_TYPE) as XML
        return export.normalize().toXMLString()
    }
}

This topic has been closed for replies.
Correct answer robin_briggs

In this example, the range given for applyLink goes across paragraphs, which is not allowed, so the link is getting shortened to cover just one paragraph. When it is undone, the second paragraph is not left in the correct state -- possibly because of the way the paragraphs merged from the paste that happens as a result of the undo. This is a bug that happens only where the range for applyLink is too big. If the range is contained within a single paragraph, the undo looks correct. Thanks for reporting it!

- robin

1 reply

Adobe Employee
February 9, 2010

I'm looking into this now. Looks like the styleName property is indeed getting dropped.

- robin

robin_briggsCorrect answer
Adobe Employee
February 9, 2010

In this example, the range given for applyLink goes across paragraphs, which is not allowed, so the link is getting shortened to cover just one paragraph. When it is undone, the second paragraph is not left in the correct state -- possibly because of the way the paragraphs merged from the paste that happens as a result of the undo. This is a bug that happens only where the range for applyLink is too big. If the range is contained within a single paragraph, the undo looks correct. Thanks for reporting it!

- robin

Participating Frequently
February 9, 2010

Robin, thanks for the feedback.

Marc