1

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

}
Jojje
  • 1,749
  • 3
  • 25
  • 44

2 Answers2

1

It seems TinyMCESettings detects 'SV' locale and tries to set the language: https://github.com/wicketstuff/core/blob/7db920363a8e0254b33b8deccee95688dd922aa5/tinymce4-parent/tinymce4/src/main/java/wicket/contrib/tinymce4/settings/TinyMCESettings.java#L262

Set it explicitly to null in the settings and it won't try to load it.

martin-g
  • 17,243
  • 2
  • 23
  • 35
  • Great, it removes the loading problem. But, I would want to have the editor in the sv locale (not in english). – Jojje Dec 19 '16 at 12:54
0

Made an edit with code that works.

Jojje
  • 1,749
  • 3
  • 25
  • 44