PDA

View Full Version : How do I set defaut style sheet for HTML Editor ?



bobpardoe
6 Apr 2011, 2:48 AM
I have worked out that the HTML Editor uses an iframe to host the html formatted text. It has head and body tags. I want to insert a link to the head to set the default style on the editor's contents.

I have found references to the beforesync and aftersync methods but I cannot find a way to addLisener to them that works.

I have been able to do what I want in a form by doing the following in my extended component but I really want to do this in the editor component itself not invoking it from the implementing form.

I get impl from this in the HTMLEdtor code.

impl = protected RichTextAreaImpl impl = GWT.create(RichTextAreaImpl.class);




public void setHeaderHTML()
{
final String link = "<link type='text/css' rel='stylesheet' href='resources/kn/css/HtmlEditor.css'></link>";

setHeadInnerHtml(impl, link);
}

protected native void setHeadInnerHtml(Object rte, String innerHtml) /*-{
rte.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.contentWindow.document.head.innerHTML = innerHtml;
}-*/;



Any ideas appreciated

Thanks

BOb