Jump to content

Recommended Posts

Posted

Hi folks...

Back publishing a lot of examples in next days. First this old one that I saw log time ago at the forum with fragmented solutions to uniHTMLMemo. So, you can add custom button, upload image and have a field to do search in the doc. Some solutions from uniGUi Staff and other users. I put together all in one project. Let me know if you think I should implement more stuff ...

So if you need more button, upload image and do search, here we go !

This project is free to download for uniGUI subscribers. In few days will be unavailable and incorporate at our packs.
 

 

Available in pack 04

 

  • Like 2
  • Fred Montier changed the title to uniGUI.Express - uniHTMLMemo with custom buttons, image upload and search
  • 1 month later...
  • 1 month later...
Posted

Ok, sometimes you might need to change one of the existing menu handlers. In my case, I needed a new event handler for when the hyperlink button is clicked. If you are in a similar situation, you can do what I did:
 

function beforeInit(sender, config) {
    config.listeners = {
        render: function(editor) {
            // Add your upload button with complex tooltip
            var uploadButton = editor.getToolbar().add({
                xtype: 'button',
                iconCls: 'fa fa-paperclip',
                text: 'Upload',
                handler: function() {
                    ajaxRequest(sender, 'upload_file', []);
                }
            });
            
            // Set complex tooltip for the upload button
            var uploadTooltip = {
                title: 'File Upload',
                text: 'Upload a file and attach it to the document.',
                cls: 'x-html-editor-tip'
            };
            
            if (uploadButton.setTooltip) {
                uploadButton.setTooltip(uploadTooltip);
            }
            
            // Modify the existing hyperlink button
            var toolbar = editor.getToolbar();
            var items = toolbar.items.items;
            
            for (var i = 0; i < items.length; i++) {
                var item = items[i];
                
                // Check if this is the Hyperlink button
                if (item.iconCls === 'x-edit-createlink' || 
                    (item.tooltip && item.tooltip.title === 'Hyperlink') || 
                    item.itemId === 'createlink') {
                    
                    // Store the original handler function
                    var originalHandler = item.handler;
                    
                    // Override with a new handler that calls both functions
                    item.setHandler(function() {
                        // Call your custom function first
                        console.log('Custom hyperlink action');
                        ajaxRequest(sender, 'custom_link_action', []);
                        
                        // Then call the original handler
                        originalHandler.call(item.scope || item);
                    });
                    
                    // Update the complex tooltip
                    var newTooltip = {
                        title: 'Enhanced Hyperlink',
                        text: 'Make the selected text a hyperlink and perform custom action.',
                        cls: 'x-html-editor-tip'
                    };
                    
                    // Apply the new tooltip
                    if (item.setTooltip) {
                        item.setTooltip(newTooltip);
                    }
                    
                    break;
                }
            }
        }
    };
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...