Skip to main content
June 1, 2011
Question

how to use default styles/formats in rich text editor?

  • June 1, 2011
  • 1 reply
  • 470 views

Dear,

We are building an online tool to create presentations. Each presentation has default settings like default Header style, Body style etc (fontname, fontsize, color). The aim is to create a rich text editor which handles those default styles - the user can use multiple styles in the same textbox. The trick is that all the textboxes has to update itself when the default styles are updated by a global style editor.

I have been looking for examples how to use the style property in TextFlow, FlowElement. I also checkted the hostFormat etc, but I found nothing in this topic how to use styles. I also checked something like CSSFormatResolver with no success.

My target is to assign a TextLayoutFormat to an element like ParagraphElement, then let the element updates itself if the particular TextLayoutFormat is updated which happens by changing the default style. I would create three TextLayoutFormat for each style like Header, Body, etc.

Is there any way to do that? Suggestions?

Thanks,

Benjamin

This topic has been closed for replies.

1 reply

Adobe Employee
June 2, 2011

TextLayoutFormat is all the *format* or *style* thing in TLF. Format is cascading. The render depends on the finally computed format. You can regard hostFormat as the default format of a textflow and then you can separately set format of all the child elements in the textflow.

There is another way to set default format using Configuration.

_____________________________________________________________________________

            var config:Configuration = new Configuration();


            var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
            textLayoutFormat.textAlign = TextAlign.CENTER;
            config.textFlowInitialFormat = textLayoutFormat;
            var linkNormalFormat:TextLayoutFormat = new TextLayoutFormat();
            // make links red and underlined
            linkNormalFormat.color = 0xFF0000;
            linkNormalFormat.textDecoration = TextDecoration.UNDERLINE;
            config.defaultLinkNormalFormat = linkNormalFormat;
            // set selection color to light blue
              var selectionFormat:SelectionFormat = new SelectionFormat(0x333300);
              config.focusedSelectionFormat = selectionFormat;


            var textFlow:TextFlow = new TextFlow(config);

______________________________________________________________________________

But there is no publish&subcribe among several TextLayoutFormats. I think observer design pattern is a good choice for that publish&subcribe job.