PDA

View Full Version : Using styles in HTMLEditor



jobe451
31 May 2009, 7:37 AM
Hi

I'd like to use the HTMLeditor. However, currently there seem to be features missing which seem to be important to me:
- The editor does not use the stylesheets of the page in what it is running
- There is no way to assign a certain style to a selection

Searching the forum, it seems to me that such features were already implemented for ext itself:
http://www.extjs.net/forum/showthread.php?t=9588&highlight=HtmlEditor+stylesheet
http://www.extjs.net/forum/showthread.php?t=19059&highlight=HtmlEditor+heading

Are those features also available for gxt?

dawesi
31 May 2009, 6:09 PM
it's a 'basic' editor only at the moment. I'm sure I've seen an example of styles in the editor somewhere on this forum though. There are plugins for mce and fckeditor if you want a more featured editor in ext.

jobe451
7 Jun 2009, 5:24 PM
I finally found an answer to my problems:

There are a few free open source rich text editors which can be used. Here an example how to integrate tinyMCE in GWT.
http://consult.goannatravel.com/blog/2007/11/22/gwt-tinymce-widget/

Seems to be a full featured and highly customizable solution.

sthamman
14 Jan 2011, 12:41 PM
In case if anyone what's to add style sheets to HtmlEditor... here is the code...



new HtmlEditor(){
@Override
public void setRawValue(String value) {
super.setRawValue(value);
Timer t = new Timer() {
@Override
public void run() {
Document d = IFrameElement.as(
getElement().getElementsByTagName("iframe").getItem(0))
.getContentDocument();
LinkElement style = d.createLinkElement();
style.setType("text/css");
style.setHref("gxt/css/gxt-all.css");
style.setRel("stylesheet");
Element elt = (Element) d.getElementsByTagName("head").getItem(
0);
HeadElement head = HeadElement.as(elt);
head.insertFirst(style);
}
};
t.schedule(500);
}
}