How to integrate CKEditor in GWT

后端 未结 4 877
挽巷
挽巷 2021-01-13 12:35

I\'m looking for a way to integrate CKEditor in my GWT project.

I\'ve made some googling and found this project: https://code.google.com/p/gwt-ckeditor/ which has be

4条回答
  •  逝去的感伤
    2021-01-13 13:09

    You can use JSNI for activate the CKEditor. For loadning the javascript file, either you load this in the html page, or by using ScriptInjector and StyleInjector.

    In GWT, create a componant :

    package com.google.editor;
    
    import com.google.gwt.core.client.JavaScriptObject;
    import com.google.gwt.user.client.TakesValue;
    import com.google.gwt.user.client.ui.Composite;
    import com.google.gwt.user.client.ui.TextArea;
    
    public class CKeditor extends Composite implements TakesValue {
      TextArea text = new TextArea();
      protected JavaScriptObject editor;
    
      public CKeditor() {
        initWidget(text);
      }
    
      @Override
      protected void onAttach() {
        super.onAttach();
        initCKEditor(text.getElement().getId());
      }
    
      private native void initCKEditor(String id) /*-{
        this.@com.google.editor.CKeditor::editor =  CKEDITOR.replace( id );
      }-*/;
    
      @Override
      public native void setValue(String value) /*-{
        this.@com.google.editor.CKeditor::editor.setData(value);
      }-*/;
    
      @Override
      public native String getValue() /*-{
        this.@com.google.editor.CKeditor::editor.setData(value);
      }-*/;
    }
    

    It's a sample, add all config you want to set in CKEditor

提交回复
热议问题