Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom dropdown with grapesjs-plugin-ckeditor plugin #90

Open
romainlembo-zenchef opened this issue Oct 2, 2024 · 0 comments
Open

Comments

@romainlembo-zenchef
Copy link

romainlembo-zenchef commented Oct 2, 2024

I'm working on a project using GrapesJS and the grapesjs-plugin-ckeditor plugin. I want to add a custom dropdown to the CKEditor toolbar, alongside other default toolbar actions, but I am encountering issues with the integration.

Issue:

I've followed the documentation to configure CKEditor and added a custom dropdown using a CKEditor plugin. However, the dropdown doesn't appear in the toolbar as expected. It seems that the grapesjs-plugin-ckeditor doesn't properly support adding custom dropdowns or modifying the toolbar configuration.

Expected

I would like something like that:
image

Current Setup:

Here is my current configuration:

const editor = grapesjs.init({
    container: '#gjs',
    components: templateContent,
    plugins: [rtePlugin],
    pluginsOpts: {
        [rtePlugin]: {
            options: {
                toolbar: [
                    { name: 'styles', items: ['Font', 'FontSize'] },
                    { name: 'basicstyles', items: ['Bold', 'Italic'] },
                    // Custom Dropdown
                    { name: 'customDropdown', items: ['CustomDropdown'] }
                ],
                extraPlugins: 'customDropdown',
            },
            ckeditor: 'https://cdn.ckeditor.com/4.21.0/full-all/ckeditor.js'
        }
    }
});

CKEDITOR.plugins.add('customDropdown', {
    init: function (editor) {
        editor.ui.addRichCombo('CustomDropdown', {
            label: 'My Custom Dropdown',
            toolbar: 'customDropdown',
            panel: {
                multiSelect: false
            },
            init: function () {
                this.add('option1', 'Option 1');
                this.add('option2', 'Option 2');
            },
            onClick: function (value) {
                editor.insertText('You selected: ' + value);
            }
        });
    }
});

Dependencies:

"react": "18.3.1",
"grapesjs": "^0.21.8",
"grapesjs-blocks-basic": "^1.0.2",
"grapesjs-plugin-ckeditor": "^1.0.1",
"grapesjs-preset-newsletter": "^1.0.2",

Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant