Documentation / API Reference

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
        let dropdown = this.app.create('dropdown', 'myplugin', { items: items });
        this.app.dropdown.open(e, button, dropdown);
    },
    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();