Skip to main content
Participating Frequently
Feb 8, 2010 10:47 AM UTC
Answered

Undo removes styleName attribute

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 is closed to new replies. Start a new post to keep the conversation going.
robin_briggsCorrect answer
Adobe Employee
Feb 9, 2010 7:14 AM UTC

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

3 replies

Adobe Employee
Feb 9, 2010 1:56 AM UTC

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

- robin

Translate
robin_briggsCorrect answer
Adobe Employee
Feb 9, 2010 7:14 AM UTC

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

Translate
Participating Frequently
Feb 9, 2010 8:02 AM UTC

Robin, thanks for the feedback.

Marc

Translate