Dropdown

create #

Arguments
name String
params Object

Here's an example of how to create a dropdown.


Redactor.add('plugin', 'myplugin', {
    start() {
        let button = {
            title: 'My button',
            icon: '<svg...>',
            command: 'myplugin.popup',
            position: {
                after: 'format'
            },
            blocks: {
                all: 'editable'
            }
        };

        this.app.toolbar.add('myplugin', button);
        this.app.context.add('myplugin', button);
    },
    popup(e, button) {
        let items = {
            item1: { title: 'Item 1', command: 'myplugin.set' },
            item2: { title: 'Item 2', command: 'myplugin.set' },
        };

        // create dropdown
        this.app.dropdown.create('myplugin', { items: items });
        this.app.dropdown.open(e, button);
    },
    set(params, item, name) {
        ...
    }
});

close #

Closes the opened dropdown.


this.app.dropdown.close();

isOpen #

Checks if a dropdown is opened.


if (this.app.dropdown.isOpen()) {
    ...
}

getName #

Returns a name of the opened dropdown.


let name = this.app.dropdown.getName();