I wouldn’t miss TinyMCE so quickly - it has many advantages compared to the GWT text editor - for me these were plugins - I needed a rich text editor that would create bbcode and not html - could not do it with GWT components, Unfortunately. So I expanded the standard bbcode plugin for TinyMCE to fit my needs and voilà :)
, TinyMCE GWT ( , ;)):
: ,
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;
public class TinyMCE extends Composite implements HasText {
private TextArea ta;
private String id;
public TinyMCE(int width, int height) {
super();
VerticalPanel panel = new VerticalPanel();
initWidget(panel);
panel.setWidth("100%");
id = HTMLPanel.createUniqueId();
ta = new TextArea();
ta.setCharacterWidth(width);
ta.setVisibleLines(height);
DOM.setElementAttribute(ta.getElement(), "id", id);
DOM.setStyleAttribute(ta.getElement(), "width", "100%");
panel.add(ta);
}
public String getID() {
return id;
}
protected static native String getEditorContents(
String elementId) ;
protected static native void setEditorContents(
String elementId, String html) ;
public void setText(String text) {
setEditorContents(id, text);
}
public String getText() {
return getEditorContents(id);
}
public void setEnabled(boolean enabled) {
ta.setEnabled(enabled);
}
protected void onLoad() {
super.onLoad();
DeferredCommand.addCommand(new Command() {
public void execute() {
setWidth("100%");
setTextAreaToTinyMCE(id);
focusMCE(id);
}
});
}
protected native void focusMCE(String id) ;
public native void resetMCE() ;
public void unload() {
unloadMCE(id);
}
protected native void unloadMCE(String id) ;
protected native void updateContent(String id) ;
protected native void getTextData(String id) ;
protected native String encodeURIComponent(String text) ;
protected native void setTextAreaToTinyMCE(String id) ;
public native void removeMCE(String id) ;
}
TinyMCE html , - ( mode : "textareas", ):
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
theme : "advanced",
skin : "default",
mode : "textareas",
plugins : "bbcode",
theme_advanced_buttons1 : "bold,italic,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,sup,sub,|,undo,redo,separator,cut,copy,paste,|,fontsizeselect,forecolor,backcolor",
theme_advanced_buttons2 : "blockquote,link,unlink,image,styleselect,removeformat,|,charmap,code",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "bottom",
theme_advanced_toolbar_align : "center",
theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle;PHP Code=phpCodeStyle",
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
button_tile_map : true
});
</script>
, http://www.ohloh.net/p/tinymce-gwt