作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找一种将 CKEditor 集成到我的 GWT 项目中的方法。
我做了一些谷歌搜索并找到了这个项目:https://code.google.com/p/gwt-ckeditor/
已被遗弃多年。所以CKEditor已经完全过时了。
我还看到 CKEditor 在 GWT 之外加载到在 GWT 中创建的 textarea 中。我不确定这是否是一个好方法。
如果有人能给我一些建议,将不胜感激。
提前致谢
最佳答案
您可以使用 JSNI 来激活 CKEditor。
要加载 javascript 文件,要么在 html 页面中加载它,要么使用 ScriptInjector和 StyleInjector .
在 GWT 中,创建一个组件:
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);
}-*/;
}
关于gwt - 如何在 GWT 中集成 CKEditor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18958728/
我是一名优秀的程序员,十分优秀!