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

Empty buttons labels using createDropdown #17824

Open
celsowm opened this issue Jan 27, 2025 · 2 comments
Open

Empty buttons labels using createDropdown #17824

celsowm opened this issue Jan 27, 2025 · 2 comments
Labels
domain:dx This issue reports a developer experience problem or possible improvement. type:question This issue asks a question (how to...).

Comments

@celsowm
Copy link

celsowm commented Jan 27, 2025

📝 Ask a question

I am using browser version of ckeditor and when I tried this simple mock code for a plugin:

import {
    Plugin,
    ButtonView,
    Command,
    createDropdown,
    addListToDropdown,
    Collection,
    Model,
} from 'ckeditor5';

export default class TextCasePlugin extends Plugin {

    init() {
        const editor = this.editor;
        editor.ui.componentFactory.add('textCaseDropdown', locale => {

            const dropdownView = createDropdown(locale);

            dropdownView.buttonView.set({
                label: 'Meu Dropdown',
                withText: true,
                tooltip: 'Meu Dropdown'
            });

            const items = new Collection();

            items.add({
                type: 'button',
                model: new Model({
                    label: 'Botão 1',
                    withText: true
                })
            });

            items.add({
                type: 'button',
                model: new Model({
                    label: 'Botão 2',
                    withText: true
                })
            });

            items.add({
                type: 'button',
                model: new Model({
                    label: 'Botão 3',
                    withText: true
                })
            });

            addListToDropdown(dropdownView, items);

            const button1 = items.get(0).model;
            button1.on('execute', () => {
                console.log('Botão 1 clicado');
            });

            const button2 = items.get(1).model;
            button2.on('execute', () => {
                console.log('Botão 2 clicado');
            });

            const button3 = items.get(2).model;
            button3.on('execute', () => {
                console.log('Botão 3 clicado');
            });

            return dropdownView;
        });
    }
}

the result as:

Image

What I did wrong?

@celsowm celsowm added the type:question This issue asks a question (how to...). label Jan 27, 2025
@Witoso
Copy link
Member

Witoso commented Jan 28, 2025

Hey, just by skimming over, I think it's the usage of Model. It should be ViewModel as in the docs.

This is on us, the re-exports from the main index have different names to avoid collisions, and it's been confusing. We will be fixing that in the #17644.

@Witoso Witoso added pending:feedback This issue is blocked by necessary feedback. domain:dx This issue reports a developer experience problem or possible improvement. labels Jan 28, 2025
@celsowm
Copy link
Author

celsowm commented Jan 28, 2025

Hey, just by skimming over, I think it's the usage of Model. It should be ViewModel as in the docs.

This is on us, the re-exports from the main index have different names to avoid collisions, and it's been confusing. We will be fixing that in the #17644.

thanks !

@CKEditorBot CKEditorBot removed the pending:feedback This issue is blocked by necessary feedback. label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. type:question This issue asks a question (how to...).
Projects
None yet
Development

No branches or pull requests

3 participants