jmcameron / attachments

Attachments Extension for Joomla 3, 4, and 5
GNU General Public License v3.0
12 stars 19 forks source link

Rework plugin insert attachment token #54

Closed JLTRY closed 1 month ago

JLTRY commented 1 month ago

Rewrite insert attachment token with Joomla 4 like implementation

JLTRY commented 1 month ago

@parapente could you please check the plugin. It works with at least joomla 5

parapente commented 1 month ago

@JLTRY I would suggest to make some changes for the plugin to fully work correctly for both Joomla 4 and 5. In InsertAttachmentToken.php line 128:

$js =  "
    function insertAttachmentsToken(editorName) {
        let editor = Joomla.editors.instances[editorName];
        let content = editor.getValue();
        if (content.match(/\{\s*attachments/i)) {
            alert('$present');
            return false;
        } else {
            editor.replaceSelection('<span class=\"hide_attachments_token\">{attachments}</span>');
        }
    }
    ";

This fixes the {attachments} tag placement in the editor.

Also just before the return $button:

$button->link = '#';

This fixes compatibility with Joomla 4 and it should be ready for merging.

parapente commented 1 month ago

Oh I forgot one thing, comment the $button->title line as otherwise it shows the description as the button title making it huge. The $button->text is enough.

JLTRY commented 1 month ago

Hello I will do the modifications when I will be back . I am in vacations for 10 days

JLTRY commented 1 month ago

Hello @parapente I added your remarks and tested it OK for Joomla 4 and Joomla 5