我正在使用相同版本运行 Wicket 7.5.0 和 wicketstuff-tinymcr。
我正在尝试初始化 tinyMce 编辑器,但出现此错误:加载失败: http://localhost:8080/mywebapp/wicket/resource/wicket.contrib.tinymce4.TinyMceBehavior/tinymce/langs/sv.js
虽然加载了小脚本:
这似乎已加载:
插件/...
主题/...
./tinymce-ver-1481290207000.js
编辑
这处理了它:
addCustomSetting("语言:\"sv_SE\"");
这是加载所有内容的类:
import wicket.contrib.tinymce4.settings.TinyMCESettings;
public class MyTinyMCESettings extends TinyMCESettings {
public MyTinyMCESettings(TinyMCESettings.Theme theme) {
super(theme);
addCustomSetting("plugins: 'autoresize'");
addCustomSetting("language: \"sv_SE\""); // this works
}
}
另一个:
import org.apache.wicket.Component;
import wicket.contrib.tinymce4.TinyMceBehavior;
import wicket.contrib.tinymce4.settings.TinyMCESettings;
public class MyTinyMceBehavior extends TinyMceBehavior {
public static final String KEY_EVENT = "keyup";
private Component component;
private TinyMCESettings settings;
public MyTinyMceBehavior(TinyMCESettings settings) {
super(settings);
this.settings = settings;
}
@Override
protected String getScript(TinyMCESettings.Mode mode, Collection<Component> components) {
StringBuilder script = new StringBuilder();
script.append(" tinyMCE.init({")
.append(settings.toJavaScript(mode, components))
.append(",onchange_callback : function (ed) {\n" +
" var text = ed.getContent();" +
" $('#" + component.getMarkupId() + "').html(text).trigger('" + KEY_EVENT + "');" +
"}")
.append("});\n");
return script.toString();
}
}