wickettinymce-4wicketstuff

Wicket 7 with wicketstuff tinymce4 Can't load language


I'm running Wicket 7.5.0 and wicketstuff-tinymcr with the same version.

Im trying to initialize a tinyMce editor but I get this error: Failed to load: http://localhost:8080/mywebapp/wicket/resource/wicket.contrib.tinymce4.TinyMceBehavior/tinymce/langs/sv.js

The tiny script is loaded though:

http://localhost:8080/mywebapp/wicket/resource/wicket.contrib.tinymce4.TinyMceBehavior/tinymce/tinymce-ver-1481290207000.js

This seems to be loaded:

plugins/...

themes/...

./tinymce-ver-1481290207000.js

EDIT

This took care of it:

addCustomSetting("language: \"sv_SE\"");

This are the classes that loads it all:

  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
     }
}

The other one:

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();
    }

}

Solution

  • Made an edit with code that works.