wicketstuff / core

Wicketstuff-core projects are bundled user contributions for use with Apache Wicket (https://wicket.apache.org/). They are released in step with Wicket releases to make them easy to use.
337 stars 298 forks source link

TinyMCE doesn't work for wicket 1.5 (baseURL problem) #74

Closed PhantomYdn closed 11 years ago

PhantomYdn commented 12 years ago

Hello,

I have following page:

@MountPath("/editpage/${pageId}")
@AuthorizeInstantiation("ADMIN")
public class EditPagePage extends GenericPage<Page>
{

and

        form.add(new TextArea("content").add(new TinyMceBehavior()));

And durung loading of page I recive following:

Failed to load: http://localhost:8080/editpage//themes/simple/editor_template.js
Failed to load: http://localhost:8080/editpage//langs/en.js

By tracing of code I realize that baseURL can't be calculated in tinymce._init method because some incorrectness in:

function getBase(n) {
if (n.src && /tiny_mce(|_gzip|_jquery|_prototype|_full)(_dev|_src)?.js/.test(n.src)) {
if (/_(src|dev)\.js/g.test(n.src))
t.suffix = '_src'; 

because URL of script for tinymce to include is following:

../wicket/resource/wicket.contrib.tinymce.InPlaceEditBehavior/tiny_mce/tiny_mce_src-ver-1321430948000.js

PhantomYdn commented 12 years ago

I use following workaround:

public static TinyMceBehavior createTinyMceBehavior()
    {
        return new TinyMceBehavior()
        {
            private static final long serialVersionUID = 4802148816874932787L;
            @Override
            public void renderHead(Component c, IHeaderResponse response)
            {
                response.renderJavaScript("var dlh = document.location.href; window.tinyMCEPreInit = {suffix:'', " +
                                                                    "base: dlh.substring(0, dlh.indexOf('/',dlh.indexOf('://')+3))," +
                                                                    "query:''};", "TinyMceBehavior.myhack");
                super.renderHead(c, response);
            }           
        };
    }
balamaci commented 12 years ago

Your workaround worked Phantom for fixing the icons, however it messes with my custom contentCss file:

What's being generated now is: /wicket/resource/wicket/resource/com.balamaci.web.util.tinymce.TinyMCETextArea/mymcesettings-ver-1322513305000.css

notice the double /wicket/resource appearing.

condig commented 12 years ago

I have the same issue like balamaci. No custom_css is working for me

bgooren commented 11 years ago

You can easily circumvent this issue by using

TinyMCESettings.lazyLoadTinyMCEResource( response );

or have a look what it does (most importantly: set the base path), and do that manually.

KluDev commented 11 years ago

Please close this bug. It's also more than two years old.