Lack of interest [Developer Tool] Custom BBCode: Allow specifying a dialog loader

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

DragonByte Tech

Well-known member
At the moment, if 3rd party add-ons want to add custom BBCode with an overlay like the Spoiler dialog, we have to overwrite the xfCustom entry in the Froala list of commands, like so:

JavaScript:
$.FE.RegisterCommand('xfCustom_charge', {
    title: custom.charge.title,
    icon: 'xfCustom_charge',
    undo: true,
    focus: true,
    callback: function()
    {
        XF.EditorHelpers.loadDialog(this, 'dbtechCreditsCharge');
    }
});

This effectively removes the ability for users to customise the BBCode and change the wording, in the above example if they want to use another tag other than [CHARGE] as their BBCode.

Please consider adding another option under "Advanced Options", where you can optionally specify a dialog reference. To avoid confusion for end-users, it might be useful to only show this option when the site is in development mode.

You could then extend the js-editorCustom array like so:
JSON:
"charge":{"title":"Charge","type":"fa","value":"money","option":"yes","dialog":"dbtechCreditsCharge"}

And change the registerCustomCommands callback like so:
JavaScript:
    if (def.dialog)
    {
        XF.EditorHelpers.loadDialog(this, def.dialog);
    }
    else
    {
        XF.EditorHelpers.wrapSelectionText(
            this,
            def.option == 'yes' ? '[' + tagUpper + '=]' : '[' + tagUpper + ']',
            '[/' + tagUpper + ']',
            true
        );
    }

In order to ensure the dialog in question is available, I would also suggest adding a new event to registerDialogs
JavaScript:
$(document).trigger('editor:register-dialogs');

So that we can easily insert our own dialogs without having to replicate the editor start process.

I believe adding this will significantly improve the functionality of custom editor buttons added by 3rd party addons.


Fillip
 
Upvote 6
This suggestion has been closed. Votes are no longer accepted.
Top Bottom