1

我正在使用相同版本运行 Wicket 7.5.0 和 wicketstuff-tinymcr。

我正在尝试初始化 tinyMce 编辑器,但出现此错误:加载失败: http://localhost:8080/mywebapp/wicket/resource/wicket.contrib.tinymce4.TinyMceBehavior/tinymce/langs/sv.js

虽然加载了小脚本:

http://localhost:8080/mywebapp/wicket/resource/wicket.contrib.tinymce4.TinyMceBehavior/tinymce/tinymce-ver-1481290207000.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();
    }

}
4

2 回答 2

1

似乎 TinyMCESettings 检测到“SV”语言环境并尝试设置语言: https ://github.com/wicketstuff/core/blob/7db920363a8e0254b33b8deccee95688dd922aa5/tinymce4-parent/tinymce4/src/main/java/wicket/contrib/tinymce4/settings /TinyMCESettings.java#L262

在设置中明确设置它null,它不会尝试加载它。

于 2016-12-15T21:55:01.577 回答
0

使用有效的代码进行了编辑。

于 2016-12-19T14:40:25.130 回答