gpt4 book ai didi

gwt - 如何在 GWT 中集成 CKEditor

转载 作者:行者123 更新时间:2023-12-04 23:02:51 25 4
gpt4 key购买 nike

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

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

我还看到 CKEditor 在 GWT 之外加载到在 GWT 中创建的 textarea 中。我不确定这是否是一个好方法。

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

最佳答案

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

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

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

关于gwt - 如何在 GWT 中集成 CKEditor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18958728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com