ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.79k stars 2.47k forks source link

Issue with custom file browser with compressed/packaged download #1693

Open Bill1000 opened 6 years ago

Bill1000 commented 6 years ago

Are you reporting a feature request or a bug?

Bug

Provide detailed reproduction steps (if any)

Adding a custom file browser button to a dialog works using the big source version of ckeditor but not the compressed/packaged download version.

This seems to be an old issue: https://dev.ckeditor.com/ticket/8466

With the compressed/packaged download of ckeditor nothing happens, no console errors, no events attached to the button. However, works fine if you use the full source version. Seems it's changing the order of attaching the events somehow.

CKEDITOR.on( 'dialogDefinition', function( ev ) {
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    if ( dialogName == 'link' ) {
        var infoTab = dialogDefinition.getContents( 'info' );
        infoTab.add( {
            type: 'button',
            label: 'Custom File Browser',
            id: 'browseCustom',
             filebrowser :
             {
                 action : 'Browse',
                 url : '/custom/file/browser' 
             },
        });
    }
});

Expected result

Expect it to work the same in both versions.

Actual result

It only works in the full source version.

Other details

Tested with v4.7.1 and 4.8.0

msamsel commented 6 years ago

Hi

I think explanation made in linked issue might be still valid to current version of editor. I just wonder why you want to redefine dialog definition to add "File Browser" in such way? Maybe satisfying for you will be just providing your url to current file browsers: https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-filebrowserBrowseUrl https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-filebrowserUploadUrl

Bill1000 commented 6 years ago

We need to add a 2nd browser that allows you to browse the CMS page tree. Using the filebrowser type is nice because it opens the url in a pop-out and has documentation on how to populate the url, but we can try to duplicate the behavior with a standard button if there is no way to fix this?

msamsel commented 6 years ago

Only idea which came to my mind to somehow workaround the bug is it manually update link plugin according to your need and adding it to your CKEditor instance. https://github.com/ckeditor/ckeditor-dev/blob/9409e28dadf1564ec35987bcd888dfe6df23ef0d/plugins/link/dialogs/link.js#L215

Bill1000 commented 6 years ago

Thanks. I appreciate you looking at this. I can use the source version for now or try to re-create what we need with a standard button, but I'm wondering why the event processing order changes when the package gets made?