Skip to main content
Participating Frequently
September 17, 2010
Question

spark textarea : enter key split paragraph

  • September 17, 2010
  • 1 reply
  • 2911 views

I'm new in this forum so hi everybody !

I have a question about the spark textarea and TLF. I try to do an editor (like wysiwyg but more simpler) and I have a problem :

When I type for example :

------

test line 1

test line 2

-------

the enter key split the paragraphs. I can see it when I do

     TextConverter.export(editor.textFlow,TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE).toString();

It returns

     "<p><span>test line 1</span></p><p><span>test line 2</span></p>" instead <p><span>test line 1<br/>test line 2</span></p>

I tried to set a configuration for the textflow of the textarea like this :

               var config:Configuration = TextFlow.defaultConfiguration;
                config.manageEnterKey = false;
               
                editor.textDisplay.textFlow = new TextFlow(config);

I used this to stop the splitting but nothing happens. When I try the exportation with TextConverter, it return the same thing :

     <p><span>test line 1</span></p><p><span>test line 2</span></p>

Is it possible to have br tag or no ?

Thanks in advance ^^

This topic has been closed for replies.

1 reply

Adobe Employee
September 20, 2010

It is possible.

Your first move, to set manageEnterKey in the Configuration to false is correct. This means that TLF will not be responding to key down events on the Enter key by splitting the paragraph. This leaves the door open for you to add your own code that handles the enter key your own way.

Next step, make a keyDown event listener that looks for a keyDown event with charCode == Keyboard.ENTER. When this happens, call insertText( '\u2028'); This is equivalent to having a <br/> in the text, and should also export this way.

Note that if you have a very long paragraph, I would expect the performance to bog down, since the system is optimized for average sized paragraphs.

Also note that the line after a break will not indent (its not considered the first line of the paragraph) and the line before it will not be justified if the paragraph is justified (its not considered to be the last line of the paragraph).

- robin

Julienb54Author
Participating Frequently
September 27, 2010

Hi,

Thanks for the reply and sorry to answer too late but I did other things the last week.

I tried what you've indicated and it creates br tag but again in p tag. I tried to prevent the event of the enter key but nothing passed.

Have you an idea ?

Adobe Employee
September 27, 2010

Sorry, I thought a <br> tag was what you wanted. What do you want the enter key to

do? What is the effect you are trying to get in the markup and visually onscreen?

Thanks,

- robin