如何在 GWT 中集成 CKEditor [英] How to integrate CKEditor in GWT

查看:35
本文介绍了如何在 GWT 中集成 CKEditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将 CKEditor 集成到我的 GWT 项目中的方法.

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

我进行了一些谷歌搜索并找到了这个项目:https://code.google.com/p/gwt-ckeditor/已被废弃多年.所以CKEditor已经完全过时了.

I've made some googling and found this project: https://code.google.com/p/gwt-ckeditor/ which has been abandoned for years. So the CKEditor is completely outdated.

我还看到 CKEditor 在 GWT 之外加载到在 GWT 中创建的文本区域中.我不确定这是否是一个好方法.

I've also seen the CKEditor being loaded outside of GWT into a textarea created in GWT. I'm not sure if that's a good way.

如果有人能给我一些建议,我将不胜感激.提前致谢

If someone could give me some advises, it would be highly appreciated. Thanks by advance

推荐答案

您可以使用 JSNI 来激活 CKEditor.要加载 javascript 文件,您可以在 html 页面中加载它,或者使用 ScriptInjectorStyleInjector.

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.

在 GWT 中,创建一个组件:

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<String> {
  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);
  }-*/;
}

这是一个示例,在CKEditor中添加您要设置的所有配置

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

这篇关于如何在 GWT 中集成 CKEditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆